HttpWatch的抓包过程/C/C++ TCP/IP协议提交方式可参见:c++通过TCP/IP协议提交POST信息登录到PHPChina中文开发者社区
C++通过Wininet库提交方式可参见: C++通过Wininet库提交POST信息登录到PHPChina中文开发者社区
这次我使用Win7自带IE上面的开发人员工具来抓包!
首先第一步打开IE输入PHPChina中文开发者社区的官方网站:http://www.phpchina.com/
下面开始打开开发人员工具,在IE右上角的设置图标弹出的下拉菜单里找到开发人员工具,或者你也可以直接按F12!
在弹出的开发人员工具中选择网络:
就可以开始抓包了
先不要立即抓包,首先进入登录页面(防止在页面操作时抓到无效HTTP协议):
输入好账号密码之后在开始抓包
在点击登录:
登录失败我们不用管它,因为账号密码都是随便输的!
这里我们看下抓包工具这里有没有抓到包:
可以看到抓到三个包,一个POST两个GET,很明显POST就是我们要找的协议请求,因为我们刚刚执行了单击的操作:
右键复制URL:
然后将URL保存起来:
URL 协议 方法 结果 类型 已接收 已花费 发起程序 等候 开始 请求 响应 已读取缓存 差距 /member.php?mod=logging&action=login&loginsubmit=yes&loginhash=Lt4DQ&inajax=1 HTTP POST 200 text/xml .69 KB 109 ms 单击 76223 31 0 78 0 156
然后在双击选中的URL协议-选择请求正文:
注意第一行的username里的内容汉字被替换成了对应u编码的十六进制数,而密码也被加密了!
下面是我抓到的协议:
请求URL,方法POST:
/member.php?mod=logging&action=login&loginsubmit=yes&loginhash=Lt4DQ&inajax=1
POST请求数据:
formhash=225be104&referer=http%3A%2F%2Fwww.phpchina.com%2F&username=17%E5%B2%81boy%E5%8D%9A%E5%AE%A2&password=c8837b23ff8aaa8a2dde915473ce0991&questionid=0&answer=
下面开始编写HTML代码:
<!--标准开头--> <html> <body>
以表单的方式提交,注意请求页面必须是完整绝对地址,(使用target="_blank"方式请求页面):
<!--以表单:POST方式提交--> <form action="http://www.phpchina.com//member.php?mod=logging&action=login&loginsubmit=yes&loginhash=Lfi72&inajax=1" method="post" target="_blank"> <h1>formhash:</h1> <input type="text" name="formhash" value="225be104"> <!--formhash--> <br> <h1>referer:</h1> <input type="text" name="referer" value="http%3A%2F%2Fwww.phpchina.com%2F"> <!--referer--> <br> <h1>账号:</h1> <input type="text" name="username" value="17%E5%B2%81boy%E5%8D%9A%E5%AE%A2"> <!--账号--> <br> <h1>密码:</h1> <input type="text" name="password" value="c8837b23ff8aaa8a2dde915473ce0991"> <!--密码--> <br> <h1>questionid:</h1> <input type="text" name="questionid" value="0"> <!--questionid--> <br> <h1>answer:</h1> <input type="text" name="answer" value=""> <!--answer--> <br> <h1>POST:</h1> <input type="submit" value="提交"> <!--提交按钮--> </form> <!--表单结束-->
<!--页面结束--> </body> </html>
运行效果:
点击提交之后,浏览器会自动跳转到请求页面,并显示请求结果:
完整代码:
<!--标准开头--> <html> <body> <!--以表单:POST方式提交--> <form action="http://www.phpchina.com//member.php?mod=logging&action=login&loginsubmit=yes&loginhash=Lfi72&inajax=1" method="post" target="_blank"> <h1>formhash:</h1> <input type="text" name="formhash" value="225be104"> <!--formhash--> <br> <h1>referer:</h1> <input type="text" name="referer" value="http%3A%2F%2Fwww.phpchina.com%2F"> <!--referer--> <br> <h1>账号:</h1> <input type="text" name="username" value="17%E5%B2%81boy%E5%8D%9A%E5%AE%A2"> <!--账号--> <br> <h1>密码:</h1> <input type="text" name="password" value="c8837b23ff8aaa8a2dde915473ce0991"> <!--密码--> <br> <h1>questionid:</h1> <input type="text" name="questionid" value="0"> <!--questionid--> <br> <h1>answer:</h1> <input type="text" name="answer" value=""> <!--answer--> <br> <h1>POST:</h1> <input type="submit" value="提交"> <!--提交按钮--> </form> <!--表单结束--> <!--页面结束--> </body> </html>