[REQ] Vb.net proxy tutorial

hornetss

Make Money Online
Joined
Nov 13, 2009
Messages
60
Reaction score
0
Points
0
Age
28
I can't seem to find a tutorial anywhere on setting up a proxy with vb.NET.

If anybody here can post a tutorial on how to test, and connect to a proxy, it would great.


Thanks,
Hornetss
 

High Definition

Make Money Online
Joined
Mar 14, 2010
Messages
18
Reaction score
0
Points
0
Location
127.0.0.1
LMAO..Its not "vBulletin.Net", its "Visual Basic.NET" .......

Anyways, here's one way how to do it..

Code:
Public Structure Struct_PROXY
        Public dwAccessType As Integer
        Public proxy As IntPtr
        Public pxyby As IntPtr
    End Structure

    Private Declare Auto Function InternetSetOption Lib "wininet.dll" (ByVal hInternet As IntPtr, ByVal dwOption As Integer, ByVal lpBuffer As IntPtr, ByVal lpdwBufferLength As Integer) As Boolean

    Private Sub refreshproxy(ByVal strProxy As String)
        Const IOProxy As Integer = 38
        Const IProxy As Integer = 3
        Dim st_SP As Struct_PROXY

        st_SP.dwAccessType = IProxy
        st_SP.proxy = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(strProxy)
        st_SP.pxyby = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi("Global")

        Dim intptrStruct As IntPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(st_SP))
        System.Runtime.InteropServices.Marshal.StructureToPtr(st_SP, intptrStruct, True)
        InternetSetOption(IntPtr.Zero, IOProxy, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(st_SP))

    End Sub

Usage:

Code:
refreshproxy("IP:PORT")



If this seems more complicated to you there is an easy way also...:p
 

hornetss

Make Money Online
Joined
Nov 13, 2009
Messages
60
Reaction score
0
Points
0
Age
28
LMAO..Its not "vBulletin.Net", its "Visual Basic.NET" .......

Anyways, here's one way how to do it..

Code:
Public Structure Struct_PROXY
        Public dwAccessType As Integer
        Public proxy As IntPtr
        Public pxyby As IntPtr
    End Structure

    Private Declare Auto Function InternetSetOption Lib "wininet.dll" (ByVal hInternet As IntPtr, ByVal dwOption As Integer, ByVal lpBuffer As IntPtr, ByVal lpdwBufferLength As Integer) As Boolean

    Private Sub refreshproxy(ByVal strProxy As String)
        Const IOProxy As Integer = 38
        Const IProxy As Integer = 3
        Dim st_SP As Struct_PROXY

        st_SP.dwAccessType = IProxy
        st_SP.proxy = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(strProxy)
        st_SP.pxyby = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi("Global")

        Dim intptrStruct As IntPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(st_SP))
        System.Runtime.InteropServices.Marshal.StructureToPtr(st_SP, intptrStruct, True)
        InternetSetOption(IntPtr.Zero, IOProxy, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(st_SP))

    End Sub
Usage:

Code:
refreshproxy("IP:PORT")
If this seems more complicated to you there is an easy way also...:p
Nice, thanks.

It replaces vb .net to vbulletin.net
 

hornetss

Make Money Online
Joined
Nov 13, 2009
Messages
60
Reaction score
0
Points
0
Age
28
oh..Word sensor, alright..
Hey I'm making a proxy checker but I can't seem to figure out how to make this time out after an X amount of seconds.

Code:
        For Each ip In TextBox1.Lines
            refreshproxy(ip)
            WebBrowser1.Navigate("http://google.com")

            While WebBrowser1.ReadyState <> WebBrowser1.ReadyState.Complete
                Application.DoEvents()
            End While

            If WebBrowser1.Document.Body.InnerHtml.Contains("<TEXTAREA") Then
                ListBox1.Items.Add(ip)
            End If

        Next
 

High Definition

Make Money Online
Joined
Mar 14, 2010
Messages
18
Reaction score
0
Points
0
Location
127.0.0.1
Hey I'm making a proxy checker but I can't seem to figure out how to make this time out after an X amount of seconds.

Code:
        For Each ip In TextBox1.Lines
            refreshproxy(ip)
            WebBrowser1.Navigate("http://google.com")

            While WebBrowser1.ReadyState <> WebBrowser1.ReadyState.Complete
                Application.DoEvents()
            End While

            If WebBrowser1.Document.Body.InnerHtml.Contains("<TEXTAREA") Then
                ListBox1.Items.Add(ip)
            End If

        Next
You need to specify the port number also to use it..

And you can add a timer to accomplish it..Like suppose

timer1.interval=(6000 * 20)
timer1.start()

If you receive the reply under those 20 seconds the proxy is good else proxy is bad..

I used 6000 * 20 because timer takes the inputs in milliseconds..So its wise to first convert it into second so multiplying it with 6000
 

Hydrogen2012

Make Money Online
Joined
Dec 29, 2009
Messages
180
Reaction score
0
Points
0
Location
Down in a Hole
Website
www.advertmarketing.com
Unless you have to, I'd stay away from the browser control. A much more accruate and efficent way to go about this would be to use the HTTPWEBRequest functions it's much more stable and will speed up your application dramatically and then using a proxy is much more easier then the Hack shown above (which by the way, is the only way to change the browser proxy) It's ugly as hell but is the way to go about it.

If you decide to switch and go to the httpwebrequest route then this is how you specify a proxy using that.

Code:
                    Dim IP as string = "192.168.1.1"
                    Dim Port as string = "80"
                    Dim proxy As New WebProxy(IP & ":" & Port, True)  ' True = Bypass on Local IPs/Domains
                    objWebRequest.Proxy = proxy  ' objWebRequest would be setup before all this and contain your httpwebrequest
 

syanide

Make Money Online
Joined
Jan 7, 2010
Messages
9
Reaction score
0
Points
0
or even use the webclient class.. It's a wrapper for the httpwebrequest object
 

hornetss

Make Money Online
Joined
Nov 13, 2009
Messages
60
Reaction score
0
Points
0
Age
28
Thanks for the help guys, but using the web browser code, how do I switch back to a direct connection?
 

scottmobster

Make Money Online
Joined
Jan 5, 2010
Messages
27
Reaction score
0
Points
0
Age
47
No one ever answered how to switch back for you. It doesn't save the IP... so when you unload the w b control, it will revert to the default windows settings, if that has no IP, then that would accomplish your goal.
 

yesrams

Make Money Online
Joined
May 3, 2010
Messages
20
Reaction score
0
Points
0
Age
45
I am searching for this.. Thank you for examples.
 

MarkusJNZ

Make Money Online
Joined
May 12, 2010
Messages
6
Reaction score
0
Points
0
Hi, slightly off topic but if you want to use a timer to see how long a process has run there is a StopWatch object in the System.Diagnostics namespace, it works a treat for seeing how long processes are taking.

Cheers
Mark
 

Hydrogen2012

Make Money Online
Joined
Dec 29, 2009
Messages
180
Reaction score
0
Points
0
Location
Down in a Hole
Website
www.advertmarketing.com
Hi, slightly off topic but if you want to use a timer to see how long a process has run there is a StopWatch object in the System.Diagnostics namespace, it works a treat for seeing how long processes are taking.

Cheers
Mark
1.) Spawn a Timer Control
2.) Set Interval to 1000 (1000ms = 1second)
3.) Enable Timer when thread starts
4.) Each tick increment a Integer in your thread you have set for timing
5.) When thread is ending Disable the Timer and output the result of Integer where ever you need it.
 

dkaiser81

Make Money Online
Joined
Dec 8, 2010
Messages
1
Reaction score
0
Points
0
Thanks for the help guys, but using the web browser code, how do I switch back to a direct connection?
Here is the code to switch back to a direct connection.

Code:
refreshProxy(":")
:top: