今天偶然发现我们学校的出校访问网页是数字验证码,于是想拿来破解。思路就是普通的抓取元素,然后填入表单,然后发现一切顺利,账号密码和验证码都填进去了。然后登陆发现
永远提示验证码错误,郁闷啊,手动输入也是验证码错误,但是在浏览器内是可以使用的,不知道问题在哪里
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 寻一个支付宝扫码远程授权登录的软件助手app
- ¥15 解riccati方程组
- ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
- ¥30 用arduino开发esp32控制ps2手柄一直报错
- ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
- ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
- ¥50 树莓派安卓APK系统签名
- ¥65 汇编语言除法溢出问题
- ¥15 Visual Studio问题
- ¥20 求一个html代码,有偿