localhost测试-- post 流程 小结--备忘
来源:互联网 发布:js查找字符串中的字符 编辑:程序博客网 时间:2024/06/01 09:20
流程
第一部 正常 方式 访问 需要登录的页面 抓包分析
1 提交的地址 / 分析源码
2 提交的数据构成 --比如含有 别的 网页hash 客户端其他数据
3 取验证码的地址
4 cookies
第二部
1 get 方式 访问 登录 页面
requestWeb = WebRequest.Create("http://localhost/168/index.php?s=Admin-Login") as HttpWebRequest;
requestWeb.Method = "Get";
responseWeb = requestWeb.GetResponse() as HttpWebResponse;
StreamReader dataresponse = new StreamReader(responseWeb.GetResponseStream(), Encoding.UTF8);
string data = dataresponse.ReadToEnd(); //读取返回的流
目的一: 取出提交数据中需要使用的hash值 之类 ..
string data2 = "value=\""; // \" 代表显示" 通过关键字符查找 拿出32位的hash值之类吧
textBox_code.Text = data.Substring(data.IndexOf(data2), 39).Substring(7); //使用indexof 和substring一般可以搞定
//取出 后 保存到文本框
目的二: 拿出建立连接时的cookies保存起来
string cookies = responseWeb.Headers.Get("Set-Cookie"); //获取该连接的cookies
cookies = cookies.Split(';')[0]; //分割出里面的sesionid
textBox_cookies.Text = cookies; //保存到文本框
requestWeb = null;
responseWeb = null;
第三部
利用获取保存的cookies 来 get访问取验证码的地址 并且显示出验证码
http://localhost/168/index.php?s=Admin-Login-Vcode 是取验证码的地址
CookieContainer cc = new CookieContainer();
cc.SetCookies(new Uri("http://localhost/168/index.php?s=Admin-Login-Vcode"), cookies); //将刚才连接保存的cookies 设置加入
requestWeb = WebRequest.Create("http://localhost/168/index.php?s=Admin-Login-Vcode") as HttpWebRequest;
requestWeb.CookieContainer = cc; // 带cookies 进行get访问
requestWeb.Method = "Get";
responseWeb = requestWeb.GetResponse() as HttpWebResponse;
Bitmap img = new Bitmap(responseWeb.GetResponseStream()); //获取验证码图片 保存到pic框中显示
pictureBox1.Image = img;
responseWeb = null;
requestWeb = null;
第四部
还是利用刚才保存的cookies 来进行POST 登陆地址
http://localhost/168/index.php?s=Admin-Login-Check 为post提交地址
CookieContainer cc = new CookieContainer();
cc.SetCookies(new Uri("http://localhost/168/index.php?s=Admin-Login-Check"), textBox_cookies.Text.ToString()); // 将保存在文本框
的cookies 设置到 post地址
string postdata = "user_name=admin&user_pwd=admin&verify=" + textBox_验证码.Text + "&__hash__=" + textBox_code.Text + "&submit.x=25&submit.y=15"; //构建提交的数据 使用到 取得的验证码 输入到验证码框 和 前面获取的hash值
requestWeb = HttpWebRequest.Create("http://localhost/168/index.php?s=Admin-Login-Check") as HttpWebRequest;
requestWeb.Method = "POST";
requestWeb.CookieContainer = cc; // 设置带cookies 来post
requestWeb.ContentType = "application/x-www-form-urlencoded";
StreamWriter datawriter = new StreamWriter(requestWeb.GetRequestStream(), Encoding.Default);
datawriter.Write(postdata); //写入post提交数据
datawriter.Flush();
//----下面为 返回的页面
responseWeb = requestWeb.GetResponse() as HttpWebResponse;
StreamReader datareader = new StreamReader(responseWeb.GetResponseStream(), System.Text.Encoding.UTF8);
textBox_Post返回.Text = datareader.ReadToEnd();
- localhost测试-- post 流程 小结--备忘
- curl post格式备忘
- 工作小结备忘
- ios 备忘小结
- sso_流程备忘
- 测试post
- 测试小结
- 系统配置流程 备忘 不时更新
- py2exe制作exe流程备忘
- Touch事件分配流程备忘
- php+apache搭建流程备忘
- android应用安装流程(备忘)
- node.js POST流程
- 测试流程
- 测试流程
- 测试流程
- 测试流程
- 测试流程
- 结构体内的#define宏定义
- (转)由于ip地址更改导致无法连接svn服务器的解决办法
- 20 精彩的暖色系网页设计
- sql查询20到30条记录
- Windows Phone开发(1):概论
- localhost测试-- post 流程 小结--备忘
- 关于UIGestureRecognizerState
- perl常用特殊变量列表
- 在Linux Fedora上部署Ruby On Rails环境
- Navicat Premium 数据库 管理工具
- 治疗鼻炎非常有效的方法——终于找到了
- linux下的C语言开发(线程互斥)
- WAP教程(10):WML参考手册、WML实例和WML DTD
- cocos2d-x初探学习笔记(22)--动画类