如何在c/c++/命令行中访问需要http验证的url?
http://admin:[email protected]/videostream.cgi
要访问不需要 http 身份验证的 url,非常简单:
telnet 192.168.1.178 80
Get /videostream.cgi HTTP/1.1
Accept: text/html;text/plain
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.13) Gecko/20100914 Firefox/3.5.13
Connection: close
但是如何指定 admin:123456
呢?
http://admin:[email protected]/videostream.cgi
To access a url that doesn't require http authenticate it's quite easy:
telnet 192.168.1.178 80
Get /videostream.cgi HTTP/1.1
Accept: text/html;text/plain
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.13) Gecko/20100914 Firefox/3.5.13
Connection: close
But how to specify admin:123456
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅 RFC 或 这篇维基百科文章。
使用 Wireshark 或其他 LAN 嗅探器来观察浏览器和服务器在您执行操作时执行的操作可能具有教育意义。访问带有嵌入凭据的 URL,例如您的 http://admin:[电子邮件受保护]/videostream.cgi
See the RFC or This Wikipedia article.
It can be educational to use Wireshark, or some other LAN sniffer, to watch what a browser and server do when you access a URL with embedded credentials such as your http://admin:[email protected]/videostream.cgi
对于基本身份验证,您将用户名和密码指定为
用户名:密码
,然后对其进行 Base64 编码并将其用作Authentication
标头的参数:YXNkZjoxMjM0
解码为asdf:1234
;我使用curl -u adsf:1234
(指定用户名“asdf”和密码“1234”)来产生此结果。For basic authentication, you specify the username and password as
username:password
, then Base64-encode it and use it as an argument to theAuthentication
header:YXNkZjoxMjM0
decodes toasdf:1234
; I usedcurl -u adsf:1234
(specifying the username "asdf" and password "1234") to produce this result.