s = b'\x39\x3b\x31\x0f\x3e\x30\x27\x13\x01\x7d\x70\x70\x03\x7d\x38\x0e\x7a\x23\x7c\x0b\x1a\x3c\x7d\x39\x7f\x3c\x4d\x4d\x4d\x29' decoded_s = s.decode('utf-8') ord_list = [ord(c) for c in decoded_s] after = '' for c in ord_list: this_one = chr((c^0x51)+5) after += this_one print(after) # moectf{GU1&&W1nd0w2_Pr1m3r!!!}
v4 = sub_1400019C0(std::cout, "I'm a first timer of Logic algebra , how about you?", envp); std::ostream::operator<<(v4, sub_140001B90); //就是 //cout << "I'm a first timer of Logic algebra , how about you?"<<endl; sub_1400019C0(std::cout, "Let's start our game,Please input your flag:", v5); sub_140001DE0(std::cin, Block); //就是 //cout "Let's start our game,Please input your flag:"<<endl; // cin << Block;
# 已知的 DES 加密结果 encrypted_text = bytes.fromhex('0723105D5C12217DCDC3601F5ECB54DA9CCEC2279F1684A13A0D716D17217F4C9EA85FF1A42795731CA3C55D3A4D7BEA')
# 尝试所有可能的 6 位数字组合 for i in itertools.product(range(10), repeat=6): key = ''.join(map(str, i)) # print(key) keyt = base64.b64encode(key.encode()).decode() # MTIzMTIzMTIz base64encode(v) 正常的123123进行base64以后的值 keytt = keyt.translate(dictionary_encode) key = keytt.encode() # print(key) # 创建 DES 对象 des = DES.new(key, DES.MODE_ECB) # 尝试解密 try: decrypted_text = des.decrypt(encrypted_text) if (b"DASCTF"in decrypted_text): print('找到了!密钥是:', key) print('明文是:', decrypted_text) break except: pass# 如果解密失败,就尝试下一个密钥
CRYPTO
先从简单的练起吧。
bigRSA
1 2 3 4 5 6 7 8
n1 = 103835296409081751860770535514746586815395898427260334325680313648369132661057840680823295512236948953370895568419721331170834557812541468309298819497267746892814583806423027167382825479157951365823085639078738847647634406841331307035593810712914545347201619004253602692127370265833092082543067153606828049061 n2 = 115383198584677147487556014336448310721853841168758012445634182814180314480501828927160071015197089456042472185850893847370481817325868824076245290735749717384769661698895000176441497242371873981353689607711146852891551491168528799814311992471449640014501858763495472267168224015665906627382490565507927272073 e = 65537 m = bytes_to_long(flag) c = pow(m, e, n1) c = pow(c, e, n2)
withopen("flag.txt","r") as fs: flag = fs.read().strip()
m = bytes_to_long(flag.encode()) c = pow(m,e,p*q) print(c) # 63388263723813143290256836284084914544524440253054612802424934400854921660916379284754467427040180660945667733359330988361620691457570947823206385692232584893511398038141442606303536260023122774682805630913037113541880875125504376791939861734613177272270414287306054553288162010873808058776206524782351475805
已知p,q,e,c,直接解
6,解不出来,说是e是phi的因子,不能得出m,那就分解一下phi
发现p-1是e的倍数,但是q-1不是,根据同余的消去律可消去两边的最大公因数
相当于mod((q-1)),就出来了
baby_e
1 2 3 4 5 6 7 8 9 10 11 12
from Crypto.Util.number import getPrime,bytes_to_long
p,q = getPrime(2048),getPrime(2048) e = 7 n = p*q m = bytes_to_long(open('flag.txt','rb').read().strip()) c = pow(m,e,n) print("c = ",c) print("n = ",n)
# c = 147693154873835354725007152781732424355869776162377337823960431913672366269917723916891506269449726723757821517328874729037838600793748824028829185409932536014732765063216715033843955453706710187792772702199448156372644163429786386035008302836467605094954587157232829525150652611067567669525072625329634860065850520051628272535479197120008981979404760445193750864902244921407742155742716289495581989134730376783828846663464819337418977287363028738701414486788851136608957124505485242331701209645216580641917007780811842757125048746184068597664780265422321550909392419865169775282217442331295071069272774722564587602419768461231775480847018941840911357926330143045826277813722919121117172763493242590521245640828462665947672485094793188432098216701511715232654611338293295459889814699850788048985878279440740712956248569068077253790198036918598519191892836075254345518967666166925163908185663991353344555402397055977817370082929420443034626201745027965444069777059760865359310439815816749939498993014457995041394803598825093836045546578310632172636478575946653375857640993393714607308326474003446154152048840071034349831168612740218034679021240949747357214453636633636662650940968576792518622437627529244515229173 # n = 553409369582823237678532685244026647155180191225879439432235077135813123637186465008813830373646133388592395760175777499266561095087891764348044063111935877931069321764391883899483374576303169645488542398590564148654412004383012178107972880058460460806768779452529433458826925606225797078653905380530651390617109384086518728626571028089036812787671647095695947167204428442727185744172445701874820612799168887428075695751162763647868386879374037826876671079326544820609721731078985096813307183878793033824330869698508952853770794414757655681370862323768018291030331209143189638496644361618184164228294031490537429556439588954274708598530042700988138862000054458742762198052079867259365645914383561162796796952346445529346145323567650621600171442575319262718389389870407629339714751583360252884338116164466349449862781112019462555743429653595045695696967783338371470032332852204294900011651434678829104876529439166176589508898757122660322523937330848536715937381297551894198974459004139082562228022412335520195652419375915216074658463954339332593244483927157329404652516225481116614815221154229491846087288087715884363786672244655901308480290011237244562251084095684531716327141154558809471185132979704992609461470501119328696999713829
e很小
$c = m^e + kn$
$m = (c - kn)**(1/7)$
尝试低加密指数攻击
1 2 3 4 5 6 7 8 9 10
from gmpy2 import iroot import libnum k = 0 while1: res = iroot(c+k*n,e) if(res[1] == True): print(libnum.n2s(int(res[0]))) #转为字符串 break k=k+1 # b'moectf{SMaLL_3xPon3nt_Mak3_rSa_w3ak!_!lP0iYlJf!M3rux9G9Vf!JoxiMl903lllA}'
import os from flag import flag from Crypto.Util.number import * from Crypto.Cipher import AES flag = b'19209389120572313' m = 88007513702424243702066490849596817304827839547007641526433597788800212065249 key = os.urandom(24) key = bytes_to_long(key) n=m % key flag += (16 - len(flag) % 16) * b'\x00' iv = os.urandom(16) aes = AES.new(key,AES.MODE_CBC,iv) enc_flag = aes.encrypt(flag)