开发者

How to access url that requires http authenticate in c/c++/command line?

http://admin:123456@192.168.1.178/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
Acc开发者_运维技巧ept: 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?


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:123456@192.168.1.178/videostream.cgi


For basic authentication, you specify the username and password as username:password, then Base64-encode it and use it as an argument to the Authentication header:

Authorization: Basic YXNkZjoxMjM0

YXNkZjoxMjM0 decodes to asdf:1234; I used curl -u adsf:1234 (specifying the username "asdf" and password "1234") to produce this result.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜