Valhalla Legends Forums Archive | Visual Basic Programming | [VB6] packet generation help needed

AuthorMessageTime
-GP-
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-

February 2, 2006, 4:15 PM
TheMinistered
Here is a sample from one of my projects, we can derive a method of "ip validation" here in a minute from this:

[code]
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
[/code]

allrighty then, here we go:
[code]
Private Sub objTCPServer_ConnectionRequest(ByVal requestID As Long)


    If( IPValidationFunction(objTCPServer.RemoteHostIP) = True) then
        'accept connection
    Else
        'reject connection
    End If
   
End Sub
[/code]

IPValidationFunction would probably look up that ip in a database of some sort or a list and see if it's validated or not.

February 2, 2006, 7:23 PM
-GP-
[quote author=TheMinistered link=topic=14107.msg144284#msg144284 date=1138908211]
[code]
Private Sub objTCPServer_ConnectionRequest(ByVal requestID As Long)


    If( IPValidationFunction(objTCPServer.RemoteHostIP) = True) then
        'accept connection
    Else
        'reject connection
    End If
   
End Sub
[/code]
[/quote]

??? 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 address

lol now can the next posters asume im not a complete n00b please /begs
-GP-
February 3, 2006, 10:20 AM
TehUser
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.
February 3, 2006, 8:30 PM
Ringo
[quote author=TehUser link=topic=14107.msg144436#msg144436 date=1138998658]
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]
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)
[code]
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
[/code]
February 3, 2006, 11:16 PM
JoeTheOdd
[quote]lol now can the next posters asume im not a complete n00b please /begs[/quote]

The way you spelled newbie, and the /beg at the end, makes me asume otherwise, but I'll do my best.
February 5, 2006, 2:04 PM
rabbit
Joe: stop being useless.

On-topic:  You may find using SOCK_RAW useful if you want to screw with TCP headers (which is what we are currently assuming).
February 5, 2006, 6:04 PM

Search