maker 发表于 2009-9-23 13:46:05

熟悉post的朋友来帮个忙,THX

本帖最后由 maker 于 2009-9-28 23:53 编辑

抓包如下:
POST /CAS/Login.Validate.Account?service=http%3A%2F%2Fwww%2Esdo%2Ecom%2Fcenter%2Findex%2Easp HTTP/1.1
Accept: application/x-shockwave-flash, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: http://www.sdo.com/IndexIframeLogin.asp
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727)
Host: cas.sdo.com
Content-Length: 243
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: SDO_REG_FROM=0; SNDA_ADRefererSystem_MachineTicket=f33acfc6-a5ca-4fb1-bfba-cf97c7af2ac6; ptid=makerbob04; sdid=1119198637; SDOTop_app=0; SDOLastLogin=97352A81B816B53DC64316694CF6A651%5E%24%5E166568564%5E%24%5E2009%2D09%2D23+12%3A35; HTTP%5FREFERER=http%3A%2F%2Fwww%2Esdo%2Ecom%2Fhome%2Ftop%2Easp; refererURL=http%253A%2F%2Fwww%2Esdo%2Ecom%2FIndexIframeLogin%2Easp; SDO_TOP_HTTP_REFERER=http%3A//www.sdo.com/IndexIframeLogin.asp; SDO_REFERER=http%3A//www.sdo.com/IndexIframeLogin.asp

warn=false&lt=Gauss-b2f1d061-6b81-4d49-b4f5-a25de65d5817-2009-09-23_12%3A41%3A51.000&_eventId=submit&idtype=0&gamearea=0&gametype=0&username=makerbob&password=makerbob&ekey=&challenge=&ptname=makerbob&ptpwd=makerbob&%B5%C7%C2%BC=+%B5%C7%C2%BC+


下面的代码还是登陆不成功,不熟悉这块,希望熟悉的朋友帮分析一下哪里出问题了,THX

#include <IE.au3>
FileDelete("log.txt")
Func _Post_Login()
$oHTTP = ObjCreate("Msxml2.xmlhttp")
$oHTTP.Open("Post","http://www.sdo.com/CAS/Login.Validate.Account?service=http%3A%2F%2Fwww%2Esdo%2Ecom%2Fcenter%2Findex%2Easp",false)
$oHTTP.setRequestHeader("Cache-Control", "no-cache")
$oHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
$oHTTP.setRequestHeader("Referer","http://www.sdo.com/IndexIframeLogin.asp")
$oHTTP.Send('warn=false&lt=Gauss-b2f1d061-6b81-4d49-b4f5-a25de65d5817-2009-09-23_12%3A41%3A51.000&_eventId=submit&idtype=0&gamearea=0&gametype=0&username=makerbob&password=makerbob&ekey=&challenge=&ptname=makerbob&ptpwd=makerbob&%B5%C7%C2%BC=+%B5%C7%C2%BC+')
$Log1 = BinaryToString($oHTTP.responseBody)
$html2 = $oHTTP.responseText
FileWrite("log.txt",$html2)
EndFunc

_Post_Login()
_IECreate ("http://www.sdo.com/IndexIframeLogin.asp",1,1,0)

maker 发表于 2009-9-23 13:51:18

今天发烧,发错地方了:face (30):

maker 发表于 2009-9-24 12:24:32

responsebody后status值为404 。。。。。

maker 发表于 2009-9-26 13:58:11

没有路过的高手?

gto250 发表于 2009-9-26 21:57:36

404错误,页面没找到!
你的请求有问题

warn=false&lt=Gauss-b2f1d061-6b81-4d49-b4f5-a25de65d5817-2009-09-23_12%3A41%3A51.000&_eventId=submit&idtype=0&gamearea=0&gametype=0&username=makerbob&password=makerbob&ekey=&challenge=&ptname=makerbob&ptpwd=makerbob&%B5%C7%C2%BC=+%B5%C7%C2%BC+

你多抓几次包,看看上面这段是不是一样的


http://lwc.nhome.cn/code/showip.asp

maker 发表于 2009-9-27 14:17:52

post地址不对返回404,修改后可以使200了,不过还是没有登录成功

#include <IE.au3>
FileDelete("log.txt")
Func _Post_Login()
$oHTTP = ObjCreate("Msxml2.xmlhttp")
$oHTTP.Open("Post","https://cas.sdo.com/CAS/Login.Validate.Account?service=http%3A%2F%2Fwww%2Esdo%2Ecom%2Fcenter%2Findex%2Easp",false)
$oHTTP.setRequestHeader("Cache-Control", "no-cache")
$oHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
$oHTTP.setRequestHeader("Referer","http://www.sdo.com/IndexIframeLogin.asp")
$oHTTP.Send('warn=false&lt=Gauss-7be45772-f7c9-44a6-8b32-a15215105c3a-2009-09-27_14%3A06%3A51.111&_eventId=submit&idtype=0&gamearea=0&gametype=0&username=makerbob&password=makerbob&ekey=&challenge=&ptname=makerbo&ptpwd=makerbob&%B5%C7%C2%BC=+%B5%C7%C2%BC+')
If @error <> 0 Then MsgBox(0,$oHTTP.Status,"登录失败!")
$Log1 = BinaryToString($oHTTP.responseBody)
TrayTip("responseBody状态",$oHTTP.status,3)
$html2 = $oHTTP.responseText
FileWrite("log.txt",$html2)
EndFunc

_Post_Login()
_IECreate ("http://www.sdo.com",1,1,0)

jhwl 发表于 2009-9-28 18:40:47

#include "ie.au3"
$oIE = _IECreate("http://www.sdo.com/IndexIframeLogin.asp")
$oForm = _IEFormGetObjByName($oIE, "form")
$warn= _IEFormElementGetObjByName ($oForm, "warn")
$lt = _IEFormElementGetObjByName ($oForm, "lt")
;=======上面为获取表单lt的值   你可以使用其它的方法
Func _Post_Login()
$oHTTP = ObjCreate("Msxml2.xmlhttp")
$oHTTP.Open("Post","https://cas.sdo.com/CAS/Login.Validate.Account?service=http%3A%2F%2Fwww%2Esdo%2Ecom%2Fcenter%2Findex%2Easp",false)
$oHTTP.setRequestHeader("Cache-Control", "no-cache")
$oHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
;$oHTTP.Send('warn='&$warn.value&'&lt='&$lt.value&'&_eventId='&$_eventId.value&'&idtype='&$idtype.value&'&gamearea='&$gamearea.value&'&gametype='&$gametype.value&'&username=makerbob&password=makerbob&ekey=&challenge=&ptname=makerbo&ptpwd=makerbob&%B5%C7%C2%BC=+%B5%C7%C2%BC+')
$oHTTP.Send('warn=false&lt='&$lt.value&'&_eventId=submit&idtype=0&gamearea=0&gametype=0&username=makerbob&password=makerbob&ekey=&challenge=&ptname=makerbo&ptpwd=makerbob&%B5%C7%C2%BC=+%B5%C7%C2%BC+')
If @error <> 0 Then MsgBox(0,$oHTTP.Status,"登录失败!")
$Log1 = BinaryToString($oHTTP.responseBody)
;TrayTip("responseBody状态",$oHTTP.status,3)
$html2 = $oHTTP.responseText
_IEDocWriteHTML ($oIE, $html2)
EndFunc
_Post_Login()使用表单方法#include "ie.au3"
;原网页中使用javascript传递值username和password
$oIE = _IECreate("http://www.sdo.com/IndexIframeLogin.asp")
        $oForm = _IEFormGetObjByName($oIE, "form")
        $username = _IEGetObjById($oIE, "username")
        $username.value = 'makerbob'
        $password = _IEGetObjById($oIE, "password")
        $password.value = 'makerbob'        
_IEFormSubmit ($oForm)

maker 发表于 2009-9-28 23:35:46

本帖最后由 maker 于 2009-9-28 23:59 编辑

谢谢各位,特别是楼上,来看jhwl 晚了,不然不用费脑筋了,写的很好,谢谢,虽然我想用xmlhttp来做静默,做了个图:

自己闭门2天研究出来了,lt值是个关键,上网查资料才知道的,呵呵,不过不会正则,取lt和后面的登录连接有点傻瓜式,哎,好多要学的,愁

jhwl 发表于 2009-9-29 15:16:39

正则取法$HTMLSource = StringRegExp(_XmlHttp("http://www.sdo.com/IndexIframeLogin.asp"),'(?<=var path    \=   \").*?(?=\")',3)
$lt=StringRegExp(_XmlHttp($HTMLSource),'(?<=lt\" value=\").*?(?=\")',3)
ConsoleWrite($lt) ;这里是得到的表单lt的值
Func _XmlHttp($url)
        Local $oHTTP, $sReturn
        $httpObj = ObjCreate("winhttp.winhttprequest.5.1")
        $httpObj.open("GET", $url)
        $httpObj.send()
        $HTMLSource = StringAddCR($httpObj.Responsetext)
        Return $HTMLSource
EndFunc   ;==>_XmlHttp

maker 发表于 2009-9-30 16:18:27

Nice~~~Thx,不常用,现学现卖了,不然就忘了代码了,:face (27):

joyhie 发表于 2009-10-2 23:36:30

想要楼主写的程序:face (29):

sdzx 发表于 2009-12-29 20:48:00

学习中,飞铲感谢

ceoguang 发表于 2010-1-1 19:13:47

收藏之.........

yorker0503 发表于 2010-4-25 00:34:55

jhwl真厉害
页: [1]
查看完整版本: 熟悉post的朋友来帮个忙,THX