今天偶然发现我们学校的出校访问网页是数字验证码,于是想拿来破解。思路就是普通的抓取元素,然后填入表单,然后发现一切顺利,账号密码和验证码都填进去了。然后登陆发现
永远提示验证码错误,郁闷啊,手动输入也是验证码错误,但是在浏览器内是可以使用的,不知道问题在哪里
C# webBrowser登录提示验证码错误
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- qq_34156691 2017-03-09 12:08关注
代码如下
using System; using System.Windows.Forms; namespace 登陆网页 { public partial class Form1 : Form { public Form1() { InitializeComponent(); webBrowser1.Navigate("http://wall.usts.edu.cn/jf6/zizhufuwu.php"); } private void button1_Click(object sender, EventArgs e) { webBrowser1.Refresh(); } private void button2_Click(object sender, EventArgs e) { //while (true) //{ HtmlDocument doc = webBrowser1.Document; HtmlElement yanzhengma = doc.GetElementById("jy"); string code = yanzhengma.All[0].All[0].All[12].InnerHtml; code = code[0].ToString() + code[1] + code[2] + code[3]; string html = yanzhengma.All[0].All[0].All[10].InnerHtml; string result=""; for (int i = 0; i < html.Length; i++) { if (html[i] != '>') continue; i+=2; result = html[i].ToString() + html[i+1] + html[i+2] + html[i+3]; //MessageBox.Show(result); } int password=111111; doc.GetElementById("UserName").SetAttribute("value", "1234"); doc.GetElementById("uPassWord").SetAttribute("value", password.ToString()); doc.GetElementById("yianzhengma").SetAttribute("value", result); //yanzhengma.All[0].All[0].All[11].SetAttribute("value", code); doc.GetElementById("B1").InvokeMember("click"); //if (name != null) // name.SetAttribute("value", a.ToString()); //a++; //HtmlElement pass = doc.GetElementById("p"); //if (pass != null) // pass.SetAttribute("value", "123"); //HtmlElement login = webBrowser1.Document.GetElementById("login_button"); //if (login != null) // login.InvokeMember("click"); // Application.DoEvents(); //} } } }
解决 无用评论 打赏 举报
悬赏问题
- ¥15 关于#python#的问题:求帮写python代码
- ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
- ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
- ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
- ¥15 perl MISA分析p3_in脚本出错
- ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
- ¥15 ubuntu虚拟机打包apk错误
- ¥199 rust编程架构设计的方案 有偿
- ¥15 回答4f系统的像差计算
- ¥15 java如何提取出pdf里的文字?