-
-
[求助][求助][求助]菜鸟问一个关于验证码的小问题
-
发表于: 2012-9-10 01:11 6406
-
最近在做一个自动登录ChinaNet的程序,用python写了一段代码,很简单,就是提交一组数据,别的都好说,就是验证码的问题不好解决,并不是想过这个验证码,只是想集成到软件中去,不过目前测试阶段中,在知道验证码的前提下,提交验证码都会显示错误,一直没想明白,谁让俺是菜鸟呢,呵呵,特地过来学习的
根据网页抓包来看,应该是Session机制的,服务器存储验证码,然后我把输入的验证码提交给服务器以便服务器比对,我想先验证这个原理是否正确,我首先用chrome打开登录页面,然后找到验证码的位置,上面写着C74R,于是我就在python中将提交的验证码写为C74R,然后提交(chrome打开登陆页面后再就没动过),根据我的设想,此时服务器中存储的验证码应该是chrome登陆页面显示的那个验证码,我用python将这个验证码提交给服务器,服务器比对后一样就应该通过了,但实际结果是返回的信息为验证码错误,不知道为什么
chrome中用developer tools进行抓包,得到验证文件的提交数据及返回信息(这个是验证码正确的时候抓取的信息):
——————————————————————————————————————
Request URL:https://wlan.ct10000.com/authServlet
Request Method:POST
Status Code:302 Moved Temporarily
Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:UTF-8,*;q=0.5
Accept-Encoding:gzip,deflate,sdch
Accept-Language:zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:570
Content-Type:application/x-www-form-urlencoded
Cookie:JSESSIONID=M1prQMGKm1NSYhrwn4GsTGtrncCxptc5VrDPjs2PphyMKyY0DNzn!411575167
Host:wlan.ct10000.com
Origin:https://wlan.ct10000.com
Referer:https://wlan.ct10000.com/style/portalv4/index.jsp?paramStr=UGGOtheTLCc9BADAVNNfQ%2Fjl3JXkiadxLfk%2FnjPPWpwrz7J90Wr8TesQ3sjbUo0tXXO5%2Bn6cIhqg%0AsxyqHXLqZd%2FKiEmlCflUivY2GEq9KPma699v0DKCx8mbuErCjq%2BjuLtaCdFokGwo93zlJpYm%2B1Do%0Aw%2BeMS9xb0umqCpi8mDym7Z4GkGVydTY%2BkS3eib835RvY892RPpjbSmg65MllnzZ5C7Ex3Kc9
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.41 Safari/536.5
Form Data
UserName:18951845678
PassWord:123456
verifycode:C74R
UserType:1
paramStr:UGGOtheTLCc9BADAVNNfQ/jl3JXkiadxLfk/njPPWpwrz7J90Wr8TesQ3sjbUo0tDklM4Zc+c0OQ
EPr96yNp/xlNNy+EUDwdQlHLyaBlabg0oKuWB/kT9nWwcvjy5PelV5knKYo/+CvLqlSFj4fiElDo
w+eMS9xb0umqCpi8mDym7Z4GkGVydTY+kS3eib835RvY892RPpjbSmg65MllnzZ5C7Ex3Kc9
isChCardUser:false
isWCardUser:false
province:cw.js.chntel.com
verifycode:
isCookie:false
cookieType:0
UserName2:
PassWord2:
verifycode2:
UserName1:18951845678
isRegisterRealm:false
province:
defaultProv:js
PassWord1:123456
verifycode1:C74R
Response Headers
Content-Type:text/html
Date:Sun, 09 Sep 2012 16:57:33 GMT
Location:https://wlan.ct10000.com/style/portalv4/logon.jsp?paramStr=IPyBmL7KZTqKVdJWnwW6hWTvLyNMYSSQe86TC9ntDKnLEa3rEZr7lkUs%2FrSsFZZmwxoHvA9gsj0v%0AiWQpTZJjSKuY9%2B3Y9%2FollpKh8aKd4Em66MjjhbIxf4dn2CWIQUTvQdqL3FY5gcbGlnz7s4P9AJjo%0Agnv3sCHfsddDeKmXjX0ksNYZykxiJkzOTTFHyJtZQveSpQ32S3CQEPr96yNp%2FzUVUl0m26tzKVhT%0AK8eEdWOjlfiaqGpYgUSIyoEOc7M6xxvu7N%2Bvs%2Bu%2F%2F0dhMYW6W%2BbI7YFUP%2BiNSHUVaZFCi7Y%3D
Set-Cookie:UserType=; expires=Thursday, 01-Jan-1970 01:00:00 GMT; path=/, PassWord1=; expires=Thursday, 01-Jan-1970 01:00:00 GMT; path=/, UserName1=; expires=Thursday, 01-Jan-1970 01:00:00 GMT; path=/, province1=; expires=Thursday, 01-Jan-1970 01:00:00 GMT; path=/, phoneNo=; expires=Thursday, 01-Jan-1970 01:00:00 GMT; path=/
Transfer-Encoding:chunked
——————————————————————————————————————
测试所用python代码中提交的数据为:
submit_data = {'UserName': '18951845678', 'PassWord': '123456', 'verifycode': 'C74R', 'verifycode1': 'C74R', 'UserType': '1', 'paramStr': 'UGGOtheTLCc9BADAVNNfQ4zQrJz7WRs7Lfk/njPPWpwrz7J90Wr8TesQ3sjbUo0tDklM4Zc+c0OQEPr96yNp/xlNNy+EUDwdQlHLyaBlabg0oKuWB/kT9nWwcvjy5Pelth87Nnula5YwJlmFcmk/YFDow+eMS9xb0umqCpi8mDym7Z4GkGVydTY+kS3eib835RvY892RPpjbSmg65MllnzZ5C7Ex3Kc9', 'isChCardUser': 'false', 'isWCardUser': 'false', 'province': 'cw.js.chntel.com', 'cookieType': '0', 'isRegisterRealm': 'false'}
部分无关紧要的数据未提交,应该没有大碍,python其余代码仅仅将数据进行提交,没有做任何特殊处理,请问各位大侠,哪个地方出问题了,或者说哪些地方想的不对,请指点一二,十分感谢!
根据网页抓包来看,应该是Session机制的,服务器存储验证码,然后我把输入的验证码提交给服务器以便服务器比对,我想先验证这个原理是否正确,我首先用chrome打开登录页面,然后找到验证码的位置,上面写着C74R,于是我就在python中将提交的验证码写为C74R,然后提交(chrome打开登陆页面后再就没动过),根据我的设想,此时服务器中存储的验证码应该是chrome登陆页面显示的那个验证码,我用python将这个验证码提交给服务器,服务器比对后一样就应该通过了,但实际结果是返回的信息为验证码错误,不知道为什么
chrome中用developer tools进行抓包,得到验证文件的提交数据及返回信息(这个是验证码正确的时候抓取的信息):
——————————————————————————————————————
Request URL:https://wlan.ct10000.com/authServlet
Request Method:POST
Status Code:302 Moved Temporarily
Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:UTF-8,*;q=0.5
Accept-Encoding:gzip,deflate,sdch
Accept-Language:zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:570
Content-Type:application/x-www-form-urlencoded
Cookie:JSESSIONID=M1prQMGKm1NSYhrwn4GsTGtrncCxptc5VrDPjs2PphyMKyY0DNzn!411575167
Host:wlan.ct10000.com
Origin:https://wlan.ct10000.com
Referer:https://wlan.ct10000.com/style/portalv4/index.jsp?paramStr=UGGOtheTLCc9BADAVNNfQ%2Fjl3JXkiadxLfk%2FnjPPWpwrz7J90Wr8TesQ3sjbUo0tXXO5%2Bn6cIhqg%0AsxyqHXLqZd%2FKiEmlCflUivY2GEq9KPma699v0DKCx8mbuErCjq%2BjuLtaCdFokGwo93zlJpYm%2B1Do%0Aw%2BeMS9xb0umqCpi8mDym7Z4GkGVydTY%2BkS3eib835RvY892RPpjbSmg65MllnzZ5C7Ex3Kc9
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.41 Safari/536.5
Form Data
UserName:18951845678
PassWord:123456
verifycode:C74R
UserType:1
paramStr:UGGOtheTLCc9BADAVNNfQ/jl3JXkiadxLfk/njPPWpwrz7J90Wr8TesQ3sjbUo0tDklM4Zc+c0OQ
EPr96yNp/xlNNy+EUDwdQlHLyaBlabg0oKuWB/kT9nWwcvjy5PelV5knKYo/+CvLqlSFj4fiElDo
w+eMS9xb0umqCpi8mDym7Z4GkGVydTY+kS3eib835RvY892RPpjbSmg65MllnzZ5C7Ex3Kc9
isChCardUser:false
isWCardUser:false
province:cw.js.chntel.com
verifycode:
isCookie:false
cookieType:0
UserName2:
PassWord2:
verifycode2:
UserName1:18951845678
isRegisterRealm:false
province:
defaultProv:js
PassWord1:123456
verifycode1:C74R
Response Headers
Content-Type:text/html
Date:Sun, 09 Sep 2012 16:57:33 GMT
Location:https://wlan.ct10000.com/style/portalv4/logon.jsp?paramStr=IPyBmL7KZTqKVdJWnwW6hWTvLyNMYSSQe86TC9ntDKnLEa3rEZr7lkUs%2FrSsFZZmwxoHvA9gsj0v%0AiWQpTZJjSKuY9%2B3Y9%2FollpKh8aKd4Em66MjjhbIxf4dn2CWIQUTvQdqL3FY5gcbGlnz7s4P9AJjo%0Agnv3sCHfsddDeKmXjX0ksNYZykxiJkzOTTFHyJtZQveSpQ32S3CQEPr96yNp%2FzUVUl0m26tzKVhT%0AK8eEdWOjlfiaqGpYgUSIyoEOc7M6xxvu7N%2Bvs%2Bu%2F%2F0dhMYW6W%2BbI7YFUP%2BiNSHUVaZFCi7Y%3D
Set-Cookie:UserType=; expires=Thursday, 01-Jan-1970 01:00:00 GMT; path=/, PassWord1=; expires=Thursday, 01-Jan-1970 01:00:00 GMT; path=/, UserName1=; expires=Thursday, 01-Jan-1970 01:00:00 GMT; path=/, province1=; expires=Thursday, 01-Jan-1970 01:00:00 GMT; path=/, phoneNo=; expires=Thursday, 01-Jan-1970 01:00:00 GMT; path=/
Transfer-Encoding:chunked
——————————————————————————————————————
测试所用python代码中提交的数据为:
submit_data = {'UserName': '18951845678', 'PassWord': '123456', 'verifycode': 'C74R', 'verifycode1': 'C74R', 'UserType': '1', 'paramStr': 'UGGOtheTLCc9BADAVNNfQ4zQrJz7WRs7Lfk/njPPWpwrz7J90Wr8TesQ3sjbUo0tDklM4Zc+c0OQEPr96yNp/xlNNy+EUDwdQlHLyaBlabg0oKuWB/kT9nWwcvjy5Pelth87Nnula5YwJlmFcmk/YFDow+eMS9xb0umqCpi8mDym7Z4GkGVydTY+kS3eib835RvY892RPpjbSmg65MllnzZ5C7Ex3Kc9', 'isChCardUser': 'false', 'isWCardUser': 'false', 'province': 'cw.js.chntel.com', 'cookieType': '0', 'isRegisterRealm': 'false'}
部分无关紧要的数据未提交,应该没有大碍,python其余代码仅仅将数据进行提交,没有做任何特殊处理,请问各位大侠,哪个地方出问题了,或者说哪些地方想的不对,请指点一二,十分感谢!
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
赞赏
他的文章
- 开虚拟机和显卡性能有无太大关系? 25419
- [求助]可不可以让sqlmap输出每一步注入的语句? 1968
- [讨论]tcpdump相比wireshark有什么优势? 2077
- Ollydbg是否有回溯功能? 5443
- [求助]《自己动手写操作系统》中有几个不懂的地方 4135
看原图
赞赏
雪币:
留言: