d = "L3t_ME_T3ll_Y0u_S0m3th1ng_1mp0rtant_A_{FL4G}_W0nt_b3_3X4ctly_th4t_345y_t0_c4ptur3_H0wev3r_1T_w1ll_b3_C00l_1F_Y0u_g0t_1t." dd = [36,0,5,54,101,7,39,38,45,1,3,0,13,86,1,3,101,3,45,22,2,21,3,101,0,41,68,68,1,68,43] answer = [] for i in dd: answer.append(d[i]) answer = "".join(answer) print answer
import md5 md5s = [ 0x831DAA3C843BA8B087C895F0ED305CE7L, 0x6722F7A07246C6AF20662B855846C2C8L, 0x5F04850FEC81A27AB5FC98BEFA4EB40CL, 0xECF8DCAC7503E63A6A3667C5FB94F610L, 0xC0FD15AE2C3931BC1E140523AE934722L, 0x569F606FD6DA5D612F10CFB95C0BDE6DL, 0x68CB5A1CF54C078BF0E7E89584C1A4EL, 0xC11E2CD82D1F9FBD7E4D6EE9581FF3BDL, 0x1DF4C637D625313720F45706A48FF20FL, 0x3122EF3A001AAECDB8DD9D843C029E06L, 0xADB778A0F729293E7E0B19B96A4C5A61L, 0x938C747C6A051B3E163EB802A325148EL, 0x38543C5E820DD9403B57BEFF6020596DL] print'Can you turn me back to python ? ...' flag = raw_input('well as you wish.. what is the flag: ') iflen(flag) > 69: print'nice try' exit() iflen(flag) % 5 != 0: print'nice try' exit() for i inrange(0, len(flag), 5): s = flag[i:i + 5] ifint('0x' + md5.new(s).hexdigest(), 16) != md5s[i / 5]: print'nice try' exit() continue print'Congratz now you have the flag'
import base64 f = open("zero_one","r").read() bi = [] for i in f.split(" "): if i == "ZERO": bi.append("0") else: bi.append("1") bi = "".join(bi) answer = [] for i inrange(len(bi)/8): answer.append(chr(int(bi[i*8:i*8+8],2))) answer = "".join(answer) answer = base64.b64decode(answer) print answer
由于ascii中大写字母0x40开头小写0x60开头,空格为0x20,所以如果两段文字中空格与小写字母异或会出现大写字母,然后得到key。 手工有点麻烦,正好有一个python写的工具FeatherDuster强的很,密文输入之后选择many times pad攻击,过一会得到了解密后的明文。发现明文里没有flag,想到密钥是flag。
We got this PRNG as the most secure random number generator for cryptography. Can you prove otherwise nc 195.154.53.62 7412
正经解法
看起来是找PRNG的漏洞,第一次见。 可以读数也可以猜数,猜对十个给flag。 生成伪随机数最著名的算法LCG,线性同余法。它是根据递归公式:$ x_{n+1} = ax_n +k \mod m$ ,所以第n+1个随机数是由第n个随机数和a,k,m决定的。首先求出m。 设$ t_n = x_{n+1} - x_n $,$ u_n = |t_{n+2}t_n - t_{n+1}^2| $ 。 $ m = gcd(u_1,u_2,…,u_k) $ ,m错误的概率随着k值的增大呈指数下降。 接下来求a和k,$ a = (x_{n+2}-x_{n+1})(x_{n+1}-x_n)^{-1} \mod m $,$ b = x_{n+1} - ax_n \mod m $。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
import gmpy2 x = [100909846,1875979913,545570872,2302513355,239025856,2061072608,633003322,3970909550,3762214126,242181143,3088920217] t = [] u = []
for i inrange(1,len(x)): t.append(x[i]-x[i-1]) for i inrange(2,len(t)): u.append(abs(t[i]*t[i-2]-t[i-1]*t[i-1])) # u = map(int,u) m = (reduce(gmpy2.gcd,u)) print"m="+hex(m) a = (x[2]-x[1])*gmpy2.invert(x[1]-x[0],m) %m print"a="+hex(a) k = (x[1] - a*x[0]) % m print"k="+hex(k)
DECIMAL HEXADECIMAL DESCRIPTION -------------------------------------------------------------------------------- 254 0xFE gzip compressed data, from Unix, last modified: Sun Jan 1 04:20:49 2017
root@leo-kali:~/ctf# binwalk -e fore4
DECIMAL HEXADECIMAL DESCRIPTION -------------------------------------------------------------------------------- 254 0xFE gzip compressed data, from Unix, last modified: Sun Jan 1 04:20:49 2017
root@leo-kali:~/ctf# cd _fore4.extracted/ root@leo-kali:~/ctf/_fore4.extracted# ls FE.gz root@leo-kali:~/ctf/_fore4.extracted# tar -vxzf FE.gz kindle_out/ kindle_out/rootfs_md5_list.tar.gz kindle_out/2540270001-2692310002.ffs kindle_out/flag.txt kindle_out/update-patches.tar.gz
gzip: stdin: unexpected end of file tar: Unexpected EOF in archive tar: Unexpected EOF in archive tar: Error is not recoverable: exiting now root@leo-kali:~/ctf/_fore4.extracted# cd kindle_out/ root@leo-kali:~/ctf/_fore4.extracted/kindle_out# cat flag.txt ALEXCTF{Wh0_N33d5_K1nDl3_t0_3X7R4Ct_K1ND13_F1rMw4R3}
from pwn import * r = remote("195.154.53.62",1337) for i inrange(500): print r.recvuntil(":") a = r.recvuntil("=") print a print r.recv() r.sendline(str(eval(a[:-2]))) print r.recv()
ALEXCTF{1_4M_l33t_b0t}
SC2: Cutie cat
题目描述
yeah steganography challenges are the worst… that’s why we got only ~~one ~~ two steganography challenges . Hint: It scripting because we need a python library to solve the challenge, one that is made in japan.