| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2883 人关注过本帖
标题:MFC做一个登陆的程序,但是总是出错误。。请大家看看。。
取消只看楼主 加入收藏
wudkj
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-1-27
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:0 
MFC做一个登陆的程序,但是总是出错误。。请大家看看。。
代码:
    try
 {
#define MAX_COUNT 1024
  CInternetSession session(_T("session"));
  INTERNET_PORT nPort = 80;
  CHttpConnection* pHttpConnect = session.GetHttpConnection(_T("10.10.10.10"), nPort);
  if(pHttpConnect)
  {
   CHttpFile* pFile = pHttpConnect->OpenRequest(CHttpConnection::HTTP_VERB_POST, "CC%E1%BD%BB=%B5%C7+%C2%BC");
   if(pFile)
   {
    // 这里是请求头信息,由抓包工具得到该信息
    pFile->AddRequestHeaders(_T("POST /portalAuthAction.do;jsessionid=3DCAE00AC6BA0D412BB1D95DBE713755 HTTP/1.1"));
    pFile->AddRequestHeaders(_T("Accept: text/html, application/xhtml+xml, */*"));
    pFile->AddRequestHeaders(_T("Referer: http://10.10.10.10:8080/portalReceiveAction.do?wlanuserip=172.31.36.225&wlanacname=amnon"));
    pFile->AddRequestHeaders(_T("Accept-Language: zh-CN"));
    pFile->AddRequestHeaders(_T("User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"));
    pFile->AddRequestHeaders(_T("Content-Type: application/x-www-form-urlencoded"));
    pFile->AddRequestHeaders(_T("Accept-Encoding: gzip, deflate"));
    pFile->AddRequestHeaders(_T("Host: 10.10.10.10:8080"));
    pFile->AddRequestHeaders(_T("Content-Length: 341"));
    pFile->AddRequestHeaders(_T("DNT: 1"));
    pFile->AddRequestHeaders(_T("Connection: Keep-Alive"));
    pFile->AddRequestHeaders(_T("Cache-Control: no-cache"));   
// 这里是要提交的数据。说明一下: xxxx@xx.xxx指的是登陆的邮箱的地址,后面的XXXXXXX表示的是登陆的密码,使用的时候换成你自己的即可
    TCHAR szRequest[MAX_COUNT] = _T("org.apache.struts.taglib.html.TOKEN=45f71bca99acb30bf6aaac05c2fc5cae&wlanuserip=172.31.36.225&wlana
        cname=amnon&chal_id=&chal_vector=&auth_type=PAP&seq_id=&req_id=&wlanacIp=192.168.254.252&ssid=&mac=&message=&bank_acct=&isC
        ookies=&userid=100330519&passwd=8888&提交=登 录");
    pFile->SendRequest(NULL, 0, szRequest, _tcslen(szRequest)+1);
   
    CString strStatus(_T(""));
    if(pFile->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF, strStatus))
    {
     AfxMessageBox(strStatus);
    }
    pFile->Close();
    delete pFile;
    pFile = NULL;
   }
  }
  pHttpConnect->Close();
  delete pHttpConnect;
  pHttpConnect =NULL;  session.Close();
 }
 catch (CInternetException* e)
 {
  e->ReportError();
  e->Delete();
 }


数据包以及分析,可能分析有误。
测试了两个账号登陆:
账号1    下列内容全部指向url:http://10.10.10.10:8080/portalAuthAction.do;jsessionid=3DCAE00AC6BA0D412BB1D95DBE713755
账号2    下列内容全部指向url:http://10.10.10.10:8080/portalAuthAction.do;jsessionid=71667340613805596BDB9C8AA034CA42

注:
===========================================================================================================================
账号密码被替换为******

数据通过ie10获得

经测试,禁用cookie后可以登录网页。

===========================================================================================================================




请求标头1
===========================================================================================================================
请求    POST /portalAuthAction.do;jsessionid=3DCAE00AC6BA0D412BB1D95DBE713755 HTTP/1.1
Accept    text/html, application/xhtml+xml, */*
Referer    http://10.10.10.10:8080/portalReceiveAction.do?wlanuserip=172.31.36.225&wlanacname=amnon
Accept-Language    zh-CN
User-Agent    Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
Content-Type    application/x-www-form-urlencoded
Accept-Encoding    gzip, deflate
Host    10.10.10.10:8080
Content-Length    341
DNT    1
Connection    Keep-Alive
Cache-Control    no-cache
Cookie    JSESSIONID=3DCAE00AC6BA0D412BB1D95DBE713755
===========================================================================================================================
请求标头2
===========================================================================================================================
请求    POST /portalAuthAction.do;jsessionid=71667340613805596BDB9C8AA034CA42 HTTP/1.1
Accept    text/html, application/xhtml+xml, */*
Referer    http://10.10.10.10:8080/portalReceiveAction.do?wlanuserip=172.31.36.225&wlanacname=amnon
Accept-Language    zh-CN
User-Agent    Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
Content-Type    application/x-www-form-urlencoded
Accept-Encoding    gzip, deflate
Host    10.10.10.10:8080
Content-Length    341
DNT    1
Connection    Keep-Alive
Cache-Control    no-cache
Cookie    JSESSIONID=71667340613805596BDB9C8AA034CA42
===========================================================================================================================

请求正文1
===========================================================================================================================
org.apache.struts.taglib.html.TOKEN=5e49ebffbbf985896592fb5ec1e7c061&wlanuserip=172.31.36.225&wlanacname=amnon&chal_id=&chal_vector=&auth_type=PAP&seq_id=&req_id=&wlanacIp=192.168.254.252&ssid=&mac=&message=&bank_acct=&isCookies=&listpasscode=0&randstr=1682&domain=&isRadiusProxy=false&userid=******&passwd=******&%CC%E1%BD%BB=%B5%C7+%C2%BC
===========================================================================================================================
请求正文2
===========================================================================================================================
org.apache.struts.taglib.html.TOKEN=ca06fd7a3eb54f27e058a5f21a7bf64c&wlanuserip=172.31.36.225&wlanacname=amnon&chal_id=&chal_vector=&auth_type=PAP&seq_id=&req_id=&wlanacIp=192.168.254.252&ssid=&mac=&message=&bank_acct=&isCookies=&listpasscode=0&randstr=5701&domain=&isRadiusProxy=false&userid=******&passwd=******&%CC%E1%BD%BB=%B5%C7+%C2%BC
===========================================================================================================================



===========================================================================================================================
对于"请求正文"中的开始数据org.apache.struts.taglib.html.TOKEN=ca06fd7a3eb54f27e058a5f21a7bf64c经过多次登录分析,发现是通过登录org.apache.struts.taglib.html.TOKEN     在返回的post数据包中包含有该数值,下次再含有账号密码的登陆时,内部数据就是访问org.apache.struts.taglib.html.TOKEN所返回的。



访问org.apache.struts.taglib.html.TOKEN的请求标头如下:

========================================访问org.apache.struts.taglib.html.TOKEN   标头   开始
   
请求    GET /portalReceiveAction.do?wlanuserip=172.31.36.225&wlanacname=amnon HTTP/1.1
Accept    text/html, application/xhtml+xml, */*
Referer    http://www.baidu.com/s?wd=org.apache.struts.taglib.html.TOKEN&tn=98012088_4_dg&ch=2&ie=utf-8
Accept-Language    zh-CN
User-Agent    Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
Accept-Encoding    gzip, deflate
Host    10.10.10.10:8080
DNT    1
Connection    Keep-Alive
Cookie    JSESSIONID=C7AEE5198532B5A10C91191043EBC949

========================================访问org.apache.struts.taglib.html.TOKEN   标头   结束


访问org.apache.struts.taglib.html.TOKEN的正文为空


访问org.apache.struts.taglib.html.TOKEN的响应标头为:

========================================访问org.apache.struts.taglib.html.TOKEN   响应   开始
   
响应    HTTP/1.1 200 OK
Server    Apache-Coyote/1.1
Pragma    No-cache
Cache-Control    no-cache
Expires    Thu, 01 Jan 1970 00:00:00 GMT
Content-Type    text/html;charset=GBK
Content-Length    5545
Date    Mon, 27 May 2013 15:40:14 GMT
========================================访问org.apache.struts.taglib.html.TOKEN    响应   结束




访问org.apache.struts.taglib.html.TOKEN返回的响应正文如下:

=================================访问org.apache.struts.taglib.html.TOKEN返回的响应正文  开始

<HTML>
<HEAD>
<TITLE>WIFI认证</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<link rel="stylesheet" href="/portal/images/css.css" type="text/css" media="screen" />
<link REL='STYLESHEET' TYPE='text/css' HREF='/master/include/cbms.css'>
<script language="JavaScript" src="/portal/portal.js"></script>
<script type='text/javascript' src='/dwr/interface/radiusServerService.js'></script>
<script language="JavaScript" src="/dwr/engine.js"></script>
<script language="JavaScript" src="/dwr/util.js"></script>
<script language="JavaScript">
function onbodyload(){
    var a = whatBrowser();
    document.portalForm.userid.focus();
   
        document.portalForm.userid.focus();   
   
}
</script>
</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0  onLoad="javascript:onbodyload();" >
<form name="portalForm" method="POST" action="/portalAuthAction.do" onsubmit="return setMD5Passwd(this)"><div><input type="hidden" name="org.apache.struts.taglib.html.TOKEN" value="1dd66beab9422c5ef748ac6bc75d715e"></div>
            <input type="hidden" name="wlanuserip" value='172.31.36.225' >
            <input type="hidden" name="wlanacname" value='amnon' >
            <input type="hidden" name="chal_id" value='' >
            <input type="hidden" name="chal_vector" value='' >
            <input type="hidden" name="auth_type" value='PAP' >
            <input type="hidden" name="seq_id" value='' >
            <input type="hidden" name="req_id" value='' >
            <input type="hidden" name="wlanacIp" value='192.168.254.252' >
            <input type="hidden" name="ssid" value='' >
            <input type="hidden" name="mac" value='' >
            <input type="hidden" name="message" value='' >
            <input type="hidden" name="bank_acct" id="bank_acct"><INPUT TYPE="hidden" name="isCookies">
            <input type="hidden" name="listpasscode" id="listpasscode" value='0' >
            <input type="hidden" name="randstr" id="randstr" value='5936' >
            <input type="hidden" name="domain" id="domain" value='' >
            <input type="hidden" name="isRadiusProxy" id="isRadiusProxy" value='false' >
<TABLE WIDTH=999 BORDER=0 CELLPADDING=0 CELLSPACING=0 align="center" background="/portal/images/2013032612483487820130107194452409ooo.jpg">
  <!--DWLayoutTable-->
    <TR>
        <TD ROWSPAN=4 WIDTH=71>&nbsp;<!--左边空白部分--></TD>
        <TD COLSPAN=2 ROWSPAN=2 HEIGHT=108 width="555" valign="top">&nbsp;<img src="/portal/images/2013032612483487520130107194452398topt.jpg"/></TD>
        <TD WIDTH=377 HEIGHT=50>&nbsp;</TD>
    </TR>
    <TR>
        <TD  WIDTH=375 HEIGHT=58>&nbsp;</TD>
    </TR>
    <TR>
        <TD  WIDTH=272 HEIGHT=341 valign="top" ><table width="272" border="0" cellpadding="0" cellspacing="0" background="/portal/images/loginbg.png" style="background-position:center; background-repeat:no-repeat">
          <!--DWLayoutTable-->
          <tr>
            <td height="61" colspan="3">&nbsp;</td>
          </tr>
          <tr>
            <td width="16" height="262">&nbsp;</td>
            <td width="238" valign="top" align="left"><!--认证部分-->&nbsp;
            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
            <logic:notEmpty name="form" property="auth_type">
            
               
            </logic:notEmpty>
            <tr>
               <td height="25" align="right" width="30%">账号&nbsp;&nbsp;</td ><td align="left" width="70%"><input type="text" name="userid" id="userid" class="editbox" value=""   onkeyup="javascript:if(event.keyCode!=37 && event.keyCode!=39){ value=value.replace(/[^0-9a-zA-Z@_:.,-]/g,'');}"/></td>
            </tr>
            <tr height="25" align="right">
               <td>密码&nbsp;&nbsp;</td ><td align="left"><input type="password" name="passwd" id="passwd" class="editbox" value="" /></td>
            </tr>
            

            

            

            <tr>
               <td height="25" align="center" colspan="2"><INPUT TYPE="checkbox" NAME="isRemind" id="isRemind"  align="absmiddle"   ><label for="isRemind">记住密码</label></td>
            </tr>

             <tr height="40">
              <td align="center" colspan="2">&nbsp;<input name="提交" type="submit" value="登 录" class="st_submit" />&nbsp;</td>
            </tr>
            <tr>
              <td align="left" valign="middle" colspan="2"><p><span style="font-size: medium;">1、请及时修改密码,地址:<a href="http://10.10.10.5">http://10.10.10.5</a></span></p></td>
            </tr>

            </table>
            
            </td>
            <td width="18">&nbsp;</td>
          </tr>
          <tr>
            <td height="18" colspan="3">&nbsp;</td>
          </tr>
         
        </table>        </TD>
        <TD COLSPAN=2 WIDTH=658 align="left">&nbsp;<p>&nbsp;</p>
<p><span style="font-size: medium;">温馨提示</span></p>
<p>&nbsp;</p>
<p><span style="font-size: medium;">1、下线地址:<a href="http://1.1.1.1/">http://1.1.1.1</a></span></p>
<p>&nbsp;</p>
<p><span style="font-size: medium;">2、常见问题及使用注意事项参考校园论坛:<a href="http://bbs.ncbuct.
<p>&nbsp;</p>
<p><span style="font-size: medium;">3、内网资源:pt.ncbuct.(下载请使用专用工具)</span></p>
<p><span style="color: #ff0000; font-size: medium;">4、多人上网可使用交换机;严禁使用路由器,由此造成的一切后果由用户自行承担。</span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p></TD>
    </TR>
    <TR>
        <TD COLSPAN=3 HEIGHT=153 valign="bottom" align="center">&nbsp;</TD>
    </TR>
    <TR>
        <TD WIDTH=71 HEIGHT=1 >&nbsp;</TD>
        <TD WIDTH=272 HEIGHT=1>&nbsp;</TD>
        <TD WIDTH=281 HEIGHT=1>&nbsp;</TD>
        <TD WIDTH=377 HEIGHT=1>&nbsp;</TD>
    </TR>
</TABLE>
</form>
<!-- End ImageReady Slices -->
</BODY>
</HTML>

=================================访问org.apache.struts.taglib.html.TOKEN返回的响应正文  结束

===========================================================================================================================


响应标头1
===========================================================================================================================
   
响应    HTTP/1.1 200 OK
Server    Apache-Coyote/1.1
Pragma    No-cache
Cache-Control    no-cache
Expires    Thu, 01 Jan 1970 00:00:00 GMT
Content-Type    text/html;charset=GBK
Content-Length    4594
Date    Mon, 27 May 2013 11:38:37 GMT
===========================================================================================================================
响应标头2
===========================================================================================================================
   
响应    HTTP/1.1 200 OK
Server    Apache-Coyote/1.1
Pragma    No-cache
Cache-Control    no-cache
Expires    Thu, 01 Jan 1970 00:00:00 GMT
Content-Type    text/html;charset=GBK
Content-Length    4594
Date    Mon, 27 May 2013 11:58:15 GMT
===========================================================================================================================


响应正文1
===========================================================================================================================
======================================================================响应正文1   开始
<HTML>
<HEAD>
<TITLE>WIFI认证</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<link rel="stylesheet" href="/portal/images/css.css" type="text/css" media="screen" />
<link REL='STYLESHEET' TYPE='text/css' HREF='/master/include/cbms.css'>
<script language="JavaScript" src="/portal/portal.js"></script>
<SCRIPT LANGUAGE="JavaScript">
<!--
    var portalUrl='';
    //alert("portalUrl="+portalUrl);
    if(portalUrl!=""){
        var url=portalUrl;
        
        var usrarray=url.split("http://");
        var num=usrarray.length;
        //alert("num="+num);
        if(num>=2){
            window.open(url);
            //window.location.href=url;
        }

    }

    //防止页面刷新
    document.onkeydown = function()
     {
              if(event.keyCode==116) {
                event.keyCode=0;
                event.returnValue = false;
              }
    }
    document.oncontextmenu = function() {event.returnValue = false;}
//-->
</SCRIPT>
</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0  onLoad="javascript:initok();">
<form name="portalForm" method="POST" action="/portalDisconnAction.do"><div><input type="hidden" name="org.apache.struts.taglib.html.TOKEN" value="5e49ebffbbf985896592fb5ec1e7c061"></div>
<input type="hidden" name="wlanuserip" value='172.31.36.225' >
<input type="hidden" name="wlanacname" value='amnon' >
<input type="hidden" name="portalUrl" value='' >
<input type="hidden" name="usertime" value='15379' >
<input type="hidden" name="wlanacIp" value='192.168.254.252' >
<input type="hidden" name="message" value='(已用免费流量为 4502.828 M)(剩余免费流量为 617.172 M)(超出免费流量为 0.000 M)' >
<input type="hidden" name="ssid" value='' >
<TABLE WIDTH=999 BORDER=0 CELLPADDING=0 CELLSPACING=0 align="center" background="/portal/images/2013032612483487820130107194452409ooo.jpg">
  <!--DWLayoutTable-->
    <TR>
        <TD ROWSPAN=4 WIDTH=71>&nbsp;<!--左边空白部分--></TD>
        <TD COLSPAN=2 ROWSPAN=2 HEIGHT=108 width="555" valign="top">&nbsp;<img src="/portal/images/2013032612483487520130107194452398topt.jpg"/></TD>
        <TD WIDTH=377 HEIGHT=50>&nbsp;</TD>
    </TR>
    <TR>
        <TD  WIDTH=375 HEIGHT=58>&nbsp;</TD>
    </TR>
    <TR>
        <TD  WIDTH=272 HEIGHT=341 valign="top" ><table width="272" border="0" cellpadding="0" cellspacing="0" background="/portal/images/loginbg.png" style="background-position:center; background-repeat:no-repeat">
          <!--DWLayoutTable-->
          <tr>
            <td height="61" colspan="3">&nbsp;</td>
          </tr>
          <tr>
            <td width="16" height="262">&nbsp;</td>
            <td width="238" valign="top" align="left"><!--认证部分-->&nbsp;
            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
            
            <tr>
               <td height="25" align="center"><font color=red>上网期间请不要关闭此窗口</font></td>
            </tr>


             <tr height="40">
              <td align="center"><input name="提交" type="submit" value="离线" class="st_submit" /></td>
            </tr>
        <tr>
           <td><font color=red>(已用免费流量为 4502.828 M)(剩余免费流量为 617.172 M)(超出免费流量为 0.000 M)</font><SCRIPT LANGUAGE="JavaScript">
                    var temp='(已用免费流量为 4502.828 M)(剩余免费流量为 617.172 M)(超出免费流量为 0.000 M)';
                    if(temp!=""){
                         alert(temp);
                    }
                 </SCRIPT></td>
        </tr>
   

            </table>
            
            </td>
            <td width="18">&nbsp;</td>
          </tr>
          <tr>
            <td height="18" colspan="3">&nbsp;</td>
          </tr>
         
        </table>        </TD>
        <TD COLSPAN=2 WIDTH=658 align="left">&nbsp;<p>&nbsp;</p>
<p><span style="font-size: medium;">温馨提示</span></p>
<p>&nbsp;</p>
<p><span style="font-size: medium;">1、下线地址:<a href="http://1.1.1.1/">http://1.1.1.1</a></span></p>
<p>&nbsp;</p>
<p><span style="font-size: medium;">2、常见问题及使用注意事项参考校园论坛:<a href="http://bbs.ncbuct.
<p>&nbsp;</p>
<p><span style="font-size: medium;">3、内网资源:pt.ncbuct.(下载请使用专用工具)</span></p>
<p><span style="color: #ff0000; font-size: medium;">4、多人上网可使用交换机;严禁使用路由器,由此造成的一切后果由用户自行承担。</span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p></TD>
    </TR>
    <TR>
        <TD COLSPAN=3 HEIGHT=153 valign="bottom" align="center">&nbsp;</TD>
    </TR>
    <TR>
        <TD WIDTH=71 HEIGHT=1 >&nbsp;</TD>
        <TD WIDTH=272 HEIGHT=1>&nbsp;</TD>
        <TD WIDTH=281 HEIGHT=1>&nbsp;</TD>
        <TD WIDTH=377 HEIGHT=1>&nbsp;</TD>
    </TR>
</TABLE>
</form>
<!-- End ImageReady Slices -->
</BODY>
</HTML>
======================================================================响应正文1   结束
===========================================================================================================================

响应正文2
===========================================================================================================================
======================================================================响应正文2   开始
<HTML>
<HEAD>
<TITLE>WIFI认证</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<link rel="stylesheet" href="/portal/images/css.css" type="text/css" media="screen" />
<link REL='STYLESHEET' TYPE='text/css' HREF='/master/include/cbms.css'>
<script language="JavaScript" src="/portal/portal.js"></script>
<SCRIPT LANGUAGE="JavaScript">
<!--
    var portalUrl='';
    //alert("portalUrl="+portalUrl);
    if(portalUrl!=""){
        var url=portalUrl;
        
        var usrarray=url.split("http://");
        var num=usrarray.length;
        //alert("num="+num);
        if(num>=2){
            window.open(url);
            //window.location.href=url;
        }

    }

    //防止页面刷新
    document.onkeydown = function()
     {
              if(event.keyCode==116) {
                event.keyCode=0;
                event.returnValue = false;
              }
    }
    document.oncontextmenu = function() {event.returnValue = false;}
//-->
</SCRIPT>
</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0  onLoad="javascript:initok();">
<form name="portalForm" method="POST" action="/portalDisconnAction.do"><div><input type="hidden" name="org.apache.struts.taglib.html.TOKEN" value="ca06fd7a3eb54f27e058a5f21a7bf64c"></div>
<input type="hidden" name="wlanuserip" value='172.31.36.225' >
<input type="hidden" name="wlanacname" value='amnon' >
<input type="hidden" name="portalUrl" value='' >
<input type="hidden" name="usertime" value='14202' >
<input type="hidden" name="wlanacIp" value='192.168.254.252' >
<input type="hidden" name="message" value='(已用免费流量为 4247.524 M)(剩余免费流量为 872.476 M)(超出免费流量为 0.000 M)' >
<input type="hidden" name="ssid" value='' >
<TABLE WIDTH=999 BORDER=0 CELLPADDING=0 CELLSPACING=0 align="center" background="/portal/images/2013032612483487820130107194452409ooo.jpg">
  <!--DWLayoutTable-->
    <TR>
        <TD ROWSPAN=4 WIDTH=71>&nbsp;<!--左边空白部分--></TD>
        <TD COLSPAN=2 ROWSPAN=2 HEIGHT=108 width="555" valign="top">&nbsp;<img src="/portal/images/2013032612483487520130107194452398topt.jpg"/></TD>
        <TD WIDTH=377 HEIGHT=50>&nbsp;</TD>
    </TR>
    <TR>
        <TD  WIDTH=375 HEIGHT=58>&nbsp;</TD>
    </TR>
    <TR>
        <TD  WIDTH=272 HEIGHT=341 valign="top" ><table width="272" border="0" cellpadding="0" cellspacing="0" background="/portal/images/loginbg.png" style="background-position:center; background-repeat:no-repeat">
          <!--DWLayoutTable-->
          <tr>
            <td height="61" colspan="3">&nbsp;</td>
          </tr>
          <tr>
            <td width="16" height="262">&nbsp;</td>
            <td width="238" valign="top" align="left"><!--认证部分-->&nbsp;
            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
            
            <tr>
               <td height="25" align="center"><font color=red>上网期间请不要关闭此窗口</font></td>
            </tr>


             <tr height="40">
              <td align="center"><input name="提交" type="submit" value="离线" class="st_submit" /></td>
            </tr>
        <tr>
           <td><font color=red>(已用免费流量为 4247.524 M)(剩余免费流量为 872.476 M)(超出免费流量为 0.000 M)</font><SCRIPT LANGUAGE="JavaScript">
                    var temp='(已用免费流量为 4247.524 M)(剩余免费流量为 872.476 M)(超出免费流量为 0.000 M)';
                    if(temp!=""){
                         alert(temp);
                    }
                 </SCRIPT></td>
        </tr>
   

            </table>
            
            </td>
            <td width="18">&nbsp;</td>
          </tr>
          <tr>
            <td height="18" colspan="3">&nbsp;</td>
          </tr>
         
        </table>        </TD>
        <TD COLSPAN=2 WIDTH=658 align="left">&nbsp;<p>&nbsp;</p>
<p><span style="font-size: medium;">温馨提示</span></p>
<p>&nbsp;</p>
<p><span style="font-size: medium;">1、下线地址:<a href="http://1.1.1.1/">http://1.1.1.1</a></span></p>
<p>&nbsp;</p>
<p><span style="font-size: medium;">2、常见问题及使用注意事项参考校园论坛:<a href="http://bbs.ncbuct.
<p>&nbsp;</p>
<p><span style="font-size: medium;">3、内网资源:pt.ncbuct.(下载请使用专用工具)</span></p>
<p><span style="color: #ff0000; font-size: medium;">4、多人上网可使用交换机;严禁使用路由器,由此造成的一切后果由用户自行承担。</span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p></TD>
    </TR>
    <TR>
        <TD COLSPAN=3 HEIGHT=153 valign="bottom" align="center">&nbsp;</TD>
    </TR>
    <TR>
        <TD WIDTH=71 HEIGHT=1 >&nbsp;</TD>
        <TD WIDTH=272 HEIGHT=1>&nbsp;</TD>
        <TD WIDTH=281 HEIGHT=1>&nbsp;</TD>
        <TD WIDTH=377 HEIGHT=1>&nbsp;</TD>
    </TR>
</TABLE>
</form>
<!-- End ImageReady Slices -->
</BODY>
</HTML>
======================================================================响应正文2   结束
===========================================================================================================================





cookie1
===========================================================================================================================

已发送    JSESSIONID    3DCAE00AC6BA0D412BB1D95DBE713755                    

===========================================================================================================================
cookie2
===========================================================================================================================

已发送    JSESSIONID    71667340613805596BDB9C8AA034CA42                                       
===========================================================================================================================




参考文件:
===========================================================================================================================
模拟登陆代码        http://www.
数据包分析    http://www.
MFC模拟登陆115网盘   http://blog.
===========================================================================================================================



=========================================以下为发送数据包的代码---缺少获得token值的代码====================================
    try
 {
#define MAX_COUNT 1024
  CInternetSession session(_T("session"));
  INTERNET_PORT nPort = 80;
  CHttpConnection* pHttpConnect = session.GetHttpConnection(_T("10.10.10.10:8080"), nPort);
  if(pHttpConnect)
  {
   CHttpFile* pFile = pHttpConnect->OpenRequest(CHttpConnection::HTTP_VERB_POST, _T("/?ac=login"));
   if(pFile)
   {
    // 这里是请求头信息,由抓包工具得到该信息
    pFile->AddRequestHeaders(_T("POST /portalAuthAction.do;jsessionid=3DCAE00AC6BA0D412BB1D95DBE713755 HTTP/1.1"));
    pFile->AddRequestHeaders(_T("Accept: text/html, application/xhtml+xml, */*"));
    pFile->AddRequestHeaders(_T("Referer: http://10.10.10.10:8080/portalReceiveAction.do?wlanuserip=172.31.36.225&wlanacname=amnon"));
    pFile->AddRequestHeaders(_T("Accept-Language: zh-CN"));
    pFile->AddRequestHeaders(_T("User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"));
    pFile->AddRequestHeaders(_T("Content-Type: application/x-www-form-urlencoded"));
    pFile->AddRequestHeaders(_T("Accept-Encoding: gzip, deflate"));
    pFile->AddRequestHeaders(_T("Host: 10.10.10.10:8080"));
    pFile->AddRequestHeaders(_T("Content-Length: 341"));
    pFile->AddRequestHeaders(_T("DNT: 1"));
    pFile->AddRequestHeaders(_T("Connection: Keep-Alive"));
    pFile->AddRequestHeaders(_T("Cache-Control: no-cache"));   
// 这里是要提交的数据。说明一下: xxxx@xx.xxx指的是登陆的邮箱的地址,后面的XXXXXXX表示的是登陆的密码,使用的时候换成你自己的即可
    TCHAR szRequest[MAX_COUNT] = _T("org.apache.struts.taglib.html.TOKEN=5e49ebffbbf985896592fb5ec1e7c061&wlanuserip=172.31.36.225&wlanacname=amnon&chal_id=&chal_vector=&auth_type=PAP&seq_id=&req_id=&wlanacIp=192.168.254.252&ssid=&mac=&message=&bank_acct=&isCookies=&listpasscode=0&randstr=1682&domain=&isRadiusProxy=false&userid=110150037&passwd=8888&%CC%E1%BD%BB=%B5%C7+%C2%BC");
    pFile->SendRequest(NULL, 0, szRequest, _tcslen(szRequest)+1);
   
    CString strStatus(_T(""));
    if(pFile->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF, strStatus))
    {
     AfxMessageBox(strStatus);
    }
    pFile->Close();
    delete pFile;
    pFile = NULL;
   }
  }
  pHttpConnect->Close();
  delete pHttpConnect;
  pHttpConnect =NULL;  session.Close();
 }
 catch (CInternetException* e)
 {
  e->ReportError();
  e->Delete();
 }
=========================================================================================================

==========================================================================================================================



代码下载地址:http://pan.baidu.com/share/link?shareid=594824&uk=2417504237

[ 本帖最后由 wudkj 于 2013-6-3 23:00 编辑 ]
搜索更多相关主题的帖子: 信息 
2013-06-03 22:59
快速回复:MFC做一个登陆的程序,但是总是出错误。。请大家看看。。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.071201 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved