Author Topic: Packet Logging....  (Read 4910 times)

0 Members and 1 Guest are viewing this topic.

Offline abc

  • Hero Member
  • *****
  • Posts: 576
    • View Profile
Packet Logging....
« on: February 18, 2007, 08:24:13 pm »
Alright....I know I posted a topic a little while ago with it but I still need help (different packet log).

I guess my question is...I'm trying to figure out what is sent to the server to connect. But there's all this 'junk' in the data...So how do I know what is actually sent and what is not?..

Code: [Select]
0000  00 18 f8 3f 4a b4 00 17  31 46 8b 27 08 00 45 00   ...?J... 1F.'..E.
0010  00 58 e2 cd 00 00 80 11  8f 7c 4c b3 f6 65 44 8e   .X...... .|L..eD.
0020  40 a4 08 da 69 86 00 44  23 94 56 53 30 31 18 00   @...i..D #.VS01..
0030  06 00 00 02 00 00 00 b6  bc d9 70 00 00 00 27 00   ........ ..p...'.
0040  00 00 01 00 00 00 70 00  00 00 18 00 00 00 cc 02   ......p. ........
0050  00 00 56 15 14 01 01 00  10 01 8f ec 18 00 01 44   ..V..... .......D
0060  4d 53 79 70 68 00                                  MSyph.           

DMSyph is my username.
How do I know what is sent to the server to connect?

Fyi, This is for Steam's Friends Network...

Offline Joe

  • B&
  • x86
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: Packet Logging....
« Reply #1 on: February 18, 2007, 10:05:35 pm »
The TCP header is 0x35 bytes long. Byte 0x36 on is the data.

When I'm hand-analyzing packets, I generally butcher it up pretty quick so it looks like this:

Code: [Select]
0030                    00 b6  bc d9 70 00 00 00 27 00         .. ..p...'.
0040  00 00 01 00 00 00 70 00  00 00 18 00 00 00 cc 02   ......p. ........
0050  00 00 56 15 14 01 01 00  10 01 8f ec 18 00 01 44   ..V..... .......D
0060  4d 53 79 70 68 00                                  MSyph.   

EDIT -
Oh, it's TCP. Nevermind.
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline Ender

  • x86
  • Hero Member
  • *****
  • Posts: 2390
    • View Profile
Re: Packet Logging....
« Reply #2 on: February 18, 2007, 10:06:34 pm »
You know what you send, now look for that in the packet log.

Offline abc

  • Hero Member
  • *****
  • Posts: 576
    • View Profile
Re: Packet Logging....
« Reply #3 on: February 18, 2007, 10:17:10 pm »
The TCP header is 0x35 bytes long. Byte 0x36 on is the data.

When I'm hand-analyzing packets, I generally butcher it up pretty quick so it looks like this:

Code: [Select]
0030                    00 b6  bc d9 70 00 00 00 27 00         .. ..p...'.
0040  00 00 01 00 00 00 70 00  00 00 18 00 00 00 cc 02   ......p. ........
0050  00 00 56 15 14 01 01 00  10 01 8f ec 18 00 01 44   ..V..... .......D
0060  4d 53 79 70 68 00                                  MSyph.   

EDIT -
Oh, it's TCP. Nevermind.

UDP***

Also, Yeah I know the data...but I don't know how to send it....Maybe i'm making it more complicated then it really is...I don't know..

Offline Sidoh

  • Moderator
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Packet Logging....
« Reply #4 on: February 18, 2007, 10:22:45 pm »
What do you mean you don't know how to send it?  Have you ever worked with sockets?  Maybe you should read a few books (or at least a few online tutorials on packets and sockets...) before you try a project like this.

Offline abc

  • Hero Member
  • *****
  • Posts: 576
    • View Profile
Re: Packet Logging....
« Reply #5 on: February 18, 2007, 10:28:12 pm »
yeah, I know how to use sockets...haha atleast I think?...

I built/building a Chat Server/Client...and it's going good..

Offline Joe

  • B&
  • x86
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: Packet Logging....
« Reply #6 on: February 18, 2007, 10:35:44 pm »
Here's the code you wanted:

Code: [Select]
'---------------------------------------------------------------------------------------
' Module    : PacketWriter
' Author    : Joe[x86]
' Purpose   : This will take input, convert it to a byte array, and return it when
'             requested.
'---------------------------------------------------------------------------------------

Option Explicit

' The initial size of the buffer, in bytes
Private Const CONST_INITIALSIZE As Integer = 128
' Maximum size of the buffer, in bytes
Private Const CONST_MAXSIZE As Integer = 1024
' Ammount of bytes to grow the buffer by, when it must increase
Private Const CONST_GROWBY As Integer = 16

' Current length of the buffered data
Private CURRENTLENGTH As Integer
' Current size of the buffer
Private CURRENTSIZE As Integer

' Byte array which holds the data
Private DATA() As Byte

Private Sub Class_Initialize()
    Call Reset
End Sub

Public Sub Reset()
    ReDim DATA(1 To CONST_INITIALSIZE)
    CURRENTSIZE = UBound(DATA)
    CURRENTLENGTH = 0
End Sub

Private Sub Grow()
    ReDim Preserve DATA(1 To UBound(DATA) + CONST_GROWBY)
    CURRENTSIZE = UBound(DATA)
End Sub

'---------------------------------------------------------------------------------------
' This inserts a byte, but not before making sure we actually have room to do it.
'---------------------------------------------------------------------------------------
Public Sub addByte(B As Byte)
    If CURRENTLENGTH + 1 >= CURRENT_SIZE Then
        Call Grow
        Call addByte(B)
    End If
    CURRENTLENGTH = CURRENTLENGTH + 1
    DATA(CURRENTLENGTH) = B
End Sub

'---------------------------------------------------------------------------------------
' This inserts a Double Word. Did I get byte order right? :-\.
'---------------------------------------------------------------------------------------
Public Sub addDWord(D As Long)
    If (Len(D) < 4) Then Exit Sub
    Call addByte(D & &HFF)
    Call addByte(D & &HFF00)
    Call addByte(D & &HFF0000)
    Call addByte(D & &HFF000000)
End Sub

'---------------------------------------------------------------------------------------
' This inserts a Null-Terminated (AKA, C-Style) string.
'---------------------------------------------------------------------------------------
Public Sub addCString(S As String)
    Dim I As Integer    ' Counter
    For I = 1 To Len(S) Step 1
        addByte (Asc(Mid(S, I, 1)))
    Next I
    Call addByte(0)
End Sub

'---------------------------------------------------------------------------------------
' This one's weird, because you have bytes mangling at the end if you don't ReDim it
' to the right length.
'---------------------------------------------------------------------------------------
Public Function getData() As Byte()
    ReDim Preserve DATA(1 To CURRENTLENGTH)
    getData = DATA
    ReDim Preserve DATA(1 To CURRENTSIZE)
End Function

For what you were going to do, just call addByte(&H--) for each value.
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline abc

  • Hero Member
  • *****
  • Posts: 576
    • View Profile
Re: Packet Logging....
« Reply #7 on: February 19, 2007, 09:29:56 am »
Thanks joe.  :)