求模拟登陆分析,在线等!

enaking 2018-10-25 07:33:56
我新手,工作之余,尝试模拟分析。自己封装了一个简单的HttpHelper

HttpHelper httpHelper87 = new HttpHelper("http://ux87.com/");
这个服务器地址是传给请求标头的host的。
然后
string strHtml = httpHelper87.GetHtml("http://ux87.com/login.php");
pBox.Image = new System.Drawing.Bitmap(httpHelper87.GetHtmlToStream("http://ux87.com/imgcode.php", out ckcCookies));
ckcCookies是接收到的Cookie


然后输入验证码:
strTimeStamp = DateTimeToStamp(DateTime.Now);这个是时间截,单位秒

string strCookieDoAction = "PHPSESSID=" + ckcCookies["PHPSESSID"].Value +
";Hm_lvt_7d781f93d49f3f4bb9e93736f01feb3a="
+ strTimeStamp +"; Hm_lpvt_7d781f93d49f3f4bb9e93736f01feb3a=" + strTimeStamp;
string strPostDataDoAction = "username=enagen001&password=123456&codevalue="
+ txtCode1.Text.Trim() + "&rme=on&code=code&act=login";

string strHttpReturnDoAction = httpHelper87.GetHtmlPost
("http://ux87.com/DoAction.php",strPostDataDoAction,strCookieDoAction, out ckcCookiesDoAction);



string strCookieindex = strCookieDoAction + "; " + ckcCookiesDoAction["user_id"].ToString() + "; "
+ckcCookiesDoAction["user_name"].ToString();

string strReturnIndex = httpHelper87.GetHtml("http://ux87.com/index.php", strCookieindex);


到这里,都是没问题的,返回的信息都和ie抓取的数据保持一致。然后下面

string strTimeStampGame_Play = DateTimeToStamp(DateTime.Now);

string strCookieGame_Play = ckcCookies["PHPSESSID"].ToString() +
"; Hm_lvt_7d781f93d49f3f4bb9e93736f01feb3a="
+ strTimeStamp + "; Hm_lpvt_7d781f93d49f3f4bb9e93736f01feb3a=" + strTimeStampGame_Play + "; " +
ckcCookiesDoAction["user_id"].ToString() + "; " + ckcCookiesDoAction["user_name"].ToString();

CookieCollection ckcGame_Play;

string strReturnGame_Play = httpHelper87.GetHtml("http://ux87.com/game_play.php?id=50116",
strCookieGame_Play, out ckcGame_Play);


其返回的值的是没有登陆的状态,求解,最好能给一个分析的办法。求鱼及渔。谢谢高手们带我成长!
...全文
1037 21 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
enaking 2018-11-08
  • 打赏
  • 举报
回复
好的,谢谢了,结贴
wq1282 2018-11-07
  • 打赏
  • 举报
回复
我已经提供了例子,且能达到需求,你把例子中的"http://ux87.com/login.php"换成“http://ux87.com/game_play.php?id=50116”就可以了!
enaking 2018-11-05
  • 打赏
  • 举报
回复
自己再顶一顶啊,,,,,
enaking 2018-11-01
  • 打赏
  • 举报
回复
引用 15 楼 wq1282 的回复:
当你发现post完之后,返回的Head包含setcookie就代表登录成功了,再用这些Cookie去拉index.php是OK的。


谢谢大哥的的细心帮助,我post完了,然后进入http://ux87.com/index.php也是对的,但进入http://ux87.com/game_play.php?id=50116 信息就不对了。
谢谢大哥。我把分数加倍,真的谢了。
token不能为空 2018-10-31
  • 打赏
  • 举报
回复
引用 17 楼 Seilboy 的回复:
Fidder 有用过吗,如果你要做爬虫的话,装一个

网页操作-抓包
程序操作-抓包

自己去比较请求头参数,cookie区别

不做爬虫也可以装一个,我看你这个问题都问了好几天了,装一个试试,很容易找出问题原因
token不能为空 2018-10-31
  • 打赏
  • 举报
回复
Fidder 有用过吗,如果你要做爬虫的话,装一个

网页操作-抓包
程序操作-抓包

自己去比较请求头参数,cookie区别
wq1282 2018-10-31
  • 打赏
  • 举报
回复
Pragma: no-cache
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Date: Wed, 31 Oct 2018 09:49:18 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Set-Cookie: user_id=518879,user_name=enagen001,user_nick=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT,rme_user=enagen001
Server: Apache
X-Powered-By: PHP/5.3.27
Connection: close
Content-Type: text/html
Content-Length: 51


<meta HTTP-EQUIV=refresh Content='0;url=index.php'>
wq1282 2018-10-31
  • 打赏
  • 举报
回复
当你发现post完之后,返回的Head包含setcookie就代表登录成功了,再用这些Cookie去拉index.php是OK的。
wq1282 2018-10-31
  • 打赏
  • 举报
回复
''''代码是VB.NET的,相信你能看懂:
''''给分完事,注释够多


Imports CsharpHttpHelper

Public Class Form1
'
'采用了苏飞CsharpHttpHelper框架,NuGet可下载
'
'分析时所使用的神器为:HttpAnalyzer
'
'求模拟登陆分析,在线等!-CSDN论坛 https://bbs.csdn.net/topics/392467546
Dim hh As New CsharpHttpHelper.HttpHelper
Dim hi As New HttpItem
Dim hr As HttpResult
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

'获取验证码,同时也能获得Cookie,一举两得,一般网站都这么玩
hi.URL = "http://ux87.com/imgcode.php"
hi.Method = "GET"
hi.WebProxy = Nothing
hi.ResultType = [Enum].ResultType.StringByte
hi.AutoRedirectCookie = True
hi.ResultCookieType = [Enum].ResultCookieType.String
hi.Cookie = ""
hr = hh.GetHtml(hi)
Me.BackgroundImageLayout = ImageLayout.None
Me.BackgroundImage = HttpHelper.GetImage(hr.ResultByte)
Debug.Print(hr.Cookie)


End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'
'填写验证码,点击按钮后继续登录操作
'看样子验证码也很容易自动识别(二值化即黑白处理, 按现有规则就能识别出字符了)
'
'Post登录信息
hi.URL = "http://ux87.com/DoAction.php"
hi.Method = "POST"
hi.Postdata = "username=enagen001&password=123456&codevalue=" & TextBox1.Text & "&rme=on&code=code&act=login"
'如果密码中有特殊符号要先 UrlEncode 再用。
hi.PostDataType = [Enum].PostDataType.String
hi.Cookie = Split(hr.Cookie, ";")(0)

''''这里非常关键,如果没有这些头,服务器就知道你不是从浏览器访问的,其他网站POST也类似原理。
hi.ContentType = "application/x-www-form-urlencoded"
hi.Referer = "http://ux87.com/login.php"
hi.Header.Add("Origin", "http://ux87.com")
hi.Header.Add("Upgrade-Insecure-Requests", "1")

Debug.Print(hi.Cookie)
hr = hh.GetHtml(hi)
Debug.Print(hr.StatusCode)
Debug.Print(hr.Header.ToString)
Debug.Print(hr.Html)

hi.URL = "http://ux87.com/index.php"
hi.Method = "GET"
hi.Cookie &= "; " & hr.Cookie.Replace(",", ";")
Debug.Print(hi.Cookie)
hr = hh.GetHtml(hi)
Debug.Print(hr.StatusCode)
Debug.Print(hr.Header.ToString)
Debug.Print(hr.Html)


End Sub
End Class
enaking 2018-10-30
  • 打赏
  • 举报
回复
引用 11 楼 xuzuning 的回复:
<!-- 登录前 start -->

<div class="index_login_20131027">

<form name="myLogin" action="DoAction.php" method="post">

<!-- <img src="images/i_tool_t.jpg" width="231" height="5" /> -->

<ul class="i_login_ul">
<li>帐 号:</li>
<li>密 码:</li>
</ul>
<ul class="i_login_ul1">

<input type="text" name="username" id="username" class="i_login_input" value="" />
<input type="password" name="password" id="password" class="i_login_input" />
<input type="checkbox" name="rme" id="rme" class="i_login_input1" /> <font class="i_login_text">记住登录帐号</font>

</ul>

<ul class="i_log_bot">

<table border="0" cellspacing="0" class="botton">

<tr><td class="botton_td"><a href="#" onclick="checkInput();">用户登录</a></td><td class="botton_td_r"></td></tr>

</table>

</ul>

<ul class="i_re_pass">

<a href="register.php" target="_blank" title="游戏用户注册">免费注册</a>

</ul>



<ul class="i_re_pass">

<font><a href="forgetpass.php" target="_blank" >忘记密码?</a></font>

</ul>

<!-- <img src="images/i_tool_b.jpg" width="231" height="6" /> -->



<input type="hidden" name="act" id="act" value="login" />

<input type='hidden' id='FromURL' name='FromURL' value='/'/>

</form>


这些我都看到,但我还是不知道我问题出在那。
enaking 2018-10-29
  • 打赏
  • 举报
回复
自己顶一下啊。
xuzuning 2018-10-29
  • 打赏
  • 举报
回复
	function checkInput(){

var flag = true;

if(document.myLogin.username.value.length == 0){

alert('用户名不得为空!');

flag = false;

}

if(flag && document.myLogin.password.value.length == 0){

alert('密码不得为空!');

flag = false;

}

if(flag) document.myLogin.submit();

}
xuzuning 2018-10-29
  • 打赏
  • 举报
回复
<!-- 登录前 start -->

<div class="index_login_20131027">

<form name="myLogin" action="DoAction.php" method="post">

<!-- <img src="images/i_tool_t.jpg" width="231" height="5" /> -->

<ul class="i_login_ul">
<li>帐 号:</li>
<li>密 码:</li>
</ul>
<ul class="i_login_ul1">

<input type="text" name="username" id="username" class="i_login_input" value="" />
<input type="password" name="password" id="password" class="i_login_input" />
<input type="checkbox" name="rme" id="rme" class="i_login_input1" /> <font class="i_login_text">记住登录帐号</font>

</ul>

<ul class="i_log_bot">

<table border="0" cellspacing="0" class="botton">

<tr><td class="botton_td"><a href="#" onclick="checkInput();">用户登录</a></td><td class="botton_td_r"></td></tr>

</table>

</ul>

<ul class="i_re_pass">

<a href="register.php" target="_blank" title="游戏用户注册">免费注册</a>

</ul>



<ul class="i_re_pass">

<font><a href="forgetpass.php" target="_blank" >忘记密码?</a></font>

</ul>

<!-- <img src="images/i_tool_b.jpg" width="231" height="6" /> -->



<input type="hidden" name="act" id="act" value="login" />

<input type='hidden' id='FromURL' name='FromURL' value='/'/>

</form>
enaking 2018-10-29
  • 打赏
  • 举报
回复
自己再顶一下,谢谢各位大牛。
weixin_43539422 2018-10-28
  • 打赏
  • 举报
回复
试试看看自说
孙大诚_SunRobin 2018-10-27
  • 打赏
  • 举报
回复
如果你是想通过模拟登陆去刷什么东西的话,推荐可以使用C#中的WebBrowser或者Chrome内核,这样不仅可以自己定制的写一个浏览器,而且可以根据加载的网站去执行自己定义的js脚本。
stherix 2018-10-26
  • 打赏
  • 举报
回复
做这个 ,研究下他的前端代码就可以了 一般网站判断同一个session,要么就是header里带token,要么是cookie里带token
enaking 2018-10-26
  • 打赏
  • 举报
回复
等待高手,自己顶一个
enaking 2018-10-26
  • 打赏
  • 举报
回复
引用 3 楼 stherix 的回复:
做这个 ,研究下他的前端代码就可以了

一般网站判断同一个session,要么就是header里带token,要么是cookie里带token


不知道从哪看起走,看了登陆按钮的checkInput()函数,都是简单的是否为空检查
xuan.ye 2018-10-26
  • 打赏
  • 举报
回复
忍不住安利一下 spring.net 的 RestTemplate 使用: https://github.com/spring-projects/spring-net-rest/blob/master/examples/Spring.HttpMessageConverterQuickStart/src/Spring.HttpMessageConverterQuickStart/Program.cs 文档: http://www.springframework.net/rest/refdoc/resttemplate.html
加载更多回复(1)

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧