• Welcome to Valhalla Legends Archive.
 

Parsing Packets

Started by MindArchon, August 25, 2004, 03:00 PM

Previous topic - Next topic

MindArchon

Ive been looking around for the last 6 hours trying to find a beginners explanation on how to get data from packets sent from battle.net. I didnt find it.

Things I know:

The function StrtoHex is used
Asc(Mid(Data, 2, 1)) gets the packet id

I have Grok's Debug Output and I have been examining the packets. Thats about all I know. Could somebody please give me just a little info on how this works?

ChR0NiC

Quote from: MindArchon on August 25, 2004, 03:00 PM
Ive been looking around for the last 6 hours trying to find a beginners explanation on how to get data from packets sent from battle.net. I didnt find it.

Things I know:

The function StrtoHex is used
Asc(Mid(Data, 2, 1)) gets the packet id

I have Grok's Debug Output and I have been examining the packets. Thats about all I know. Could somebody please give me just a little info on how this works?


http://www.dark-wire.net/exile/members/tutorials.php?view=7

This is as good as it gets, nobody wants to waste their time teaching people about packets, sorry. I learned by noticing the differences in packet logs and by using Grok's debug output.

MindArchon

Quote from: ChRoNiC on August 25, 2004, 03:49 PM
Quote from: MindArchon on August 25, 2004, 03:00 PM
Ive been looking around for the last 6 hours trying to find a beginners explanation on how to get data from packets sent from battle.net. I didnt find it.

Things I know:

The function StrtoHex is used
Asc(Mid(Data, 2, 1)) gets the packet id

I have Grok's Debug Output and I have been examining the packets. Thats about all I know. Could somebody please give me just a little info on how this works?


http://www.dark-wire.net/exile/members/tutorials.php?view=7

This is as good as it gets, nobody wants to waste their time teaching people about packets, sorry. I learned by noticing the differences in packet logs and by using Grok's debug output.

So.. You use StrToHex then your bot examines the hex to get the values out of it?

Sorc.Polgara

Ok, I had trouble with this too.

BNCS Headers are like so

&HFF (Byte) + PacketID (Byte) + PacketSize (WORD)

So basically a BNCS header is a DWORD (4 Bytes).

This is the way I looked at the header, looked at it as a string.
"ABCDDDDDD..."

A = &HFF, BNCS constant
B = PacketID
C = PacketSize
D = Packet's Data

Quote
Mid(Data, 2, 1)

This is just taking the "B" packet.

I'm not quite sure what you are asking specifically.

I am a newbie like you too but I know some stuff.

I have made this PacketDebuffer Class and posted it earlier.  This could help you with parsing a packet.


'===============================
'PacketDebuffer Class
'By Bethra, aka. Sorc.Polgara =)
'===============================

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal

numBytes As Long)

Private Debuffer As String      '// Debuffering string

'Sets the Debuffer string
Public Function DebuffPacket(PacketData As String)
   Debuffer = PacketData
End Function

'Resets/clears the Debuffer
Public Function Clear()
   Debuffer = vbNullString
End Function

'=======================================================
'Public Functions that debuffer a part from the Debuffer
'=======================================================

'Debuffers a DWORD from the Debuffer
Public Function DebuffDWORD()
   DebuffDWORD = GetDWORD(Debuffer)
   RemoveDWORD
End Function

'Debuffers a WORD from the Debuffer
Public Function DebuffWORD()
   DebuffWORD = GetWORD(Debuffer)
   RemoveWORD
End Function

'Debuffers a BYTE from the Debuffer
Public Function DebuffBYTE()
   DebuffBYTE = GetBYTE(Debuffer)
   RemoveBYTE
End Function

'Debuffers a FILETIME from the Debuffer
Public Function DebuffFILETIME()
   DebuffFILETIME = GetFILETIME(Debuffer)
   RemoveFILETIME
End Function

'Debuffers a null-terminating string from the Debuffer
Public Function DebuffNTString()
   DebuffNTString = GetNTString(Debuffer)
   RemoveNTString
End Function

'=====================================================
'Public Functions that remove a part from the Debuffer
'=====================================================

'Removes a BYTE from the Debuffer
Public Function RemoveBYTE()
   Debuffer = Mid(Debuffer, 2)
End Function

'Removes a WORD from the Debuffer
Public Function RemoveWORD()
   Debuffer = Mid(Debuffer, 3)
End Function

'Removes a DWORD from the Debuffer
Public Function RemoveDWORD()
   Debuffer = Mid(Debuffer, 5)
End Function

'Removes a FILETIME structure from the Debuffer
Public Function RemoveFILETIME()
   Debuffer = Mid(Debuffer, 9)
End Function

'Removes a non-terminating string from the Debuffer
Public Function RemoveNTString()
   Dim Pos As Integer
   Pos = InStr(1, Debuffer, Chr(0), vbBinaryCompare)
   Debuffer = Mid(Debuffer, Pos + 1)
End Function

'=======================================================
'Functions that get parts from the front of the Debuffer
'=======================================================

'Gets a BYTE from the Debuffer
Function GetBYTE() As String
   Dim PBYTE As String
   PBYTE = Mid(Debuffer, 1, 1)
   GetBYTE = PBYTE
End Function

'Gets a WORD from the Debuffer
Function GetWORD() As String
   Dim WORD As String * 2
   CopyMemory WORD, Debuffer, 2
   GetWORD = WORD
End Function

'Gets a DWORD from the Debuffer
Function GetDWORD() As String
   Dim DWORD As String * 4
   CopyMemory DWORD, Debuffer, 4
   GetDWORD = DWORD
End Function

'Gets a FILETIME from the Debuffer
Function GetFILETIME() As String
   Dim FILETIME As String * 8
   CopyMemory FILETIME, Debuffer, 8
   GetFILETIME = FILETIME
End Function

'Gets a non-terminating string from the Debuffer
Function GetNTString() As String
   Dim NTString As String
   Dim Pos As Integer
   Pos = InStr(1, Debuffer, Chr(0), vbBinaryCompare)
   NTString = Mid(Debuffer, 1, Pos)
   GetNTString = NTString
End Function

'=====================Credits============================
'DarkMinion for using his PacketBuffer class as a guide,
'this is the first class I have ever made =)
'-----------------
'Bot Developement Forum members who helped me understand
'some stuff that I need to know inorder to make this =)
'=======================================================


Here is how you might use it to parse the parts of a BNCS header from the packet


Dim PDebuf As PacketDebuffer
Set PDebuf = New PacketDebuffer
       
With PDebuf
   .DebuffPacket Packet
   PacketConst = .DebuffBYTE
   PacketID = .DebuffBYTE
   PacketSize = .DebuffWORD
End With