RSA1
下载附件发现是一个非常简单的RSA加密
e = 65537
N = 1018261336751023520497560395829454421245429586704872293236600679847605951423419167478189648109263
the encrypted flag = 713822463491939628949080236459794906441914407944768290378695739068636927695199214947719158013040
首先对于大整数进行分解,大整数分解
p=9942874965373398689
q=102411157768469768587484356311902427789461430190314198242306101223897141593967
利用RSA的原理对其破解,详细可以查看https://mp.csdn.net/mp_blog/creation/editor/134606261
解密代码
import gmpy2
from Crypto.Util.number import *
p=9942874965373398689
q=102411157768469768587484356311902427789461430190314198242306101223897141593967
n=p*q
dn=(p-1)*(q-1)
e=65537
encflag=713822463491939628949080236459794906441914407944768290378695739068636927695199214947719158013040
d=gmpy2.invert(e,dn)
print(long_to_bytes(pow(encflag,d,n)))
解密结果
shellmates{U_5h0uld_U53_L4rg3_Numb3r5}
unrecovery
题目
import random
from string import ascii_lowercase,digits
from secret import flag
chars = ascii_lowercase + digits
random.seed(2**1337 - 1)#加一个种子
shuffled_chars=[i for i in chars]
random.shuffle(shuffled_chars)#将字符串chars打乱
shuffled_chars = ''.join(shuffled_chars)
#print(f"{chars}\n{''.join(shuffled_chars)}");input()
enc = ''
for i in flag:
if i.isalnum():#如果i为字母和数字返回ture,反之返回false
enc += shuffled_chars[chars.index(i)]
else:
enc+=i
print(enc)
# ctn44vmunc{3ghgsy_uto_coo2_gc_2asyoxg1ec}
就一个简单字符串之间的转换问题,由于种子已经给出了,所以可以直接得出,不多说直接上代码
from string import ascii_lowercase,digits
import random
chars = ascii_lowercase + digits
print(chars)
random.seed(2**1337 - 1)
shuffled_chars=[i for i in chars]
random.shuffle(shuffled_chars)
shuffled_chars = ''.join(shuffled_chars)
print(shuffled_chars)
dec = ''
enc="ctn44vmunc{3ghgsy_uto_coo2_gc_2asyoxg1ec}"
for i in enc:
if i.isalnum():#字母和数字返回ture
dec +=chars[shuffled_chars.index(i)]
else:
dec+=i
print(dec)
#