Results 1 to 1 of 1
  1. #1
    Remy is offline
    New member
    Join Date
    2013 May
    Thanked 0 Times in 0 Posts
    Rep Power

    Releasing my simple HTTPWrapper

    I coded this a while back and decided to release it here.

    wrapper with between function:
    Public Class Wrapper
    Public CC As New CookieContainer()
        Dim responseData As String = ""
        Function WebRequest(ByRef HTML As String, URL As String, _
                            method As String, POSTdata As String, _
                            Referer As String) As String
                Dim hwrequest As Net.HttpWebRequest = Net.WebRequest.Create(URL)
                hwrequest.Accept = "*/*"
                hwrequest.AllowAutoRedirect = True
                hwrequest.UserAgent = "Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:16.0.1) Gecko/20121011 Firefox/16.0.1" 'Emulates Firefox as Agent for stealth
                hwrequest.Timeout = 60000
                hwrequest.Method = method
                hwrequest.KeepAlive = "True" 'Keeps Session Alive
                hwrequest.CookieContainer = CC 'Holds cookies, for logins etc
                hwrequest.Referer = Referer 'Simulate genuine request
                If hwrequest.Method = "POST" Then
                    hwrequest.ContentType = "application/x-www-form-urlencoded"
                    Dim encoding As New System.Text.UTF8Encoding 'Use UTF8Encoding for XML requests
                    Dim postByteArray() As Byte = encoding.GetBytes(POSTdata)
                    hwrequest.ContentLength = postByteArray.Length
                    Dim postStream As IO.Stream = hwrequest.GetRequestStream()
                    postStream.Write(postByteArray, 0, postByteArray.Length)
                    Dim postResponse As HttpWebResponse
                    postResponse = DirectCast(hwrequest.GetResponse, HttpWebResponse)
                    CC.Add(postResponse.Cookies) 'Adds Cookie to Container
                End If
                Dim hwresponse As Net.HttpWebResponse = hwrequest.GetResponse()
                If hwresponse.StatusCode = Net.HttpStatusCode.OK Then
                    Dim responseStream As IO.StreamReader = _
                      New IO.StreamReader(hwresponse.GetResponseStream())
                    responseData = responseStream.ReadToEnd()
                    HTML = responseData
                End If
            Catch e As Exception
                responseData = "An error occurred: " & e.Message
            End Try
            Return responseData
        End Function
    Function Between(ByVal Input As String, ByVal StrStart As String, ByVal StrEnd As String, Optional ByVal Offset As Int32 = 0) As String
            If (Len(Input) = 0) Then
                Return vbNullString
            End If
            Dim Pos1 As Int32 = Input.IndexOf(StrStart, Offset) + Len(StrStart)
            If (Pos1 <> -1) Then
                Dim Pos2 As Int32 = Input.IndexOf(StrEnd, Pos1) - Pos1
                If (Pos2 <> -1) Then
                    Return Input.Substring(Pos1, Pos2)
                End If
            End If
            Return vbNullString
        End Function
    End Class
    This is for basically making HTTP web bots, can be used to login sites and such.
    Cannot be used on HTTPS sites, i haven't figured out how to make a wrapper for that yet or how to decrypt the data.

    GET, Webrequest(String, URL, "GET", "", "Refferer")
    Now lets pretend i'm making a login code for maybe a validation for one of my programs.
    in order to use the wrapper we need to declare it in our class
    Dim wrapper As New Wrapper
    We would first need to declares some strings, and send a "GET" request like this:

    dim html, user, pass, token as string.
    wrapper.webrequest(html,"", "GET", "" ,"")
    'We need to visit this page because said site has a dynamic token on page load that validates login.
    Now that is done we need to fish out the token using our between function, you would add something like this:
    token = wrapper.Between(html, "<token>", "</token>") 
    'Our between function grabs a string between two constants generated in a page.
    Now assuming we have the user info we could log in:
    wrapper.WebRequest(html, "", "POST", "token=" & token & "user=" & user & "pass=" & pass,"")
    'use & to put together text and strings, Also use post to post Data.
    Almost done, generally there is a unique string of text in a webpage when a user is logged into a site, lets pretend on the home page where you login there is a link to a user control panel that isn't there when logged out.:
    wrapper.WebRequest(html, "", "GET", "", "")
    If InStr(html, "Control Panel") Then
                MsgBox("logged in!")
            End If
    'This tells us if the login was a success.

Similar Threads

  1. [C++] How to make a simple bot
    By Dwar in forum Programming Tutorials
    Replies: 3
    Last Post: 2014-10-04, 12:53 PM
  2. [Tutorial] Bot simple fishing, using wpe indetectable
    By christoff in forum Aika Bots, Hacks, Cheats
    Replies: 28
    Last Post: 2012-06-08, 03:58 AM
  3. [Tutorial] Simple way to profit from gold in NPC
    By Yoshi- in forum Aika Guides, Tutorials
    Replies: 3
    Last Post: 2012-01-21, 03:51 PM
  4. [Release] Simple ASM Injector
    By pohkak in forum Files & Tools
    Replies: 1
    Last Post: 2012-01-07, 05:22 PM
Visitors found this page by searching for:


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts