題目信息
相關知識
-G:表示GET請求,缺省POST
-d參數用于發送 POST 請求的數據體
使用-d參數以后,HTTP 請求會自動加上標頭Content-Type : application/x-www-form-urlencoded。并且會自動將請求轉為 POST 方法,因此可以省略-X POST。
linux下使用GET url傳參時注意轉義:
curl "http://127.0.0.1/api/test\?name\=cat"
1、通過post方法請求
curl -d 'type=0?enable=1' "http://127.0.0.1/api/test"
- 傳遞json:
curl -H "Content-Type: application/json" -X POST -d '{"type":0, "enable":"1"}' "http://127.0.0.1/api/test"
實際使用哪種,看接口需要的是json還是字符串
- 通過GET方法請求(wireshark抓包確認是GET請求):
curl "http://127.0.0.1/api/test"
GET請求方法傳參(wireshark抓包確認是GET請求):
curl "http://127.0.0.1/api/test?name=cat"
分析過程
對如Get問題中由于get請求可以在url中進行添加,所以只需要把url進行修改即可:
http://61.147.171.105:54730/?a=1
解題過程
http://61.147.171.105:54730/?a=1
此處需要以post方式傳入b的值,在終端輸入:
curl -X POST -d 'b=2' 'http://61.147.171.105:54730/?a=1'
結果為:
即可獲得相應的flag