【发布时间】:2021-12-04 07:40:25
【问题描述】:
这个想法是 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 变量的最后一行。谁能解释为什么?
提前谢谢!!!
【问题讨论】:
-
这与 Vim 无关。
标签: bash curl scripting quotes double-quotes