from Crypto.Cipher import DES3 import base64,itertools,string,hashlib defdes3_cbc_decrypt(secret_key,secret_value,iv): unpad=lambda s:s[0:-ord(s[-1])] res=DES3.new(secret_key.encode("utf-8"),DES3.MODE_CBC,iv) base64_decrypted=base64.b64decode(secret_value.encode("utf-8")) encrypt_text=res.decrypt(base64_decrypted) result=unpad(encrypt_text.decode()) return result defsha256crash(sha256enc): code='' strlist=itertools.product(string.ascii_letters+string.digits,repeat=4) for i in strlist: code=i[0]+i[1]+i[2]+i[3] encinfo=hashlib.sha256(code.encode()).hexdigest() if encinfo==sha256enc: return code defsha512crash(sha512enc): code='' strlist=itertools.product(string.ascii_letters+string.digits,repeat=4) for i in strlist: code=i[0]+i[1]+i[2]+i[3] encinfo=hashlib.sha512(code.encode()).hexdigest() if encinfo==sha512enc: return code defmd5crash(md5enc): code='' strlist=itertools.product(string.ascii_letters+string.digits,repeat=4) for i in strlist: code=i[0]+i[1]+i[2]+i[3] encinfo=hashlib.md5(code.encode()).hexdigest() if encinfo==md5enc: return code key="WelcomeToTheGKCTF2021XXX" iv=b'1Ssecret's cipher="o/aWPjNNxMPZDnJlNp0zK5+NLPC4Tv6kqdJqjkL0XkA=" part1=des3_cbc_decrypt(key,cipher,iv) part2=sha256crash("6e2b55c78937d63490b4b26ab3ac3cb54df4c5ca7d60012c13d2d1234a732b74") part3=sha512crash("6500fe72abcab63d87f213d2218b0ee086a1828188439ca485a1a40968fd272865d5ca4d5ef5a651270a52ff952d955c9b757caae1ecce804582ae78f87fa3c9") part4=md5crash("ff6e2fd78aca4736037258f0ede4ecf0") flag="GKCTF{"+part1+part2+part3+part4+"}" print(flag)
[FSCTF 2023]rrrrust!!!
Rust逆向连蒙带猜。
0x55DB3F0666DF处发现有xor,可能是异或加密,多次动调发现密钥为循环字符串。
找到loc_55DB3F066569处有密文比较过程,dump出来写exp:
1 2 3 4
enc=[0x3E,0x2A,0x27,0x33,0x15,0x03,0x3D,0x77,0x25,0x64,0x03,0x67,0x07,0x32,0x76,0x0B,0x1C,0x21,0x2B,0x32,0x19,0x23,0x5E,0x26,0x69,0x22,0x3B,0xD8,0x9F,0x0B,0x3F,0xDB,0x55] key="XFFTnT" for i inrange(len(enc)): print(chr(enc[i]^ord(key[i%6])),end='')
res=[83,15,90,84,80,85,3,2,0,7,86,7,7,91,9,0,80,5,2,3,93,92,80,81,82,84,90,95,2,87,7,52,0] for i inrange(31,-1,-1): res[i]^=res[i+1] for i inrange(len(res)): print(chr(res[i]),end='')