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 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
| import numpy as np from z3 import * from Crypto.Util.number import *
sr = np.array([ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x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xb7, 0x17, 0xf7, 0x8c, 0x79, 0xd6, 0xa7, 0xbf, 0x8b, 0x3f, 0x1f, 0x53, 0x63, 0x75, 0x35, 0x2c, 0x60, 0xfd, 0x27, 0xd3, 0x94, 0xa5, 0x7c, 0xa1, 0x05, 0x58, 0x2d, 0xbd, 0xd9, 0xc7, 0xaf, 0x6b, 0x54, 0x0b, 0xe0, 0x38, 0x04, 0xc8, 0x9d, 0xe7, 0x14, 0xb1, 0x87, 0x9c, 0xdf, 0x6f, 0xf9, 0xda, 0x2a, 0xc4, 0x59, 0x16, 0x74, 0x91, 0xab, 0x26, 0x61, 0x76, 0x34, 0x2b, 0xad, 0x99, 0xfb, 0x72, 0xec, 0x33, 0x12, 0xde, 0x98, 0x3b, 0xc0, 0x9b, 0x3e, 0x18, 0x10, 0x3a, 0x56, 0xe1, 0x77, 0xc9, 0x1e, 0x9e, 0x95, 0xa3, 0x90, 0x19, 0xa8, 0x6c, 0x09, 0xd0, 0xf0, 0x86 ], dtype=np.uint8)
def mulx(V, c): return (V << 1) ^ (c*((V&0x80)>>7)) def mulx_pow(V, i, c): if i == 0: return V else: return mulx(mulx_pow(V, i - 1, c), c)
def mul_alpha(c): r0 = mulx_pow(c, 23, 0xa9) & 0xff r1 = mulx_pow(c, 245, 0xa9) & 0xff r2 = mulx_pow(c, 48, 0xa9) & 0xff r3 = mulx_pow(c, 239, 0xa9) & 0xff return (r0 << 24) | (r1 << 16) | (r2 << 8) | r3
def div_alpha(c): r0 = mulx_pow(c, 16, 0xa9) & 0xff r1 = mulx_pow(c, 39, 0xa9) & 0xff r2 = mulx_pow(c, 6, 0xa9) & 0xff r3 = mulx_pow(c, 64, 0xa9) & 0xff return (r0 << 24) | (r1 << 16) | (r2 << 8) | r3 def s1(w): w0 = (w >> 24) & 0xff w1 = (w >> 16) & 0xff w2 = (w >> 8) & 0xff w3 = w & 0xff
r0 = (mulx(sr[w0], 0x1b) ^ sr[w1] ^ sr[w2] ^ mulx(sr[w3], 0x1b) ^ sr[w3]) & 0xff r1 = (mulx(sr[w0], 0x1b) ^ sr[w0] ^ mulx(sr[w1], 0x1b) ^ sr[w2] ^ sr[w3]) & 0xff r2 = (sr[w0] ^ mulx(sr[w1], 0x1b) ^ sr[w1] ^ mulx(sr[w2], 0x1b) ^ sr[w3]) & 0xff r3 = (sr[w0] ^ sr[w1] ^ mulx(sr[w2], 0x1b) ^ sr[w2] ^ mulx(sr[w3], 0x1b)) & 0xff
return (int(r0) << 24) | (int(r1) << 16) | (int(r2) << 8) | int(r3)
def s2(w): w0 = (w >> 24) & 0xff w1 = (w >> 16) & 0xff w2 = (w >> 8) & 0xff w3 = w & 0xff
r0 = (mulx(sq[w0], 0x69) ^ sq[w1] ^ sq[w2] ^ mulx(sq[w3], 0x69) ^ sq[w3]) & 0xff r1 = (mulx(sq[w0], 0x69) ^ sq[w0] ^ mulx(sq[w1], 0x69) ^ sq[w2] ^ sq[w3]) & 0xff r2 = (sq[w0] ^ mulx(sq[w1], 0x69) ^ sq[w1] ^ mulx(sq[w2], 0x69) ^ sq[w3]) & 0xff r3 = (sq[w0] ^ sq[w1] ^ mulx(sq[w2], 0x69) ^ sq[w2] ^ mulx(sq[w3], 0x69)) & 0xff return (int(r0) << 24) | (int(r1) << 16) | (int(r2) << 8) | int(r3)
def clock_fsm(s15, s5): F = (s15 + fsm[0]) ^ fsm[1] r = fsm[1] + (fsm[2] ^ s5) fsm[2] = s2(fsm[1]) fsm[1] = s1(fsm[0]) fsm[0] = r return F
def lfsr_keystream_mode(S0,S2,S11): v = (S0 << 8) ^ mul_alpha((S0 >> 24) & 0xff) ^ S2 ^ (S11 >> 8) ^ \ div_alpha(S11 & 0xff) return v
def de_lfsr_keystream_mode(S0, S2, S11, S16): if S0 == '': S0 = BitVec('S0', 32) else: S0 = np.uint32(S0) if S2 == '': S2 = BitVec('S2', 32) else: S2 = np.uint32(S2) if S11 == '': S11 = BitVec('S11', 32) else: S11 = np.uint32(S11) if S16 == '': S16 = BitVec('S16', 32) else: S16 = np.uint32(S16) solver = Solver() solver.add(S16 == lfsr_keystream_mode(S0, S2, S11))
if solver.check() == sat: res = solver.model() if isinstance(S0, BitVecRef): return res[S0].as_long() if isinstance(S2, BitVecRef): return res[S2].as_long() if isinstance(S11, BitVecRef): return res[S11].as_long() if isinstance(S16, BitVecRef): return res[S16].as_long() else: return False
def de_s1(s): r0=(s>>24)&0xff r1=(s>>16)&0xff r2=(s>>8)&0xff r3=s&0xff
def mulx(V, c): return (V << 1) ^ (c*LShR(V, 7))& 0xff solver=Solver() srw0,srw1,srw2,srw3=BitVecs('srw0 srw1 srw2 srw3', 8) solver.add(r0 == (mulx(srw0, 0x1b) ^ srw1 ^ srw2 ^mulx(srw3, 0x1b) ^ srw3) & 0xff) solver.add(r1 == (mulx(srw0, 0x1b) ^ srw0 ^ mulx(srw1, 0x1b) ^ srw2 ^ srw3) & 0xff) solver.add(r2 == (srw0 ^ mulx(srw1, 0x1b) ^ srw1 ^ mulx(srw2, 0x1b) ^ srw3) & 0xff) solver.add(r3 == (srw0 ^ srw1 ^ mulx(srw2, 0x1b) ^ srw2 ^ mulx(srw3, 0x1b)) & 0xff)
if solver.check()==sat: res=solver.model() __sr=sr.tolist() w0=__sr.index(res[srw0].py_value()) w1=__sr.index(res[srw1].py_value()) w2=__sr.index(res[srw2].py_value()) w3=__sr.index(res[srw3].py_value()) return (w0 << 24) | (w1 << 16) | (w2 << 8) | w3 else: return False def de_s2(s): r0=(s>>24)&0xff r1=(s>>16)&0xff r2=(s>>8)&0xff r3=s&0xff
def mulx(V, c): return (V << 1) ^ (c*LShR(V, 7))& 0xff solver=Solver() sqw0,sqw1,sqw2,sqw3=BitVecs('sqw0 sqw1 sqw2 sqw3', 8) solver.add(r0 == (mulx(sqw0, 0x69) ^ sqw1 ^ sqw2 ^mulx(sqw3, 0x69) ^ sqw3) & 0xff) solver.add(r1 == (mulx(sqw0, 0x69) ^ sqw0 ^ mulx(sqw1, 0x69) ^ sqw2 ^ sqw3) & 0xff) solver.add(r2 == (sqw0 ^ mulx(sqw1, 0x69) ^ sqw1 ^ mulx(sqw2, 0x69) ^ sqw3) & 0xff) solver.add(r3 == (sqw0 ^ sqw1 ^ mulx(sqw2, 0x69) ^ sqw2 ^ mulx(sqw3, 0x69)) & 0xff)
if solver.check()==sat: res=solver.model() __sq=sq.tolist() w0=__sq.index(res[sqw0].py_value()) w1=__sq.index(res[sqw1].py_value()) w2=__sq.index(res[sqw2].py_value()) w3=__sq.index(res[sqw3].py_value()) return (w0 << 24) | (w1 << 16) | (w2 << 8) | w3 else: return False
def checkS(): flag=False for i in range(len(S)-16): __l=[type(S[i]),type(S[i+2]),type(S[i+11]),type(S[i+15+1])] if __l.count(int)==3: flag=True if __l.index(str)==3: S[i+15+1]=int(lfsr_keystream_mode(np.uint32(S[i+0]),np.uint32(S[i+2]),np.uint32(S[i+11]))) else: __index=[i,i+2,i+11,i+15+1] S[__index[__l.index(str)]]=de_lfsr_keystream_mode(S[i],S[i+2],S[i+11],S[i+15+1]) return flag
def checkFSM(): flag=False for i in range(len(fsm)-5): if type(fsm[i][1])==int and type(fsm[i+1][2])!=int: fsm[i+1][2]=int(s2(fsm[i][1])) flag=True if type(fsm[i][0])==int and type(fsm[i+1][1])!=int: fsm[i+1][1]=int(s1(fsm[i][0])) flag=True if type(fsm[i][1])!=int and type(fsm[i+1][2])==int: fsm[i][1]=de_s2(fsm[i+1][2]) flag=True if type(fsm[i][0])!=int and type(fsm[i+1][1])==int: fsm[i][0]=de_s1(fsm[i+1][1]) flag=True __l=[type(fsm[i][1]),type(fsm[i][2]),type(S[i+5]),type(fsm[i+1][0])] if __l.count(int)==3: flag=True __=__l.index(str) if __==0: fsm[i][1]=(fsm[i+1][0]-(fsm[i][2]^S[i+5]))%2**32 elif __==1: fsm[i][2]=((fsm[i+1][0]-fsm[i][1])^S[i+5])%2**32 elif __==2: S[i+5]=((fsm[i+1][0]-fsm[i][1])^fsm[i][2])%2**32 elif __==3: fsm[i+1][0]=(fsm[i][1]+(fsm[i][2]^S[i+5]))%2**32 return flag
def checkFSFSM(): flag=False for i in range(len(S)-15): __l=[type(fsm[i][0]),type(fsm[i][1]),type(F[i]),type(S[i+15])] if __l.count(int)==3: flag=True __=__l.index(str) if __==0: fsm[i][0]=((F[i]^fsm[i][1])-S[i+15])%2**32 elif __==1: fsm[i][1]=(F[i]^(S[i+15]+fsm[i][0]))%2**32 elif __==2: F[i]=((S[i+15]+fsm[i][0])^fsm[i][1])%2**32 elif __==3: S[i+15]=((F[i]^fsm[i][1])-fsm[i][0])%2**32 return flag
def checkFSSTREAM(): flag=False for i in range(len(key_stream)): __l=[type(key_stream[i]),type(F[i]),type(S[i])] if __l.count(int)==2: flag=True __=__l.index(str) if __==0: key_stream[i]=F[i]^S[i] elif __==1: F[i]=key_stream[i]^S[i] elif __==2: S[i]=key_stream[i]^F[i] return flag
def checkALL(): flag=checkFSM() flag=flag or checkFSFSM() flag=flag or checkFSSTREAM() flag=flag or checkS() return flag
def checkCORRECT(): t_S=[3728967755, 3495356165, 472187142, 886943789, 4084678986, 114208514, 4079807976, 4275161248, 3282638664, 2076006597, 3373805671, 2974123815, 3847446102, 2029449241, 1167248190, 3124340476, 2413002776, 3447953474, 4266587847, 4175396429, 4131847277, 1684661431, 2541104664, 2037740470, 2396869767, 4221185578, 3017606363, 2068083020, 2267507878, 3591283476, 2686059627, 1351965579, 545189806, 3529654008, 795261281, 3336159413, 55920688, 3640778187, 10677684, 2992943598, 1690983591, 1929655536, 858855436, 3516290525, 208822826, 1790432759, 1090329888, 3311895372, 2442868764, 525297149, 1581426865, 2535702230, 3690055020, 2897748567, 1087734291, 2968696404, 790180987, 1067508412, 1812069970]
for i in range(len(t_S)): if type(S[i])==int: if S[i]!=t_S[i]: print('S:',i) t_r1=[4288109169, 566438029, 3252420959, 310114661, 405113667, 42168638, 426348252, 2217508059, 2364527128, 2513670487, 4258403922, 1344762431, 3259421801, 2290768410, 3562266277, 3034556817, 2874338847, 2207755823, 3434078908, 3673270886, 3634307680, 887505320, 3272180482, 3182178649, 2463707393, 3945361442, 532203740, 3515575884, 2670224373, 219742259, 3138161244, 1504798987, 3549858809, 1036509647, 2256657537, 4291048480, 3146309710, 1353304775, 3251573430, 278650815, 2240592460, 2202855101, 3645670807, 2183393958, 1051616755, 3920219094, 3655214575, 2766578751, 1372178632, 1819972070, 4032746236, 3996865332, 2470546560, 2521538742, 562444771, 2248808042, 3424030997, 638968787, 1996261738, 2006370108]
t_r2=[1355885794, 3828109594, 472496693, 1076682495, 3872837314, 1840614625, 1816901402, 3255922705, 262821239, 1309786686, 1583923810, 1523195432, 3041126837, 1214947918, 2931262268, 1778538638, 3573090404, 3075404417, 2429921657, 3637677643, 4131381119, 3779984047, 1617841815, 686529006, 3837496372, 3892378064, 2477993090, 2397911448, 2777576939, 1392741422, 1550955835, 2448835842, 3240053317, 3509923480, 4119599101, 375278529, 3937252695, 2608352072, 1358566283, 1627404846, 503044471, 3736592806, 3934907064, 1460859829, 3855897853, 3244167835, 4051089435, 847623116, 3403687926, 2949222116, 1917891093, 624600427, 2001915094, 147539826, 3128478596, 2224489645, 2923913710, 3146498598, 398940241, 1637262462]
t_r3=[3594474665, 780361133, 142866320, 340900620, 1611791033, 1655452060, 2795848422, 797785169, 4276079609, 3931283242, 1267140897, 3903796825, 516286503, 1973930640, 4277622808, 3071699452, 3405201788, 2182536739, 862548827, 1896988818, 3309063171, 1382452360, 645501838, 4006280117, 3496165626, 2544749415, 1833769537, 809879027, 3051926704, 1198409551, 1004958565, 1123356359, 2779335233, 3052290141, 3093081549, 3252733994, 385360256, 359128930, 1849137641, 687792692, 266786993, 3127492305, 1392346274, 1979730466, 479859492, 1187167205, 608981746, 3300250000, 220351399, 4245003, 3407353675, 1092604782, 559427932, 1958415395, 2773555934, 1261361337, 1619553922, 3312946173, 3589284217, 4259352522]
for i in range(len(t_r1)): if type(fsm[i][0])==int and fsm[i][0]!=t_r1[i]: print('R1:',i,0) if type(fsm[i][1])==int and fsm[i][1]!=t_r2[i]: print('R2:',i,1) if type(fsm[i][2])==int and fsm[i][2]!=t_r3[i]: print('R3:',i,2) t_F=[3909102991, 1438316991, 2473993108, 1357262547, 4157851474, 2508185930, 295224457, 3652442850, 164565177, 1788946400, 2802091550, 1590585650, 2294852608, 1205560462, 81068677, 1056699762, 789660110, 324562780, 264734925, 3532320140, 1766276202, 3648418679, 4234489434, 2527364835, 2709941979, 2817733913, 17813838, 2320613312, 3576745017, 1250487923, 2041959784, 190366505, 1507935488, 508966771, 1348294019, 1213765392, 3087084147, 3085163387, 1048389254, 812735484, 730114519, 1825700510, 4066673387, 3107390285, 1220207318, 883241532, 5483853, 275268404, 384384940, 2648392877, 2643780042, 2388170262, 704314697, 1113445259, 3645689675, 4150313002, 1649850319, 77719709, 1803356974] for i in range(len(t_F)): if type(F[i])==int and F[i]!=t_F[i]: print('F:',i)
key_stream=['']*150 gift=b"the quick brown fox jumps over the lazy dog\n" C=[3539094009, 980211684, 2198891016, 905998740, 1595475160, 3962636204, 1199994505, 3190370623, 296595869, 3158272345, 2748985736, 382671580, 2521428409, 248078233, 1528783547, 2729100548, 3426466722, 3192873770, 1337295957, 1431041587, 1607853207, 3998694569, 3160389002, 3728077354, 1120982789, 3443900372, 1811224296, 3102761228, 3296566547, 3724398326, 873334127, 3279785283, 1267844209, 907638672, 2121413959, 3173567371, 4097722407, 844863077, 3114817962, 3619759560, 2198708209, 2363435526, 196774438, 2671749579, 4031688923, 471349633, 778676959, 3608967403, 92491149, 913291948, 3021362116, 1067932129, 999259588, 3190588842, 1828097126, 1450255462, 1305572961, 1341694028, 2350778224, 2932388574, 1204050979, 1294999174, 1921124090, 2342994011, 1941020673, 1191919176, 187588176, 255691701, 274795123, 873091533, 299848364, 870697920, 3387594780, 944072831, 848477078, 447469593, 917439649, 598555627, 3036173079, 3758185777, 4236584984, 4205933999, 1185586113, 3227810954, 2737102694, 3680871868, 4102277292, 378037705]
hack=[834501734,940247165,2078728259,483907438,1102712410,3110955761,3016462560,871310805,1334672645,1102778698]
fsm=[['']*3 for i in range(150)] S=['']*150 F=['']*150
fsm[2][0]=hack[0] fsm[2][1]=hack[1] fsm[2][2]=hack[2] S[2]=hack[3] S[3]=hack[4] S[6]=hack[5] S[7]=hack[6] S[8]=hack[7] fsm[5][0]=hack[8] fsm[7][0]=hack[9]
for i in range(len(gift)): key_stream[i]=C[i]^gift[i]
F[2]=S[2]^key_stream[2] F[3]=S[3]^key_stream[3] F[6]=S[6]^key_stream[6] F[7]=S[7]^key_stream[7] F[8]=S[8]^key_stream[8]
while checkALL(): None
plain=b'' for i in range(len(C)): plain+=long_to_bytes(key_stream[i]^C[i]) print(plain)
|