Results 1 to 16 of 16

Thread: [2005] Retrieve Remote IP Address

  1. #1

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    55

    [2005] Retrieve Remote IP Address

    Hello everyone! I've looked through all the elements under System.Net.NetworkInformation and I can't seem to find a way to retrieve the client's remote IP address. May someone please explain to me how? Thank you very much!
    Last edited by getlowdogg369; Mar 4th, 2007 at 04:43 PM. Reason: Added 2005 Prefix

  2. #2

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    55

    Re: [2005] Retrieve Remote IP Address

    Hello again! I've tried the following code, but TextBox4 was blank.
    VB Code:
    1. For Each tcpConnection As TcpConnectionInformation In IPGlobalProperties.GetIPGlobalProperties.GetActiveTcpConnections
    2.             TextBox4.Text = tcpConnection.RemoteEndPoint.Address.ToString()
    3.         Next

  3. #3

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    55

    Re: [2005] Retrieve Remote IP Address

    Bump! I've been doing research for hours and I still can't find anything! I only found topics relating to retrieving local IP addresses (192.168.x.x). How do I retrieve a remote IP address? If you don't know what I mean by remote IP address, it's the IP address that IP Chicken provides you. Thank you very much!

  4. #4
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: [2005] Retrieve Remote IP Address

    Quote Originally Posted by getlowdogg369
    Bump! I've been doing research for hours and I still can't find anything! I only found topics relating to retrieving local IP addresses (192.168.x.x). How do I retrieve a remote IP address? If you don't know what I mean by remote IP address, it's the IP address that IP Chicken provides you. Thank you very much!
    Cheap way is to have a browser go to www.whatismyip.org and read the document. Don't know how to do it any other way.

  5. #5

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    55

    Re: [2005] Retrieve Remote IP Address

    Quote Originally Posted by high6
    Cheap way is to have a browser go to www.whatismyip.org and read the document. Don't know how to do it any other way.
    It must be in Visual Basic 2005. This is because I'm making a banning system. Anyone else...?

  6. #6
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: [2005] Retrieve Remote IP Address

    Quote Originally Posted by getlowdogg369
    It must be in Visual Basic 2005. This is because I'm making a banning system. Anyone else...?
    You can do that in vb 2005...

  7. #7

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    55

    Re: [2005] Retrieve Remote IP Address

    Quote Originally Posted by high6
    You can do that in vb 2005...
    I can? Great! Do you know how...? If not, I have an alternative idea. What if I retrieved the source code of the website you posted. There is nothing within the source code but the IP address, so yea...

  8. #8
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: [2005] Retrieve Remote IP Address

    Quote Originally Posted by getlowdogg369
    I can? Great! Do you know how...? If not, I have an alternative idea. What if I retrieved the source code of the website you posted. There is nothing within the source code but the IP address, so yea...

    Code:
    Imports System.Net
    Imports System.Text.Encoding
    
            TextBox1.Text = Nothing
            Dim tcp As New Sockets.Socket(Sockets.AddressFamily.InterNetwork, Sockets.SocketType.Raw, Sockets.ProtocolType.Raw)
            tcp.Connect(TextBox2.Text, 80)
            If tcp.Connected = False Then Exit Sub
            tcp.Send(ASCII.GetBytes("GET / HTTP/1.0" & vbCrLf & vbCrLf))
            Dim buf(1024) As Byte
            Dim bytes As Int32 = tcp.Receive(buf, 1024, 0)
            TextBox1.Text &= ASCII.GetString(buf, 0, bytes)
            Do While bytes > 0
                bytes = tcp.Receive(buf, 1024, 0)
                TextBox1.Text &= ASCII.GetString(buf, 0, bytes)
            Loop

  9. #9
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] Retrieve Remote IP Address

    That would give him his IP. Im assuming, by looking at the code that he provided, that he wants to retrieve the IP adresses of all active connections on the PC.

    The code you wrote should be working, but try this and see if any IP adresses are showing:
    VB Code:
    1. For Each tcpConnection As TcpConnectionInformation In IPGlobalProperties.GetIPGlobalProperties.GetActiveTcpConnections
    2.             MessageBox.Show(tcpConnection.RemoteEndPoint.Address.ToString())
    3.         Next
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  10. #10

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    55

    Re: [2005] Retrieve Remote IP Address

    Quote Originally Posted by high6
    Code:
    Imports System.Net
    Imports System.Text.Encoding
    
            TextBox1.Text = Nothing
            Dim tcp As New Sockets.Socket(Sockets.AddressFamily.InterNetwork, Sockets.SocketType.Raw, Sockets.ProtocolType.Raw)
            tcp.Connect(TextBox2.Text, 80)
            If tcp.Connected = False Then Exit Sub
            tcp.Send(ASCII.GetBytes("GET / HTTP/1.0" & vbCrLf & vbCrLf))
            Dim buf(1024) As Byte
            Dim bytes As Int32 = tcp.Receive(buf, 1024, 0)
            TextBox1.Text &= ASCII.GetString(buf, 0, bytes)
            Do While bytes > 0
                bytes = tcp.Receive(buf, 1024, 0)
                TextBox1.Text &= ASCII.GetString(buf, 0, bytes)
            Loop
    The program frozed up when I used the code.
    Quote Originally Posted by Atheist
    That would give him his IP. Im assuming, by looking at the code that he provided, that he wants to retrieve the IP adresses of all active connections on the PC.

    The code you wrote should be working, but try this and see if any IP adresses are showing:
    VB Code:
    1. For Each tcpConnection As TcpConnectionInformation In IPGlobalProperties.GetIPGlobalProperties.GetActiveTcpConnections
    2.             MessageBox.Show(tcpConnection.RemoteEndPoint.Address.ToString())
    3.         Next
    I just want to retrieve the remote IP address. Nothing else. If you don't know what I mean by remote IP address, it's the IP address the IP Chicken provides you. Also, your code is providing me with 3 different IP addresses. None of which are my remote IP address.

  11. #11
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: [2005] Retrieve Remote IP Address

    Quote Originally Posted by getlowdogg369
    The program frozed up when I used the code.

    I just want to retrieve the remote IP address. Nothing else. If you don't know what I mean by remote IP address, it's the IP address the IP Chicken provides you. Also, your code is providing me with 3 different IP addresses. None of which are my remote IP address.
    you probably used it wrong. imports goes up top and textbox2 is the host(www.whatismyip.org), textbox1 is where its pasted(remote ip).

  12. #12

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    55

    Re: [2005] Retrieve Remote IP Address

    Quote Originally Posted by high6
    you probably used it wrong. imports goes up top and textbox2 is the host(www.whatismyip.org), textbox1 is where its pasted(remote ip).
    vb Code:
    1. Imports System.Net
    2. Imports System.Text.Encoding
    3.  
    4. Public Class Form1
    5.  
    6.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    7.         TextBox1.Text = Nothing
    8.         Dim tcp As New Sockets.Socket(Sockets.AddressFamily.InterNetwork, Sockets.SocketType.Raw, Sockets.ProtocolType.Raw)
    9.         tcp.Connect(TextBox2.Text, 80)
    10.         If tcp.Connected = False Then Exit Sub
    11.         tcp.Send(ASCII.GetBytes("GET / HTTP/1.0" & vbCrLf & vbCrLf))
    12.         Dim buf(1024) As Byte
    13.         Dim bytes As Int32 = tcp.Receive(buf, 1024, 0)
    14.         TextBox1.Text &= ASCII.GetString(buf, 0, bytes)
    15.         Do While bytes > 0
    16.             bytes = tcp.Receive(buf, 1024, 0)
    17.             TextBox1.Text &= ASCII.GetString(buf, 0, bytes)
    18.         Loop
    19.     End Sub
    20. End Class
    That's my exact code straight out of the program. Also, I'm not receiving any errors/warnings. I've typed "www.google.com" without the quotes into TextBox2 and it still frozed. Also, how does this give the client his/her computer's remote IP address? I just want it to do basically the same as IP Chicken or www.whatismyip.org.

  13. #13
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: [2005] Retrieve Remote IP Address

    Quote Originally Posted by getlowdogg369
    vb Code:
    1. Imports System.Net
    2. Imports System.Text.Encoding
    3.  
    4. Public Class Form1
    5.  
    6.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    7.         TextBox1.Text = Nothing
    8.         Dim tcp As New Sockets.Socket(Sockets.AddressFamily.InterNetwork, Sockets.SocketType.Raw, Sockets.ProtocolType.Raw)
    9.         tcp.Connect(TextBox2.Text, 80)
    10.         If tcp.Connected = False Then Exit Sub
    11.         tcp.Send(ASCII.GetBytes("GET / HTTP/1.0" & vbCrLf & vbCrLf))
    12.         Dim buf(1024) As Byte
    13.         Dim bytes As Int32 = tcp.Receive(buf, 1024, 0)
    14.         TextBox1.Text &= ASCII.GetString(buf, 0, bytes)
    15.         Do While bytes > 0
    16.             bytes = tcp.Receive(buf, 1024, 0)
    17.             TextBox1.Text &= ASCII.GetString(buf, 0, bytes)
    18.         Loop
    19.     End Sub
    20. End Class
    That's my exact code straight out of the program. Also, I'm not receiving any errors/warnings. I've typed "www.google.com" without the quotes into TextBox2 and it still frozed. Also, how does this give the client his/her computer's remote IP address? I just want it to do basically the same as IP Chicken or www.whatismyip.org.
    Code:
    Dim tcp As New Sockets.Socket(Sockets.AddressFamily.InterNetwork, Sockets.SocketType.Stream, Sockets.ProtocolType.Tcp)
    forgot I changed it when messing around.

  14. #14

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    55

    Re: [2005] Retrieve Remote IP Address

    Quote Originally Posted by high6
    Code:
    Dim tcp As New Sockets.Socket(Sockets.AddressFamily.InterNetwork, Sockets.SocketType.Stream, Sockets.ProtocolType.Tcp)
    forgot I changed it when messing around.
    Aghh! I think they blocked it out!
    HTTP/1.1 200 OK
    Connection: close
    Content-Length: 159
    Date: Mon, 05 Mar 2007 02:02:22 GMT
    Content-Type: text/plain
    Server: AOLserver/4.0
    MIME-Version: 1.0

    Error: blank User-Agent header is not allowed! Please ask the author of your IP address checking client to specify their client's name in the User-Agent header
    It works fine with Google!
    HTTP/1.0 200 OK
    Cache-Control: private
    Content-Type: text/html
    Set-Cookie: PREF=ID=cefed278a818f1ac:TM=1173059501:LM=1173059501:S=dpa82SYisptIk_WP; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com
    Server: GWS/2.1
    Date: Mon, 05 Mar 2007 01:51:41 GMT
    Connection: Close

    <html>
    <head>
    ...
    </head>
    <body>
    ...
    </body>
    </html>
    Ahh, well... Does anyone else know any way to retrieve the remote IP address of the client's computer?

  15. #15
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: [2005] Retrieve Remote IP Address

    Quote Originally Posted by getlowdogg369
    Aghh! I think they blocked it out!

    It works fine with Google!

    Ahh, well... Does anyone else know any way to retrieve the remote IP address of the client's computer?
    Just change the packet being sent to.

    Code:
    tcp.Send(ASCII.GetBytes("GET / HTTP/1.0" & vbCrLf & "User-Agent: FireFox" & vbCrLf & vbCrLf))
    also the first packet is gonna be all that data, the second one will contain the IP.

  16. #16

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    55

    Re: [2005] Retrieve Remote IP Address

    Quote Originally Posted by high6
    Just change the packet being sent to.

    Code:
    tcp.Send(ASCII.GetBytes("GET / HTTP/1.0" & vbCrLf & "User-Agent: FireFox" & vbCrLf & vbCrLf))
    also the first packet is gonna be all that data, the second one will contain the IP.
    Yes, it works! One more question... How do I make it so it doesn't retrieve the headers? The following is the headers incase you didn't know...
    HTTP/1.1 200 OK
    Connection: close
    Content-Length: 13
    Date: Mon, 05 Mar 2007 02:12:40 GMT
    Content-Type: text/plain
    Server: AOLserver/4.0
    MIME-Version: 1.0
    How would I make it at least retrieve the last line? Thank you very much!
    Last edited by getlowdogg369; Mar 4th, 2007 at 09:22 PM.

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