[VB.NET]Making a basic form-filling bot

Discussion in 'Archives' started by Hidden Dart, Jan 2, 2010.

[VB.NET]Making a basic form-filling bot
  1. Unread #1 - Jan 2, 2010 at 9:11 PM
  2. Hidden Dart
    Joined:
    Dec 16, 2008
    Posts:
    358
    Referrals:
    1
    Sythe Gold:
    0

    Hidden Dart Forum Addict
    Banned

    [VB.NET]Making a basic form-filling bot

    Hi,
    this guide will show you how to create a basic form filling bot. It will explain what the different parts of the code do and hopefully you will learn not just how to make a bot, but how to adapt it to most sites that you may need it for.

    You should have a basic - intermediate knowledge of VB.NET before using this guide, as it is okay to be able to copy it, but that has no real value. It would help more if you had enough of a knowledge to apply the things you learn in different areas.

    I will be re-creating my most successful bot, the Orange SIM bot. Myself and others have received THOUSANDS of SIMs. Personally, i received a total of about 8000 SIM packs (4 per pack). It was released on another site that was more form-filling bot based.

    Proof: http://i39.tinypic.com/29lcyld.jpg - Yes, that is 8 Royal Mail bags full of SIM packs. I think that is the greatest amount received to date, however i can not be certain. Now to show you how it was done.

    Step 1. Setting up your form.
    Set up your form however you want, but personally i went with a very compact style:
    [​IMG]
    You will also need to add a webbrowser, however, this does not need to be visible in the form. DO NOT SET VISIBLE TO FALSE! Simply move it out of the visible area.

    Another thing you have to add is an integer, call it "i". You will also need to create two Private Subs, called GO and RESTART. RESTART should simply contain the code to take the webbrowser to the page of the form. GO will be developed throughout the guide. Do this by adding the following to the code:
    Code:
     Dim i As Integer = 0
        Private Sub restart()
            WebBrowser1.Navigate("www.orange.co.uk/freesimcard")
        End Sub
    
        Private Sub GO()
        End Sub
    
    Step 2. Assigning a TextBox to a form element
    As you may have guessed, you will need to assign one of your textboxes to one of the textboxes on the web page. To do this, you need the web page's textbox IDs. You can find these by doing the following...

    Open up the source of the web page and search for one of the labels of the form. For example, "First Name". This will should take you down to the section of the source where the form's information is held. If it does not, then keep hitting enter until you reach that point.

    You will now want to look for something similar to this:
    Code:
    label class="desc">your first name: <span class="req">*</span></label>
    <input class="field text medium" type="text" name="firstname" value="" id="firstname"/>
    This will not be exactly the same for every different form, but they generally have similar types of input. The piece of information you want is the ID of the form's textbox. Look for the "id=". The text in quotes after "id=" is the ID of the element.

    Once you have found it, you want to add this to the GO sub:
    Code:
    WebBrowser1.Document.GetElementById("firstName").SetAttribute("value", TextBox1.Text)
    This basically means, set the text value of the First Name textbox to whatever is in textbox1.

    Now comes the boring part... You have to assign every textbox in the web form to a textbox or input in the windows form. This may take several minutes, but it is the most time consuming part of making the bot. The rest is fairly fast.

    You will also need to add this small piece of code to submit the form:
    Code:
    WebBrowser1.Document.Forms(0).InvokeMember("submit")
    ~~~Step 2.1. Assigning Radio Buttons to form elements.
    Radio buttons are fairly simple to do, but they require if statements, and occasionally a fair few. In this example, the form element's ID i will be using is "drpSim".

    Code:
            If RadioButton1.Checked = True Then WebBrowser1.Document.GetElementById("drpSim").SetAttribute("value", "1")
            If RadioButton2.Checked = True Then WebBrowser1.Document.GetElementById("drpSim").SetAttribute("value", "2")
            If RadioButton3.Checked = True Then WebBrowser1.Document.GetElementById("drpSim").SetAttribute("value", "3")
            If RadioButton4.Checked = True Then WebBrowser1.Document.GetElementById("drpSim").SetAttribute("value", "4")
    This simply means, if radiobutton X is selected, the value of the element should be X. So if the fourth radiobutton is selected, 4 SIM cards would be ordered.

    It is not necessary to use radiobuttons in this case, so you may want to use another method if you think it would work better and you think you could apply it.

    Step 3. Controlling the amount of submissions, using the progress bar and applying the "apartment trick".
    This section is optional, but highly suggested.

    The integer "i" is the main player in this section, as it is what will be used to track the amount of times a form has been submitted, and prevent it from ordering more than you want. It will also allow you to exploit some web forms, but this is not always necessary to order multiple times.

    To start, add the following code to the GO sub:
    Code:
    i += 1
    ToolStripStatusLabel1.Text = i & "/" & TextBox6.Text
    The first line adds one to "i". The second line makes the label in the status bar show "i", then / and then the number entered in the "How many SIMs do you want to order" textbox. This would show the number of SIMs ordered out of the total the user wanted to order. This will update every time the form is filled, as GO is the sub used to fill the form.

    To get the progress bar to be accurate, you will need to add the following to the GO sub:
    Code:
            ToolStripProgressBar1.Minimum = 0
            ToolStripProgressBar1.Maximum = TextBox6.Text
            ToolStripProgressBar1.Value = i
    This means that the progress bar will increase by 1 every time the form is submitted, and once the amount of times the user wanted the form to submit is reached, the progress bar will be full.

    To prevent the form from submitting more than the requested amount of times, add the following code to the webbrowser sub. This will also loop the submitting and prevent it from attempting to submit on any page other than the Orange SIM page:
    Code:
    If WebBrowser1.DocumentText.ToString().Contains("Just fill in the form below and we'll send you your SIM.") Then
                GO()
            ElseIf WebBrowser1.DocumentText.ToString().Contains("Your SIM Card will be with you shortly") Then
                restart()
            End If
    
            If i >= TextBox6.Text Then _
            WebBrowser1.Navigate("")
            If i >= TextBox6.Text Then _
            i = 0
            If i >= TextBox6.Text Then _
            ToolStripProgressBar1.Value = 0
            If i >= TextBox6.Text Then _
                MsgBox("Orders Complete.")
            If i >= TextBox6.Text Then _
            WebBrowser1.Navigate("about:blank")
    The first two If statements identify the pages by finding a part of text from the Orange SIM order page and the Orange SIM order complete page. This makes it able to identify when to fill the form, and when the form has been filled and submitted successfully. The webbrowser will be taken back to the order page if the order complete page is identified.

    The last four If statements reset the integer "i" to 0, alert the user with a pop up, take the web browser to a blank page to stop it submitting any more and reset the progress bar. All of this is done easily with the use of a few If statements.

    The apartment trick is simply done, just change the address section of the GO sub to have the textbox input and " apartment " and the value of "i", it should look like this:
    Code:
    WebBrowser1.Document.GetElementById("address2").SetAttribute("value", TextBox4.Text & " apartment " & i)
    This will bypass the one per address restrictions some websites have.

    If you need to generate random phone numbers, for this form you can use Environment.TickCount. This will fill in the box with a different number each time. It can also be used to generate random mailinator emails by using the following code for the email input value:
    Code:
    Environment.TickCount & "@mailinator.com"
    Step 4. Finishing up.
    The final piece of code to be added is the in the button1 sub. This is simply to start the form filling. This is extremely simple, just add:
    Code:
    RESTART()
    This will prompt the RESTART() sub, taking the webbrowser to the web page with the form. All from there will be determined by the initial input in the form.

    To test it, you need to debug it. To do this go to the Debug tab at the top of the screen and go to start debugging, as shown in this picture:
    [​IMG]

    After doing this, your .exe program will be found in the debug section of your project. This is shown in this picture:
    [​IMG]

    I hope this helps you out and you can make some bots of your own :)
     
  3. Unread #2 - Mar 2, 2010 at 8:33 PM
  4. Lukef555
    Joined:
    Aug 16, 2008
    Posts:
    3,206
    Referrals:
    6
    Sythe Gold:
    0

    Lukef555 Grand Master
    Banned

    [VB.NET]Making a basic form-filling bot

    Nice guide, ive made one myself but i also made one using this tut and it seems to work fairly well.

    7/10
     
< Always run files as administrators. (Recommended for Windows Vista). | ------$0.10 Lockerz Referral Service------- >

Users viewing this thread
1 guest


 
 
Adblock breaks this site