请问NTLM认证如何做?

一桶姜山 2014-11-26 03:07:08
单位的http代理服务器是用ntlm用域用户认证访问的。

想通过单位的代理下载外网的网页,ntlm前2次握手应该是成功了,取到了代理服务器发送的挑战码,但是不知道怎么组第三次握手的请求报文,请问大家这个挑战码要怎么处理?
网上找了好些文章都看不明白,对挑战码的处理过程都是很简略的描述。
...全文
547 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
huangjiazhi_ 2017-06-28
  • 打赏
  • 举报
回复
!!!!!!!!求分享代码!!!!!!
oyljerry 2014-12-04
  • 打赏
  • 举报
回复
直接对比一下两者接收的数据,同时用抓包工具抓一下对比,看到底多出的是什么数据
一桶姜山 2014-12-04
  • 打赏
  • 举报
回复
刚刚试了下将代理服务器添加的头去掉后长度正好等于Content-Length,结贴
一桶姜山 2014-12-04
  • 打赏
  • 举报
回复
或者我改用短连接来做? 但是短连接是否每次连接都要做ntlm的3次握手?那也挺浪费啊
一桶姜山 2014-12-04
  • 打赏
  • 举报
回复
引用 3 楼 oyljerry 的回复:
[quote=引用 2 楼 paulcxz 的回复:] ntlm认证成功了,再提个问题,当服务器返回的Content-Length长度与实际长度不一致的时候怎么判断是否已经接收完整个报文?只能是recv到超时为止吗?还是说要自己分析html看是否接收完毕?
理论上Content-Length要跟实际长度一样,不然就没法判断接收数据长度了 是不是你处理数据有问题,所以长度对不上 或者好似否为chunk类型[/quote] 我目前的代码做的是客户端,处理逻辑是recv 直到超时,然后将recv的返回值累加统计出总共接收到3904byte的数据。 跟服务器返回的Content-Length内容对比相差了有几百个字节,接收的内容如下: HTTP/1.1 407 Proxy Authentication Required ( Forefront TMG 闇€瑕佹巿鏉冩墠鑳藉畬鎴愯姹傘€傛嫆缁濊闂?Web 浠g悊绛涢€夊櫒銆? ) Via: 1.1 HDQ-PROXY-C2 Proxy-Authenticate: Negotiate Proxy-Authenticate: Kerberos Proxy-Authenticate: NTLM Connection: Keep-Alive Proxy-Connection: Keep-Alive Pragma: no-cache Cache-Control: no-cache Content-Type: text/html Content-Length: 3572 锘?!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>閿欒娑堟伅</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <style> body { background:#e5eaf5 url(/Wbo-2F6F3A0E-CB8D-4B27-8C2A-76513A2AA4E1/bg.gif) top left repeat-x ; margin:0px 0px 0px 0px; font-family:Arial, Helvetica, sans-serif; min-width:1000px; font-size:12px; color:#000000; direction:ltr; } img {border:none} .main { width:100%; background:url(/Wbo-2F6F3A0E-CB8D-4B27-8C2A-76513A2AA4E1/topright.gif) top right no-repeat; min-width:1000px; min-height:400px; margin-left:auto; margin-right:auto; text-align:left; } .logo {float:left; height:103px; } .sidetext {float:right; width:182px; height:52px; background:url(/Wbo-2F6F3A0E-CB8D-4B27-8C2A-76513A2AA4E1/sidetext.png) top left; border:1px solid #2a2e31; margin-right:20px; margin-top:20px; padding:4px; } .sidetextNone {visibility:hidden; } .whiteline {float:left; clear:both; font-size:20px; margin-left:47px; margin-top:17px; color:#ffffff; white-space:nowrap; } .bold {font-weight:bold;} .maintext {float:left; margin-top:20px; clear:both; color:#000; margin-left:47px;} .color1 {color:#677183;} ul {margin-top:0; padding-left:15px; padding-top:5px; padding-bottom:5px;} ul li {list-style-image:url(/Wbo-2F6F3A0E-CB8D-4B27-8C2A-76513A2AA4E1/bullet.gif)} A { FONT-WEIGHT: bold; COLOR: #005a80; } A:hover { FONT-WEIGHT: bold;COLOR: #0d3372; } </style> </head> <body> <div class="main"> <div class="logo"><img src="/Wbo-2F6F3A0E-CB8D-4B27-8C2A-76513A2AA4E1/logo.png" alt="ForeFront" /></div> <div class="whiteline"><td id=L_default_2><span class="bold">缃戠粶璁块棶娑堟伅:</span> 鏃犳硶鏄剧ず璇ラ〉 </td></div> <div class="maintext"> <td id=L_default_3><span class="bold color1">瑙i噴:</span> 灏濊瘯璁块棶鐨勯〉闈㈠嚭鐜伴棶棰橈紝鏃犳硶鏄剧ず璇ラ〉闈€?</td><br /> <br /> <td id=L_default_5><span class="bold color1">璇峰皾璇曚互涓嬫搷浣?</span></td><br /> <ul> <li><td id=L_default_6><span class="bold">鍒锋柊椤甸潰:</span> 鍗曞嚮鈥滃埛鏂扳€濇寜閽潵鍐嶆鎼滅储姝ら〉銆傝秴鏃跺彲鑳芥槸鐢变簬 Internet 鎷ュ閫犳垚鐨勩€?/td></li> <li><td id=L_default_7><span class="bold">妫€鏌ユ嫾鍐?</span> 璇锋鏌ユ偍鏄惁姝g‘閿叆浜嗙綉椤靛湴鍧€銆傞敭鍏ョ殑鍦板潃鍙兘涓嶆纭€?/td></li> <li><td id=L_default_8><span class="bold">閫氳繃閾炬帴璁块棶:</span> 濡傛灉鏈変竴涓摼鎺ユ寚鍚戞偍姝e湪瀵绘壘鐨勯〉闈紝璇峰皾璇曢€氳繃璇ラ摼鎺ユ潵璁块棶姝ら〉闈€?/td></li> </ul> <br /> <td id=L_default_9><span>濡傛灉鎮ㄤ粛鐒舵棤娉曠湅鍒拌姹傜殑椤碉紝璇峰皾璇曚笌绠$悊鍛樻垨鏀寔浜哄憳鑱旂郴銆?/span> </td><br /> <br /> <td id=L_default_10><span class="bold color1">鎶€鏈俊鎭?閽堝鏀寔浜哄憳)</span></td><br /> <ul> <li><td id=L_default_11><span class="bold">閿欒浠g爜:</span></td> 407 Proxy Authentication Required. Forefront TMG 闇€瑕佹巿鏉冩墠鑳藉畬鎴愯姹傘€傛嫆缁濊闂?Web 浠g悊绛涢€夊櫒銆?(12209).</li> <li><td id=L_default_12><span class="bold">IP 鍦板潃:</span></td> 10.200.11.52</li> <li><td id=L_default_13><span class="bold">鏃ユ湡:</span></td> 2014/12/4 5:52:39 [GMT]</li> <li><td id=L_default_14><span class="bold">鏈嶅姟鍣?</span></td> HDQ-PROXY-C2.HDQ.SPDB.com </li> <li><td id=L_default_15><span class="bold">鏉ユ簮:</span></td> 浠g悊 </li> </ul> </div> </div> </body> </html>
oyljerry 2014-12-04
  • 打赏
  • 举报
回复
引用 2 楼 paulcxz 的回复:
ntlm认证成功了,再提个问题,当服务器返回的Content-Length长度与实际长度不一致的时候怎么判断是否已经接收完整个报文?只能是recv到超时为止吗?还是说要自己分析html看是否接收完毕?
理论上Content-Length要跟实际长度一样,不然就没法判断接收数据长度了 是不是你处理数据有问题,所以长度对不上 或者好似否为chunk类型
一桶姜山 2014-12-04
  • 打赏
  • 举报
回复
ntlm认证成功了,再提个问题,当服务器返回的Content-Length长度与实际长度不一致的时候怎么判断是否已经接收完整个报文?只能是recv到超时为止吗?还是说要自己分析html看是否接收完毕?
一桶姜山 2014-12-04
  • 打赏
  • 举报
回复
hey? 来个人接分啊

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧