[VB.NET Tutorial, Intermediate] Downloading a list and IO read it. menu

Shout-Out

User Tag List

Results 1 to 7 of 7
  1. #1
    Electricrain's Avatar Member
    Reputation
    8
    Join Date
    Aug 2009
    Posts
    8
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [VB.NET Tutorial, Intermediate] Downloading a list and IO read it.

    Overview.
    Welcome to yet another of my fine tutorials!
    This is a good method for downloading any lists you might find on the internet, and add each line into an variable. Useful for datamining, email-adress leeching, proxy-leeching and anything else you might want to leech.
    The method will treat any document as a textfile, so you will only be able to use it on things like txt, dat, html, xml, cab, ini, db and so on and forth.
    The way we read the data into the the variable can be applied on any file, especially useful in information-stealers (not copying, moving or modifying the file but READING it is way more undetectable than any other method). I mean, reading the data into a variable makes it impossible for the computer to associate it with the original file, and therefore any protection the original file might have.

    Example file.
    Our example file is the proxylist from Tubeincreaser located here.
    The code.
    A thing called "imports" are required. An import is a specific part of the .net library which we need to Include at the top of our code to load it. So in the very top of the code, before everything else, write:
    Code:
    Imports System.IO
    Imports System.Net.WebRequestMethods
    Imports System.Text.RegularExpressions
    Not all might be required, but including these 3 makes compitability with older versions of the .net framework more likely.

    Next, place a button on your form and in its button_click event, write:
    Code:
    If System.IO.File.Exists("C:\proxylist.txt") = True Then
                System.IO.File.Delete("C:\proxylist.txt")
    End If
    This will check for the file which we are about to create. Because it is a proxylist we want it to refresh on each download, and most textfiles are no larger than 750KB which makes this no problem.

    Continuing on the button click, just below the code we just made, we are going to use a "Try" expression. You should always use this expression when dealing with more complex file operations since it is less likely to glitch out. And if it does you will (most of the time) don't get any memory leaks:
    Code:
    Try
                My.Computer.Network.DownloadFile _
             ("http://www.tubeincreaser.com/proxylist.txt", _
              "C:\proxylist.txt")
    This saves the file from the http-address to your C:\ disc. You can name the saved file in anyway you want, does not have to be proxylist.txt.
    (If you explore Network.DownloadFile you will find that it works with FTP:// connections, and even have networkcredentials settings!)

    The next step of our Try expression will be:
    Code:
    Dim ioFile As New StreamReader("C:\proxylist.txt")
                Dim ioLine As String
                Dim ioLines As String
    ioFile = the variable that holds all data it can read from the file.
    ioLine = holds the individual line which is to be formatted.
    ioLines = holds all the text we loaded, and formatted.

    What we now are going to do is loading the file in raw data, formatting the raw data into a format with 1 ip & port on each line. Then we save the formatted data into a variable which we are going to use in the end!
    Code:
    ioLine = ioFile.ReadLine
                ioLines = ioLine
                While Not ioLine = ""
                    ioLine = ioFile.ReadLine
                    ioLines = ioLines & vbCrLf & ioLine
                End While
    While creates a loop until a certain condition is met, here the condition states that as long as the line read does NOT contain "" (AKA nothing), continue reading the lines.
    Look at this code and try understanding what parts of it refers to what parts of the paragraph above the code. If you do not understand what it does, go back and read it again!

    Let us examine the string that changes the read text:

    Code:
    ioLines = ioLines & vbCrLf & ioLine
    ioLines, the formatted data is adding itself before any other variables. If we would write ioLines = vbCrLf & ioLine the variable would be rewritten each time. By assigning its own value first, the other variables gets added onto that value. vbCrLf is VB's way of pressing enter when writing. So it first adds the old value. Then it changes the line. Then it adds the new value on the new line. Capich?

    And now we finish the Try expression with the Catch and End Try. Catch is, simplified, "if something unexpected happens".
    Code:
    Catch
                MsgBox("Failed to load proxylist. Are you connected to the internet?" & vbCrLf & "Also check if your firewall blocks this program.")
            End Try
    As you can see we give the user an informative error report. Not like the usual MS errors saying "There was a fault at memory adress 0cX74363". But advice on how the user might fix the error that occured. ALWAYS DO THIS, DAMNIT.(Or I will come after you )

    And we are done! But how do we use it?
    Add a richtextbox onto your form. name it RichTextBox_proxies.
    Code:
    RichTextBox_proxies.Text = ""
    RichTextBox_proxies.Text = ioLines
    And you will see that each time you click the button, the proxylist will be downloaded, saved to your computer, the RichTextbox cleared and the proxies loaded into the RichTextBox.
    There is an error in the part where the text is loaded into the textbox. But I'm not sayin'. And the VB editor won't say it either. But it is there!
    There is also some unnecessary parts, regarding obtaining the proxylist... we could skip some saving and go right to the using.
    You figure these out yourself, and you have learned way more than just copy/pasting code!

    :wave:

    [VB.NET Tutorial, Intermediate] Downloading a list and IO read it.
  2. #2
    namelessgnome's Avatar Contributor
    Reputation
    108
    Join Date
    May 2007
    Posts
    263
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Intermediate is an exaggeration, beginner is more like it. None the less a a good tutorial.

    However a few corrections are needed:

    "A thing called "imports" are required. An import is a specific part of the .net library which we need to Include at the top of our code to load it"

    Import means to import a namespace, the import statement has nothing to do with loading either.

    The reason for having namespaces is purely for avoiding conflicts if classes in two namespaces have the same name.

    Code:
    Catch
                MsgBox("Failed to load proxylist. Are you connected to the internet?" & vbCrLf & "Also check if your firewall blocks this program.")
            End Try
    Also avoid catching Exception as we what to handle all errors differently. If want to globally catch errors and crash after giving the user a message there is an event for that in the AppDomain.

    Don't use vbCrLf, use Environment.NewLine

    and when including newlines in strings I use '\n'

    Code:
    If System.IO.File.Exists("C:\proxylist.txt") = True Then
    If executes the If block, If the expression is true, in other words the = True is implicit and not needed
    Last edited by namelessgnome; 08-03-2009 at 01:24 PM. Reason: typo

  3. #3
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mmmm... I prefer my way.

    WebClient wc = new WebClient();
    string data = wc.DownloadString("url for proxy list");
    strin[] lines = data.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

    3 lines. Not 293849028.

    Also; WebProxy can take strings in the form of iport (0.0.0.0:0000)

  4. #4
    Electricrain's Avatar Member
    Reputation
    8
    Join Date
    Aug 2009
    Posts
    8
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, cool of you to post so many variations
    I am not going to edit the tutorial though, because if people start customizing it and changing the way it works they learn way more.

    And also because I'm lazy :P

  5. #5
    Vaqxine1's Avatar Member
    Reputation
    33
    Join Date
    Jul 2009
    Posts
    57
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use WebClient as well.
    I only use it in 2 programs though, my DDoS bot and a HWID checker for protecting my programs.

  6. #6
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Vaqxine1 View Post
    I use WebClient as well.
    I only use it in 2 programs though, my DDoS bot and a HWID checker for protecting my programs.
    You must have one shitty DDoS app then.

  7. #7
    Vaqxine1's Avatar Member
    Reputation
    33
    Join Date
    Jul 2009
    Posts
    57
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Apoc View Post
    You must have one shitty DDoS app then.
    Nah, it's awesome.
    The webclient part is for checking if the stealers should be on, if they're on then they use the php page to submit logs. Could have done most of it with IRC but this was easier since I already had it coded for a previous project.

Similar Threads

  1. [LIST] List and Reviews of the Best Forums/Website Hosts
    By Succy in forum World of Warcraft Emulator Servers
    Replies: 23
    Last Post: 04-08-2008, 08:40 PM
  2. Realm list and other stuff for amusement
    By tomit12 in forum World of Warcraft General
    Replies: 10
    Last Post: 11-08-2007, 06:58 AM
  3. Guides Lists and links
    By Dimmy353 in forum World of Warcraft Guides
    Replies: 14
    Last Post: 09-04-2007, 08:57 AM
  4. Rapidshare Unlimited Download Site list
    By Itachi69 in forum Community Chat
    Replies: 2
    Last Post: 09-01-2007, 02:15 PM
  5. Three tutorials!!! Under WSG, Under UC, and Barrens Highway!
    By Dathellen in forum World of Warcraft Exploration
    Replies: 11
    Last Post: 08-16-2007, 02:19 PM
All times are GMT -5. The time now is 10:42 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search