python—post请求数据包
可以正常访问网页地址
http://192.168.40.239/binzcms1/index.php
用户登录成功的post请求数据包信息:
1、获取最新的验证码
GET http://192.168.40.239/binzcms1/index.php?ctl=code&ctl=code&ctl=code&ctl=code&ctl=code&ctl=code HTTP/1.1
Host: 192.168.40.239
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://192.168.40.239/binzcms1/index.php
Cookie: style=styles4; PHPSESSID=1kq6ich50b6cb6g3rl75ct2ta4
Connection: keep-alive
HTTP/1.1 200 OK
Date: Sat, 16 Dec 2017 12:53:48 GMT
Server: Apache/2.4.23 (Win32) OpenSSL/1.0.2j PHP/5.4.45
X-Powered-By: PHP/5.4.45
Expires: 0
Cache-Control: no-cache
Pragma: no-cache
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: image/png
Content-Length: 269
PNG
IHDR 2 EPLTE & e S Ҡ Z
c7 y z9 bX! & \ %g;kddd0=2 C IDAT(
*** FIDDLER: RawDisplay truncated at 128 characters. Right-click to disable truncation. ***
2、正常的成功登录的POST请求数据包信息:
POST http://192.168.40.239/binzcms1/index.php?ctl=member&act=front_member_login HTTP/1.1
Host: 192.168.40.239
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://192.168.40.239/binzcms1/index.php
Cookie: style=styles4; PHPSESSID=1kq6ich50b6cb6g3rl75ct2ta4
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 73
username=xwb&password=173605852&login_code=qhue&button=%E7%99%BB%E5%BD%95
HTTP/1.1 302 Found
Date: Sat, 16 Dec 2017 12:53:58 GMT
Server: Apache/2.4.23 (Win32) OpenSSL/1.0.2j PHP/5.4.45
X-Powered-By: PHP/5.4.45
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: http://192.168.40.239/binzcms1/index.php
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
Content-Length: 0
3、在局域网linux 机器上运行python脚本信息(当中的login_code值必须是最新的图片验证码信息。谨记:并且headers的字典信息必须与Post请求的数据头信息一致):
root@kali:~/python/laowangpy/function# cat postloginbinzcms.py
#!/usr/bin/python
# --*-- coding:utf-8 --*--
import string
import urllib
import urllib2
url = "http://192.168.40.239/binzcms1/index.php?ctl=member&act=front_member_login"#请求post的url地址
values = {"username":"xwb","password":"173605852","login_code":"mqdq","button":"登录"}#请求的URL地址,post表单数据信息
headers = {"Host":"192.168.40.239",
"User-Agent" : "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0",
"Accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language" : "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3",
"Accept-Encoding" : "gzip,deflate",
"Referer" : "http://192.168.40.239/binzcms1/index.php",
"Cookie" : "style=styles4; PHPSESSID=1kq6ich50b6cb6g3rl75ct2ta4",
"Connection" : "keep-alive",
"Content-Type" : "application/x-www-form-urlencoded",
"Content-Length": "73"}
data = urllib.urlencode(values)#请求post表单数据
req = urllib2.Request(url,data,headers)#请求数据)
proxy_handler = urllib2.ProxyHandler({'http': '192.168.40.1:4455'})#抓包
opener = urllib2.build_opener(proxy_handler)
urllib2.install_opener(opener)#启用post请求
response = urllib2.urlopen(req)#打开请求的数据
the_page = response.read()#读取并缓存请求到的数据
print the_page#打印请求到的页面
print "你请求到页面数据包为%d字节" %len(the_page)#计算请求到的页面数据大小
root@kali:~/python/laowangpy/function#
4、运行脚本情况:
root@kali:~/python/laowangpy/function# vi postloginbinzcms.py
root@kali:~/python/laowangpy/function# python postloginbinzcms.py
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Binzcms内容管理系统</title>
<meta name="keywords" content="binzcms,内容管理系统" />
<meta name="description" content="好用的内容管理系统" />
<link type="text/css" rel="stylesheet" href="http://192.168.40.239/binzcms1/templates/default/css/style.css" />
<link type="text/css" rel="stylesheet" href="http://192.168.40.239/binzcms1/templates/default/css/index.css" />
<link type="text/css" rel="stylesheet" href="http://192.168.40.239/binzcms1/templates/default/css/ie.css" />
</head>
<body>
<div id="container">
<div id="header">
<div id="top">
<div id="alreadyLogin">
<span id="whois"><strong>xwb</strong>,欢迎回来!</span>
|<span><img src="http://192.168.40.239/binzcms1/templates/default/images/house.png" /><a href="index.php?ctl=home&act=front_home">会员中心</a></span>
|<span><a href="index.php?ctl=member&act=front_member_out">退出</a></span>
</div><!-- end of alreadyLogin -->
<div id="miniSearch">
<form action="index.php" method="get">
<input type="hidden" name="ctl" value="search" />
<input type="hidden" name="act" value="front_all_search" />
<input type="text" name="keywords" id="keywords" class="textInput" />
<input type="submit" name="button3" id="button3" class="btnInput" value="搜索" />
</form>
</div><!-- end of miniSearch -->
</div><!-- end of top -->
<div id="topMiddle">
<div id="logo">
<h1><a href="http://192.168.40.239/binzcms1">Binzcms内容管理系统</a></h1>
</div><!-- end of logo -->
<ul id="miniLinks">
<li><a href="index.php?ctl=home&act=front_home">会员中心</a></li>
<li><a href="index.php?ctl=guestbook">我要留言</a></li>
<li class="rss-icon"><a href="index.php?ctl=rss&act=front_rss" target="_blank">RSS</a></li>
</ul><!-- end of miniLinks -->
</div><!-- end of topMiddle -->
<div id="topBottom">
<ul id="mainNav">
<li class="current"><span><a href="http://192.168.40.239/binzcms1">首页</a></span></li>
<li ><span><a href="http://192.168.40.239/binzcms1/index.php?ctl=class&act=front_class&class_id=10" >国内新闻</a></span></li>
<li ><span><a href="http://192.168.40.239/binzcms1/index.php?ctl=class&act=front_class&class_id=11" >国际新闻</a></span></li>
<li ><span><a href="http://192.168.40.239/binzcms1/index.php?ctl=class&act=front_class&class_id=12" >图片新闻</a></span></li>
<li ><span><a href="http://192.168.40.239/binzcms1/index.php?ctl=class&act=front_class&class_id=13" >官方论坛</a></span></li>
<li ><span><a href="http://192.168.40.239/binzcms1/index.php?ctl=guestbook">留言板</a></span></li>
</ul><!-- enf of mainNav -->
</div><!-- end of topBottom -->
</div><!-- end of header -->
<div id="main">
<div class="right-main">
<div class="sub-wrap">
<div class="right-half simple-h2" style="margin-right:20px;">
<h2>
<ul class="tabs" id="firstTab">
<li class="active" onmouseover="nTabs(this,0);"><span>最新资讯<!--最新资讯--></span></li>
<li onmouseover="nTabs(this,1);"><span>焦点新闻<!--焦点新闻--></span></li>
</ul><!-- enf of tabs -->
<span class="more"><a href="index.php?ctl=search&act=front_all_search" target="_blank">更多</a><!--更多--></span>
</h2>
<div id="firstTab_0" class="tab-content">
<ul class="whole-list">
<li>
<a href="index.php?ctl=article&act=front_article_content&article_id=26" target="_blank" title="网络团购调查:96%企业有融资意向存十大隐忧"><font color="#fd6600">网络团购调查:96%企业有融资意向存十大隐忧</font></a>
</li>
<li>
<a href="index.php?ctl=article&act=front_article_content&article_id=25" target="_blank" title="墨西哥湾原油泄漏">墨西哥湾原油泄漏</a>
</li>
<li>
<a href="index.php?ctl=article&act=front_article_content&article_id=24" target="_blank" title="第五届海峡(福州)渔业博览会将在福州开展"><font color="#0000fe">第五届海峡(福州)渔业博览会将在福州开展</font></a>
</li>
<li>
<a href="index.php?ctl=article&act=front_article_content&article_id=23" target="_blank" title="中秋前夜 祭月典礼重现京城(高清组图)">中秋前夜 祭月典礼重现京城(高清组图)</a>
</li>
<li>
<a href="index.php?ctl=article&act=front_article_content&article_id=22" target="_blank" title="河北廊坊“炫动金秋”购车节十一举办">河北廊坊“炫动金秋”购车节十一举办</a>
</li>
<li>
<a href="index.php?ctl=article&act=front_article_content&article_id=21" target="_blank" title="组图:新发现比校花更美的民间美女">组图:新发现比校花更美的民间美女</a>
</li>
</ul><!-- enf of whole-list -->
</div><!-- enf of firstTab_0 -->
<div id="firstTab_1" class="tab-content" style="display:none;">
<ul class="whole-list">
<li><a href="index.php?ctl=article&act=front_article_content&article_id=21" target="_blank" title="组图:新发现比校花更美的民间美女">组图:新发现比校花更美的民间美女</a></li>
<li><a href="index.php?ctl=article&act=front_article_content&article_id=24" target="_blank" title="第五届海峡(福州)渔业博览会将在福州开展"><font color="#0000fe">第五届海峡(福州)渔业博览会将在福州开展</font></a></li>
<li><a href="index.php?ctl=article&act=front_article_content&article_id=20" target="_blank" title="高清组图:高清:“星姐”选举全国总冠军诞生">高清组图:高清:“星姐”选举全国总冠军诞生</a></li>
<li><a href="index.php?ctl=article&act=front_article_content&article_id=17" target="_blank" title="中国老年人占全世界22% 去年底已达1.67亿人">中国老年人占全世界22% 去年底已达1.67亿人</a></li>
<li><a href="index.php?ctl=article&act=front_article_content&article_id=18" target="_blank" title="中国将于近日择机发射“遥感卫星十一号”"><font color="#fd6600">中国将于近日择机发射“遥感卫星十一号”</font></a></li>
<li><a href="index.php?ctl=article&act=front_article_content&article_id=19" target="_blank" title="香港国泰航空以约16亿美元向波音购买6架飞机">香港国泰航空以约16亿美元向波音购买6架飞机</a></li>
</ul><!-- enf of whole-list -->
</div><!-- enf of firstTab_1 -->
</div><!-- enf of right-half -->
<div class="right-half simple-h2">
<h2><span class="tit"><em>推荐资讯<!--推荐资讯--></em></span>
<span class="more"><a href="index.php?ctl=search&act=front_all_search" target="_blank">更多</a></span>
</h2>
<ul class="whole-list">
<li><a href="index.php?ctl=article&act=front_article_content&article_id=17" target="_blank" title="中国老年人占全世界22% 去年底已达1.67亿人">中国老年人占全世界22% 去年底已达1.67亿人</a></li>
<li><a href="index.php?ctl=article&act=front_article_content&article_id=18" target="_blank" title="中国将于近日择机发射“遥感卫星十一号”"><font color="#fd6600">中国将于近日择机发射“遥感卫星十一号”</font></a></li>
<li><a href="index.php?ctl=article&act=front_article_content&article_id=19" target="_blank" title="香港国泰航空以约16亿美元向波音购买6架飞机">香港国泰航空以约16亿美元向波音购买6架飞机</a></li>
<li><a href="index.php?ctl=article&act=front_article_content&article_id=20" target="_blank" title="高清组图:高清:“星姐”选举全国总冠军诞生">高清组图:高清:“星姐”选举全国总冠军诞生</a></li>
<li><a href="index.php?ctl=article&act=front_article_content&article_id=22" target="_blank" title="河北廊坊“炫动金秋”购车节十一举办">河北廊坊“炫动金秋”购车节十一举办</a></li>
<li><a href="index.php?ctl=article&act=front_article_content&article_id=23" target="_blank" title="中秋前夜 祭月典礼重现京城(高清组图)">中秋前夜 祭月典礼重现京城(高清组图)</a></li>
</ul><!-- enf of whole-list -->
</div><!-- enf of right-half -->
<div class="clear"></div>
</div><!-- enf of sub-wrap -->
<div class="sub-wrap" id="search">
<ul id="searchTab">
<li onclick="nTabs(this,0);" class="active">全部<!--全部--></li>
<li onclick="nTabs(this,1);">资讯<!--资讯--></li>
<li onclick="nTabs(this,2);">图片<!--图片--></li>
</ul><!-- enf of searchTab -->
<div id="searchTab_0" class="search-content">
<form action="index.php" method="get">
<input type="hidden" name="ctl" value="search" />
<input type="hidden" name="act" value="front_all_search" />
<input type="text" name="keywords" id="keywords" class="textInput" />
<input type="submit" name="button4" id="button4" class="btnInput" value="搜索" />
</form>
</div><!-- enf of searchTab_0 -->
<div id="searchTab_1" class="search-content" style="display:none;">
<form action="index.php" method="get">
<input type="hidden" name="ctl" value="search" />
<input type="hidden" name="act" value="front_article_search" />
<input type="text" name="keywords" id="keywords" class="textInput" />
<input type="submit" name="button4" id="button4" class="btnInput" value="搜索" />
</form>
</div><!-- enf of searchTab_1 -->
<div id="searchTab_2" class="search-content" style="display:none;">
<form action="index.php" method="get">
<input type="hidden" name="ctl" value="search" />
<input type="hidden" name="act" value="front_image_search" />
<input type="text" name="keywords" id="keywords" class="textInput" />
<input type="submit" name="button4" id="button4" class="btnInput" value="搜索" />
</form>
</div><!-- enf of searchTab_2 -->
</div><!-- enf of search -->
<div class="sub-wrap bg-h2">
<h2>
<em>国内新闻</em>
<span class="more">
<a href="index.php?ctl=class&act=front_class&class_id=10" target="_blank">更多</a>
</span>
</h2>
<div class="right-half">
<ul class="pic-list">
<li>
<div class="thumb">
<a href="index.php?ctl=article&act=front_article_content&article_id=26" target="_blank"><img src="http://192.168.40.239/binzcms1/upload/uppic/201009/12851577201459839133.jpg" /></a>
</div><!-- enf of thumb -->
<p>
<a href="index.php?ctl=article&act=front_article_content&article_id=26" target="_blank"><font color="#fd6600">网络团购调查:96%企业有融资意向存十大隐忧</font></a>
</p>
</li>
<li>
<div class="thumb">
<a href="index.php?ctl=article&act=front_article_content&article_id=24" target="_blank"><img src="http://192.168.40.239/binzcms1/upload/uppic/201009/12851550681499554651.jpg" /></a>
</div><!-- enf of thumb -->
<p>
<a href="index.php?ctl=article&act=front_article_content&article_id=24" target="_blank"><font color="#0000fe">第五届海峡(福州)渔业博览会将在福州开展</font></a>
</p>
</li>
<li>
<div class="thumb">
<a href="index.php?ctl=article&act=front_article_content&article_id=23" target="_blank"><img src="http://192.168.40.239/binzcms1/upload/uppic/201009/12851543409247323.jpg" /></a>
</div><!-- enf of thumb -->
<p>
<a href="index.php?ctl=article&act=front_article_content&article_id=23" target="_blank">中秋前夜 祭月典礼重现京城(高清组图)</a>
</p>
</li>
<div class="clear"></div>
</ul><!-- enf of pic-list -->
</div><!-- enf of right-half -->
<div class="right-half">
<ul class="whole-list" style="margin:15px 8px 8px 18px;">
<li>
<a href="index.php?ctl=article&act=front_article_content&article_id=26" target="_blank"><font color="#fd6600">网络团购调查:96%企业有融资意向存十大隐忧</font></a>
</li>
<li>
<a href="index.php?ctl=article&act=front_article_content&article_id=24" target="_blank"><font color="#0000fe">第五届海峡(福州)渔业博览会将在福州开展</font></a>
</li>
<li>
<a href="index.php?ctl=article&act=front_article_content&article_id=23" target="_blank">中秋前夜 祭月典礼重现京城(高清组图)</a>
</li>
<li>
<a href="index.php?ctl=article&act=front_article_content&article_id=22" target="_blank">河北廊坊“炫动金秋”购车节十一举办</a>
</li>
<li>
<a href="index.php?ctl=article&act=front_article_content&article_id=19" target="_blank">香港国泰航空以约16亿美元向波音购买6架飞机</a>
</li>
<li>
<a href="index.php?ctl=article&act=front_article_content&article_id=18" target="_blank"><font color="#fd6600">中国将于近日择机发射“遥感卫星十一号”</font></a>
</li>
<li>
<a href="index.php?ctl=article&act=front_article_content&article_id=17" target="_blank">中国老年人占全世界22% 去年底已达1.67亿人</a>
</li>
</ul><!-- enf of whole-list -->
</div><!-- enf of right-half -->
<div class="clear"></div>
</div><!-- enf of sub-wrap -->
<div class="sub-wrap bg-h2">
<h2>
<em>图片新闻</em>
<span class="more">
<a href="index.php?ctl=class&act=front_class&class_id=12" target="_blank">更多</a>
</span>
</h2>
<div class="right-half">
<ul class="pic-list">
<li>
<div class="thumb">
<a href="index.php?ctl=article&act=front_article_content&article_id=25" target="_blank"><img src="http://192.168.40.239/binzcms1/upload/uppic/201009/12851558141683183648.jpg" /></a>
</div><!-- enf of thumb -->
<p>
<a href="index.php?ctl=article&act=front_article_content&article_id=25" target="_blank">墨西哥湾原油泄漏</a>
</p>
</li>
<li>
<div class="thumb">
<a href="index.php?ctl=article&act=front_article_content&article_id=21" target="_blank"><img src="http://192.168.40.239/binzcms1/upload/uppic/201009/1285149406344509034.jpg" /></a>
</div><!-- enf of thumb -->
<p>
<a href="index.php?ctl=article&act=front_article_content&article_id=21" target="_blank">组图:新发现比校花更美的民间美女</a>
</p>
</li>
<li>
<div class="thumb">
<a href="index.php?ctl=article&act=front_article_content&article_id=20" target="_blank"><img src="http://192.168.40.239/binzcms1/upload/uppic/201009/128507319153794655.jpg" /></a>
</div><!-- enf of thumb -->
<p>
<a href="index.php?ctl=article&act=front_article_content&article_id=20" target="_blank">高清组图:高清:“星姐”选举全国总冠军诞生</a>
</p>
</li>
<div class="clear"></div>
</ul><!-- enf of pic-list -->
</div><!-- enf of right-half -->
<div class="right-half">
<ul class="whole-list" style="margin:15px 8px 8px 18px;">
<li>
<a href="index.php?ctl=article&act=front_article_content&article_id=25" target="_blank">墨西哥湾原油泄漏</a>
</li>
<li>
<a href="index.php?ctl=article&act=front_article_content&article_id=21" target="_blank">组图:新发现比校花更美的民间美女</a>
</li>
<li>
<a href="index.php?ctl=article&act=front_article_content&article_id=20" target="_blank">高清组图:高清:“星姐”选举全国总冠军诞生</a>
</li>
</ul><!-- enf of whole-list -->
</div><!-- enf of right-half -->
<div class="clear"></div>
</div><!-- enf of sub-wrap -->
</div>
<!-- end of right-main -->
<div class="left-side">
<div id="slideShow">
<script type="text/javascript">
var swf_width=285;
var swf_height=220;
</script>
<script src="data/flashdata/cycle_image.js"></script>
</div><!-- enf of slideShow -->
<div class="bg-h2" id="siteBoard">
<h2><em>网站公告<!--网站公告--></em></h2>
<ul id="boardList">
<li><a href="index.php?ctl=other&act=notice_show&article_id=3" target="_blank" title="Binzcms内容管理系统发布!">Binzcms内容管理系统发布!</a></li>
<li><a href="index.php?ctl=other&act=notice_show&article_id=11" target="_blank" title="Binzcms论坛开放注册">Binzcms论坛开放注册</a></li>
<li><a href="index.php?ctl=other&act=notice_show&article_id=12" target="_blank" title="Binzcms功能介绍">Binzcms功能介绍</a></li>
</ul><!-- enf of boardList -->
</div><!-- enf of siteBoard -->
<!-- enf of download -->
<div class="bg-h2" id="poll">
<h2><em>投票调查<!--投票调查--></em></h2>
<form name="vote_form" action="index.php?ctl=other&act=poll_view&vote_id=" method="post">
<input type="hidden" name="vote_type" value="" />
<h3></h3>
<form>
<ul id="pollList">
</ul><!-- end of pollList -->
<div class="textCenter">
<input type="submit" class="btnInput" value="提交" />
<a href="index.php?ctl=other&act=poll_view&vote_id=">查看结果<!--查看结果--></a>
</div><!-- end of textCenter -->
</form>
</div><!-- enf of bg-h2 -->
<!-- enf of bg-h2 -->
</div>
<!-- end of left-side -->
<div id="links">
<h2>友情链接<!--友情链接--></h2>
<div id="txtLinks">
<a href="http://www.binzcms.com" target="_blank" title="Binzcms">Binzcms</a>
</div><!-- enf of txtLinks -->
</div><!-- enf of links -->
</div><!-- end of main -->
<div id="footer">
<ul id="bottomNav">
<li><a href="index.php" target="_blank">网站首页</a></li>
<li><a href=" http://192.168.40.239/binzcms1/index.php?ctl=other&act=footer&article_id=6 " target="_blank">关于我们</a></li>
<li><a href=" http://192.168.40.239/binzcms1/index.php?ctl=other&act=footer&article_id=7 " target="_blank">服务条款</a></li>
<li><a href=" http://192.168.40.239/binzcms1/index.php?ctl=other&act=footer&article_id=8 " target="_blank">联系我们</a></li>
<li><a href=" http://192.168.40.239/binzcms1/index.php?ctl=other&act=footer&article_id=9 " target="_blank">免责声明</a></li>
<li><a href=" http://192.168.40.239/binzcms1/index.php?ctl=other&act=footer&article_id=10 " target="_blank">网站地图</a></li>
</ul><!-- enf of bottomNav -->
<p>Power by <a href="http://www.binzcms.com" target="_blank">binzcms v1.0 beta</a> © 2009-2010 binzcms.com All Rights Reserved.</p>
<p><a href="http://www.miibeian.gov.cn/" target="_blank">冀ICP备0000000号</a></p> </div><!-- end of footer -->
</div><!-- end of container -->
<script type="text/javascript">
//实现标签切换
function nTabs(thisObj,Num){
if(thisObj.className == "active")return;
var tabObj = thisObj.parentNode.id;
var tabList = document.getElementById(tabObj).getElementsByTagName("li");
for(i = 0; i < tabList.length; i++)
{
if (i == Num)
{
thisObj.className = "active";
document.getElementById(tabObj+"_"+i).style.display = "block";
}else{
tabList[i].className = "normal";
document.getElementById(tabObj+"_"+i).style.display = "none";
}
}
}
</script>
</body>
</html>
你请求到页面数据包为26468字节
root@kali:~/python/laowangpy/function#