A webbrowser toy

Source: Internet
Author: User

I remember that when I went to college, a teacher only allowed the students to watch the slides he showed in class to prevent the students from not listening to the lectures. The examination content was exactly the content on the PPT, so when a classmate came to me, I used VB to write a PPT dedicated to stealing the instructor's USB flash drive.ProgramThe results saved countless lives. Those times have gone, and now will become the future.

Today, I received another "glorious and arduous" task. One student applied for a XX mailbox, but the password was forgotten. Another student often used brute force cracking to obtain the password, however, it is too slow, and the tool can only use 6 digits as the dictionary. Click "forgot password ?" The link needs to provide the previous birthday and prompt answer to the question provided to XX. He knows the answer to the question, but his birthday was entered at random.

Now the problem is simple. Just write a program and let the program automatically input the birthday value to XX for determination.

Well, this essay has no other intention. I just want to use this example to explain the usage of the webbrowser control in Visual Studio 2005. In the past, I wrote several articles about mshtml in my essay. It was in the. NET 1.1 era. Now it is much easier to do this.

Click the "forgot password" link, as shown in:

First, you need to use the navigate method of the webbrowser control (wbxxmain) to enter the first page:

String Strurl =   " Http://entry.XX.com/cgi/reg? Funcid = rpstart " ;
This . Wbxxmail. navigate (strurl );

Then, you need the user name to get the text box and fill it in automatically. In this case, you need to use the getelementbyid method of the Document Property of the webbrowser control to obtain the text box (the ID or name of the text box can be found by viewing the source file on the page), and use the setattribute method to specify the value attribute for the text box:

System. Windows. Forms. htmlelement heusername =   This . Wbxxmail. Document. getelementbyid ( " Username " );
Heusername. setattribute ( " Value " , This . Dsconfig. Tables [ " Config " ]. Rows [ 0 ] [ " Username " ]. Tostring ());

Next, you need to trigger the Click Event of the "OK" button to submit the value in the text box:

 

System. Windows. Forms. htmlelement hebtnusubmit =   This . Wbxxmail. Document. getelementbyid ( " Update. x " );
Hebtnusubmit. invokemember ( " Click " );

Same as above, http://entry.XX.com/cgi/reg on page? Funcid = rpbirthday, fill in the values in the year, month, and day text boxes, and trigger the Click Event of the "OK" button. Regardless of the year, month, day input is correct, will go to the page http://entry.XX.com/cgi/reg? Funcid = rpquestion. At this time, you can only judge whether the input is correct based on the content of the page. You can determine whether a "birthday error" is displayed in the body of the page:

If ( This . Wbxxmail. Document. Body. innerhtml. indexof ( " Birthday Error " ) ! =   - 1 )
{
//Birthday error. You can also use the Goback () method to return the start page.
StringStrurl= "Http://entry.XX.com/cgi/reg? Funcid = rpstart";
This. Wbxxmail. navigate (strurl );
}
Else
{
//Correct processing logic for birthday Input
}

OK. You can start loop processing. Slowly, we put all the logic in the documentcompleted event of the webbrowser control. Because the navigate method is called multiple times, the loop can be completed without loop statements (seeCode).

Source code download

I saved the User Name of the mailbox, the start and end dates of the last operation, and possible final results of the operation in the config file. if you are interested, you can change these parameters and try using your mailbox.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.