1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
| import os import itertools
def func(s): v70 = 0 v4 = len(s) v5 = 0 v71 = v4 v6 = v4 v72 = 0 if v4 != 0: v7 = s for i in range(v6): v5 = ord(v7[i]) ^ v5 v5 = v5 & 0xFF v8 = 8 for j in range(8): v9 = 2 * v5 v9 = v9 & 0xFF v10 = v9 ^ 7 if v9 < 0x80: v10 = v9 v5 = v10 v4 = v71 v72 = v10 print('Part 0x0 Calculate v72 For Part 0x4: ', hex(v72)) list_5B20 = sub_40106C() for x in list_5B20: pass v11 = 0xFFFFFFFF for i in range(v4): tmp = list_5B20[0xFF & (v11 ^ ord(s[i]))] if v11 >= 0x80000000: v11 = ((v11 >> 8) | 0xFF000000) ^ tmp else: v11 = (v11 >> 8) ^ tmp v67 = v11 ^ 0xFFFFFFFF print('Part 0x2, This Value Should Be 0xF52E0765: ', hex(v67)) if v67 == 0xf52e0765: return 1
s = sub_4010B7(s, v4) print('Part 0x3 Manipulat Original String, Used For Xor: ', s) v13 = v72 v69 = 1 v14 = v72 + 1 v66 = [] while(v13 < v14): if v13 > 0x80: v15 = 0xFFFFFF00 | v13 for j in range(200): if (v15 & 1) != 0: v15_abs = 0xFFFFFFFF - v15 + 1 v15_abs = 3 * v15_abs - 1 v15 = 0xFFFFFFFF - (v15_abs - 1) else: if v15 > 0x80000000: v15 = (v15 >> 1) | 0x80000000 else: v15 = v15 >> 1 v66.append(hex(v15)) else: v15 = v13 & 0xFF for j in range(200): if (v15 & 1) != 0: v15 = 3 * v15 + 1 else: if v15 > 0x80000000: v15 = (v15 >> 1) | 0x80000000 else: v15 = v15 >> 1 v66.append((v15)) v13 = v13 + 1 if v72 < 0x80: print('Part 0x5, Calculate With Or: ', (v66[195]), (v66[196]), (v66[197])) v17 = (v66[195]) | (v66[196]) | (v66[197]) v18 = v71 cmp_a = (s[0])^(s[1])^(s[2]) print('Part 0x5, Or Result: ', hex(v17)) print('Part 0x5, Xor Result: ', hex(cmp_a)) else: print('Part 0x5, Calculate With Or: ', hex(int(v66[195], 16)), hex(int(v66[196], 16)), hex(int(v66[197], 16))) v17 = int(v66[195], 16) | int(v66[196], 16) | int(v66[197], 16) v18 = v71 cmp_a = (s[0])^(s[1])^(s[2]) print('Part 0x5, Or Result: ', hex(v17)) print('Part 0x5, Xor Result: ', hex(cmp_a)) v19 = v17 + 2 v20 = v18 - v19 - 7 print('Part 0x6, This Value Should Be Less Than Or Equal 0: ' , v20) print('Part 0x7, s[3] should be 0x14/20: ', s[3]) print('Part 0x7, s[4] should be 0xC/12: ', s[4]) print('Part 0x7, s[5] should be 0x1D/29: ', s[5]) print('Part 0x7, s[5] should be 0xF/15: ', s[6]) v74 = s[6:] print('Part 0x8, Rest Length Of String: ', v19) v21 = 0 v71 = 0 if v19 > 0: v22 = 1 for i in range(v19): v23 = v74[v22] + 10 * v70 print('Part 0x8, (' ,v23, '=', v74[v22], '+', '10 *', v70, ')%', v69, '==', v23%v69) v24 = v23 - 0x37373737 if v23 <= 0x4B435445: v24 = v23 v70 = v24 if (v24 % v69): print('Failed! ') return 0 v69 = v69 + 1 v22 = v69 v25 = v19 - 1 if (v19 - 1) > 0: v26 = v19 - 1 for i in range(v26): v27 = 0 if v25 > 0: for i in range(v25): v28 = v74[v27 + 1] v29 = v74[v27 + 2] if v28 > v29: v74[v27 + 1] = v29 v74[v27 + 2] = v28 v27 = v27 + 1 v25 = v25 - 1 print('Part 0x9, Last 9 Elements After Sort: ', v74[1:]) a_str = '1234567890_ABCDEFGHIJKLMNOPQRSTUVWXYZ' a_str = sub_4010B7(a_str, v19) print('Part 0xA, a_str: ', a_str) v30 = 0 if v19 > 0: for i in range(v19): print('Part 0xA, Compare 2: ', a_str[v30], v74[v30+1]) if a_str[v30] != v74[v30+1]: print('Failed!') return 0 v30 = v30 + 1 return 0 def sub_4010B7(s, length): res = [] for i in range(length): v4 = ord(s[i]) v5 = 48 if v4 >= 58: v5 = 55 res.append((v4 - v5) & 0xFF) return res
def sub_40106C(): v1 = [] for i in range(1024): v2 = i v3 = 8 for j in range(8): if (v2 & 1) != 0: tmp = 0xEDB88320 else: tmp = 0 if v2 >= 0x80000000: v2 = ((v2 >> 1) | 0x80000000) ^ tmp else: v2 = (v2 >> 1) ^ tmp v1.append(v2) v1.append(1) return v1
if __name__ == '__main__':
s = 'A7AKCTF381654729' res = func(s) ''' # Fuzz One For Last 9 Bytes prefix = 'A7AKCTF' maybe_result = [] example = '123456789' result = itertools.permutations(example) for x in result: suffix = ''.join(x) s = prefix + suffix #print(s) res = func(s) if res == 1: print(res, s) break print(maybe_result) ''' ''' # Fuzz Two For First 3 Bytes suffix = 'KCTF381654729' text = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVMXYZ' result = itertools.permutations(text, 3) for x in result: prefix = ''.join(x) s = prefix + suffix #print(s) res = func(s) if res == 1: print(res, s) break '''
|