Results 1 to 4 of 4

Thread: [RESOLVED] Using proxy with WebClient

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2011
    Location
    England
    Posts
    421

    Resolved [RESOLVED] Using proxy with WebClient

    Hi, I am looking into using a proxy with the WebClient.

    The code I am trying is:
    VB.NET Code:
    1. Using WClient As New WebClient
    2.     WClient.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)")
    3.  
    4.     Dim WProxy As New WebProxy("<IP>:<Port>")
    5.     WClient.Proxy = WProxy
    6.  
    7.     'I am using this website to test the current IP
    8.     MessageBox.Show(Encoding.UTF8.GetString(WClient.DownloadData("http://checkip.dyndns.org/")))
    9. End Using
    When I retrieve my IP from dyndns using the MessageBox above it is showing my own IP. Some of the proxy IP's I have tested use https so I also tried the code below:
    VB.NET Code:
    1. Private Shared Function BypassCertificate(ByVal sender As Object, ByVal cert As X509Certificate, ByVal chain As X509Chain, ByVal [error] As System.Net.Security.SslPolicyErrors) As Boolean
    2.     Return True
    3. End Function
    4.  
    5. Private Sub TestProxy()
    6.     ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(AddressOf BypassCertificate)
    7.     Using WClient As New WebClient
    8.         WClient.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)")
    9.  
    10.         Dim WProxy As New WebProxy("<IP>:<Port>")
    11.         WClient.Proxy = WProxy
    12.  
    13.         MessageBox.Show(Encoding.UTF8.GetString(WClient.DownloadData("http://checkip.dyndns.org/")))
    14.     End Using
    15. End Sub
    However I still get the same result.

    Am I doing this wrong? Or could it be that the proxy is working but that the IP lookup websites look beyond the proxy back to the source? If so, how would I test that it is working?

    Thanks
    Jay

  2. #2
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: Using proxy with WebClient

    My IP 86.9.199.38 Proxy <html><head><title>Current IP Check</title></head><body>Current IP Address: 64.78.30.2</body></html>

    vb Code:
    1. Imports System.Net
    2. Imports System.Text
    3.  
    4. Public Class Form1
    5.     Private Sub TestProxy()
    6.  
    7.         Dim proxy As New WebProxy("64.78.30.180:80")
    8.  
    9.         Using wClient As New WebClient
    10.             wClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0")
    11.             wClient.Proxy = proxy
    12.  
    13.             Try
    14.                 Me.RichTextBox1.Text = String.Format("My IP 86.9.199.38 Proxy {0}",
    15.                                                  wClient.DownloadString(New Uri("http://checkip.dyndns.org/")))
    16.             Catch ex As Exception
    17.                 MessageBox.Show(ex.Message)
    18.             End Try
    19.         End Using
    20.     End Sub
    21.  
    22. End Class
    My Github - 1d3nt

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2011
    Location
    England
    Posts
    421

    Re: Using proxy with WebClient

    Your absolutely right. It seems there is nothing wrong with that code but rather the proxies I had tried. The site I grabbed them from has Transparent and Anonymous proxies. All my tests so far had been grabbing the Transparent ones.

    Thanks for checking.

  4. #4
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: [RESOLVED] Using proxy with WebClient

    I was going to suggest make sure your proxy is not transparent. http://spys.ru/en/ Good luck.
    My Github - 1d3nt

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width