Created
October 21, 2016 09:36
-
-
Save msm-code/1cbf0c21ff12449d575e1b0bbe3739d3 to your computer and use it in GitHub Desktop.
paper.python.b29d1255e212fce3077bc026a860e2cf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def dga_single(self, state): | |
| name = '' | |
| len = self.getbyte(state, 8) + 5 | |
| for i in range(len): | |
| r = self.getbyte(state, 0xFFFFFFFF) | |
| c = self.getbyte(state, 26) + 0x61 | |
| name += chr(c) | |
| n = 0 | |
| while n == 0: | |
| n = self.getbyte(state, 5) | |
| name += '.' + [0, 'net', 'com', 'in', 'pw'][n] | |
| return name | |
| def getbyte(self, state, param): | |
| temp0 = ((state[0] << 11) ^ state[0]) & 0xFFFFFFFF | |
| temp2 = state[2] | |
| state[0] = (state[0] + state[1]) & 0xFFFFFFFF | |
| state[1] = (state[1] + state[2]) & 0xFFFFFFFF | |
| state[2] = (state[2] + state[3]) & 0xFFFFFFFF | |
| state[3] = ((state[3] >> 19) ^ state[3] ^ temp0 ^ (temp0 >> 8)) & 0xFFFFFFFF | |
| return (((state[3] + temp2) & 0xFFFFFFFF) % (param * 100)) / 100 | |
| def __init__(self, seed, date): | |
| arg8 = seed + date.day + (date.year << 9) + (date.month << 5) | |
| state = [0] * 4 | |
| state[0] = (arg8 + seed) & 0xFFFFFFFF | |
| state[1] = ror(state[0] * 2, 4) | |
| state[2] = ror(bswap(state[1]), 0xE) + seed | |
| state[3] = ror(state[2] + state[1], 0x12) | |
| for i in range(16): | |
| next_byte = self.getbyte(state, 0xFFFFFFFF) | |
| dword_ndx, byte_ndx = i / 4, i % 4 | |
| byte_mask = 0xFF << (byte_ndx * 8) | |
| state[dword_ndx] = (state[dword_ndx] & ~byte_mask) | | |
| ((next_byte & 0xFF) << (byte_ndx * 8)) | |
| self.state = state |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment