hi all, I am curently making a server authentication program for authenticating a users IP address but i have no idea how to code the most vital part of the process ie. the programs ability to change the source IP of a packet from what it should be to form part of the validation key.
does anyone know any code or libery that i could use?
-GP-
Here is a sample from one of my projects, we can derive a method of "ip validation" here in a minute from this:
Private Sub objTCPServer_ConnectionRequest(ByVal requestID As Long)
Dim intReturn As Integer
intReturn = AvailableSocket()
If (intReturn > 0) Then
If (objClientCollection.Add(objClient(intReturn), objUDPServer, objTCPServer.RemoteHostIP) Is Nothing = False) Then
objClient(intReturn).Accept requestID
End If
Else
If ((objClient.UBound - 1) < m_intSocketMaximum) Then
intReturn = objClient.UBound + 1
Load objClient(intReturn)
If (objClientCollection.Add(objClient(intReturn), objUDPServer, objTCPServer.RemoteHostIP) Is Nothing = False) Then
objClient(intReturn).Accept requestID
End If
End If
End If
End Sub
allrighty then, here we go:
Private Sub objTCPServer_ConnectionRequest(ByVal requestID As Long)
If( IPValidationFunction(objTCPServer.RemoteHostIP) = True) then
'accept connection
Else
'reject connection
End If
End Sub
IPValidationFunction would probably look up that ip in a database of some sort or a list and see if it's validated or not.
Quote from: TheMinistered on February 02, 2006, 01:23 PM
Private Sub objTCPServer_ConnectionRequest(ByVal requestID As Long)
If( IPValidationFunction(objTCPServer.RemoteHostIP) = True) then
'accept connection
Else
'reject connection
End If
End Sub
??? OMG how stupid do you think i am?!??!?!? ???
/slaps TheMinistered
right no iv got that out of my system... just incase you missed my point ill spell it out:
I need help re-packaging or crafting custom packets to be sent to the server
spesificly addressing changing of the ip addresslol now can the next posters asume im not a complete n00b please /begs
-GP-
Because -GP- can apparently barely speak English, I'm going to make a guess. I think what he wants to do is edit the packet on a raw level and mess with the IP header structure to change the source address. But unless he learns how to write more proficiently, I doubt anyone will be able to help him.
Quote from: TehUser on February 03, 2006, 02:30 PM
Because -GP- can apparently barely speak English, I'm going to make a guess. I think what he wants to do is edit the packet on a raw level and mess with the IP header structure to change the source address. But unless he learns how to write more proficiently, I doubt anyone will be able to help him.
Hehe, so im not the only one who can hardly read it then :)
Im unsure if hes making his own server, and making some kind of IP auth for it, or if hes trying to write a client for a server which has some kind of IP auth.
And if the server is TCP or UDP or somthing else.
sendto() in the winsock api might be helpfull (Please dont /slap me for taking a guess)
Private Type sockaddr_in
sin_family As Integer
sin_port As Integer
sin_addr As Long
sin_zero(1 To 8) As Byte
End Type
Private Declare Function sendto Lib "ws2_32.dll" (ByVal s As Long, ByRef Buf As Any, ByVal buflen As Long, ByVal flags As Long, ByRef toaddr As sockaddr_in, ByVal tolen As Long) As Long
Dim udpAddr As sockaddr_in
With udpAddr
.sin_addr = inet_addr(IP)
.sin_port = htons(Port)
.sin_family = 2 'AF_INET Internetwork
End With
If sendto(sckHdl, ByVal tmpData, Len(tmpData), 0&, udpAddr, Len(udpAddr)) = -1 Then
MakeLog tmpData, vbRed, "SendToPacket() UDP_ERROR: Unable to Send Packet Via: " & sckHdl
End If
Quotelol now can the next posters asume im not a complete n00b please /begs
The way you spelled newbie, and the /beg at the end, makes me asume otherwise, but I'll do my best.
Joe: stop being useless.
On-topic: You may find using SOCK_RAW (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/tcp_ip_raw_sockets_2.asp) useful if you want to screw with TCP headers (which is what we are currently assuming).