|
-
Mar 4th, 2007, 04:37 PM
#1
Thread Starter
Member
[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
-
Mar 4th, 2007, 05:05 PM
#2
Thread Starter
Member
Re: [2005] Retrieve Remote IP Address
Hello again! I've tried the following code, but TextBox4 was blank.
VB Code:
For Each tcpConnection As TcpConnectionInformation In IPGlobalProperties.GetIPGlobalProperties.GetActiveTcpConnections
TextBox4.Text = tcpConnection.RemoteEndPoint.Address.ToString()
Next
-
Mar 4th, 2007, 07:29 PM
#3
Thread Starter
Member
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!
-
Mar 4th, 2007, 07:32 PM
#4
Frenzied Member
Re: [2005] Retrieve Remote IP Address
 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.
-
Mar 4th, 2007, 07:37 PM
#5
Thread Starter
Member
Re: [2005] Retrieve Remote IP Address
 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...?
-
Mar 4th, 2007, 07:44 PM
#6
Frenzied Member
Re: [2005] Retrieve Remote IP Address
 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...
-
Mar 4th, 2007, 07:47 PM
#7
Thread Starter
Member
Re: [2005] Retrieve Remote IP Address
 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...
-
Mar 4th, 2007, 07:57 PM
#8
Frenzied Member
Re: [2005] Retrieve Remote IP Address
 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
-
Mar 4th, 2007, 08:00 PM
#9
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:
For Each tcpConnection As TcpConnectionInformation In IPGlobalProperties.GetIPGlobalProperties.GetActiveTcpConnections
MessageBox.Show(tcpConnection.RemoteEndPoint.Address.ToString())
Next
-
Mar 4th, 2007, 08:13 PM
#10
Thread Starter
Member
Re: [2005] Retrieve Remote IP Address
 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.
 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:
For Each tcpConnection As TcpConnectionInformation In IPGlobalProperties.GetIPGlobalProperties.GetActiveTcpConnections
MessageBox.Show(tcpConnection.RemoteEndPoint.Address.ToString())
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.
-
Mar 4th, 2007, 08:29 PM
#11
Frenzied Member
Re: [2005] Retrieve Remote IP Address
 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).
-
Mar 4th, 2007, 08:40 PM
#12
Thread Starter
Member
Re: [2005] Retrieve Remote IP Address
 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:
Imports System.Net
Imports System.Text.Encoding
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
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
End Sub
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.
-
Mar 4th, 2007, 08:45 PM
#13
Frenzied Member
Re: [2005] Retrieve Remote IP Address
 Originally Posted by getlowdogg369
vb Code:
Imports System.Net
Imports System.Text.Encoding
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
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
End Sub
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.
-
Mar 4th, 2007, 09:04 PM
#14
Thread Starter
Member
Re: [2005] Retrieve Remote IP Address
 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?
-
Mar 4th, 2007, 09:08 PM
#15
Frenzied Member
Re: [2005] Retrieve Remote IP Address
 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.
-
Mar 4th, 2007, 09:15 PM
#16
Thread Starter
Member
Re: [2005] Retrieve Remote IP Address
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|