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
| from Crypto.Util.number import *
def decrypt(key, key_seq): m = [] for i in key: if i in key_seq: m.append('1') else: m.append('0') m = int(''.join(m), 2) print(long_to_bytes(m).hex())
key_stream = [[8779582278268986568, 13972447072333016717], [2835921688996422960, 13399390213922803289], [2972409776130309532, 16559329861009939963], [1033763475380874170, 12718043069307240271], [14518345776863828700, 14518345781028613351], [3594736753648488302, 16556792243215240193], [2920878919724938340, 12736435585789788179], [1428541050429491416, 10358834156010643157], [1268208453518006040, 13276414912962398789], [9113004782712964334, 11102773719072440869], [432329273352093334, 15287074050624177007], [6942433427262517692, 15121233721483378169], [3697581427774504474, 9990181203579400259], [258166246112909708, 16587601807931780257], [6627525136794168270, 12412544559944377193], [6684243938812889796, 9744991320816487597], [1803935490195559424, 16508419663583149481], [4826520667649813430, 10065209613001787539], [4372180482202183080, 17622260286929220133], [8876839085812793576, 11390663903781585557], [5751539233457914060, 16457028586634856139], [1836484817807711118, 18210599645956675471], [7318815736519327028, 17236939324015480183], [6029822704859535140, 18441128104321479757], [618181373323940462, 10556650214702682187], [7281107314188002400, 14507765834006962981], [2440649095282677440, 15852140222260708969], [6009553007025357374, 17841915322455125371], [8108357868642599946, 17851008316317599911], [8837992241624284328, 12081450737853266699], [1695635503484119714, 10973551872446870647], [2661390343339298182, 16511069682831770237], [6538201270686099842, 16548423095865111853], [3557376979829441730, 11246273648570095117], [6979839776983904698, 12224697773647469917], [8523959602484753600, 13964591584802246651], [2082684913461012782, 15929008069799020451], [7839528782052360990, 11191637010989706853], [5545266207423011378, 18197690351643272573], [3453626818702163380, 13770763335134370991], [8063552728968536124, 13303373687545948007], [3387950048990474816, 13701984912510588149], [5558131541688098228, 16114638404839345663], [3542546840365140738, 16686116803788883931], [3630426494960614130, 15526280242707122011], [3319501829037603628, 14421584453923837837], [3346153664282028922, 11434364198579333993], [6068659120328552598, 11580704128296125107], [6527437612922589722, 18023670557697626281], [6391429115601860172, 13224541131631377211], [3930164041727827390, 10458290927061214901], [2661353548507038800, 15472496154249710809], [3967370278962719008, 12420435944394721093], [4858804803266586782, 11888676089983790917], [4181640118414759568, 12462430910276960563], [8301778622336617048, 10879387637052495779], [656963133086067490, 12790525991712394309], [7804492847900751508, 10445583672503001371], [6050292517786733624, 14739877198024482919], [6819907064055335354, 17462249837089654921], [4673283453097206176, 11491045269336812639], [43420844401216724, 18163419661266446761], [2801893311188048476, 12487529381913793231], [6079439990157701706, 12372107513836504583]] c = 248989084975279954530446836187742260957464300571462773588456663949016643230510464543511459928583572807089450199912563182507696384583461748946818877790890833787976928042941582962480484928204346903330773117645824916689806456224546576491363960352805243729130006879143274931033742096269219412413483369744418405994456845747843492443615095091040028459038822533077065396480961075744563084128188136369847545720850903783595992035389582552870395168288052488886873290247545662095337543626052711637168589058325880633931884880718419421190578986090522834555126398496232907268338531658654840865853876273393196175836323813262165790569865768435667663526298122251221172688546949592040884434661997750300546641 ps = [15526280242707122011, 16587601807931780257, 12420435944394721093, 16457028586634856139, 11102773719072440869, 13224541131631377211, 12372107513836504583, 9744991320816487597, 18197690351643272573, 10065209613001787539, 15287074050624177007, 12081450737853266699, 11491045269336812639, 17622260286929220133, 16556792243215240193, 16548423095865111853, 12487529381913793231, 12224697773647469917, 13303373687545948007, 11191637010989706853, 16114638404839345663, 17851008316317599911, 15929008069799020451, 12736435585789788179, 10358834156010643157, 12412544559944377193, 18163419661266446761, 10973551872446870647, 12790525991712394309, 16686116803788883931, 15121233721483378169, 14739877198024482919, 17462249837089654921, 16508419663583149481, 18441128104321479757, 16559329861009939963]
true_key = [] for i in range(len(key_stream)): if (key_stream[i][0] ^ key_stream[i][1]).bit_length() < 50: iv = key_stream[i][0] ^ key_stream[i][1] true_key.append(key_stream[i][1]) key_stream.pop(i) break
for i in range(63): j = 0 while 1: if key_stream[j][0] ^ key_stream[j][1] == true_key[i]: true_key.append(key_stream[j][1]) key_stream.pop(j) break j += 1
decrypt(true_key[::-1], ps)
|