Valhalla Legends Forums Archive | Battle.net Bot Development | packet display function

AuthorMessageTime
Camel
I wrote this little function in vb to aid debugging of packets

[quote][16:25:23] SEND 0x50
(DWORD) 0x00000000
(DWORD) IX86
(DWORD) W2BN
(DWORD) 0x0000004F
(DWORD) 0x00000000
(DWORD) 0x00000583
(DWORD) 0x0000012C
(DWORD) 0x00000409
(DWORD) 0x00000409
(NTString) USA
(NTString) United States[/quote]

The function as is should be called without the packet header. To call it with the packet header, change Spot=1 to Spot=5.

[code]Public Enum fTypes
fDWORD
fDWORDStr
fNTString
fHash
End Enum

Public Function FormatPacketDisplay(str As String, ParamArray Format()) As String
Dim T
Dim Spot As Long
Spot = 1
For Each T In Format
Select Case CLng(T)
Case fTypes.fDWORD
FormatPacketDisplay = FormatPacketDisplay & vbCrLf & "(DWORD) 0x" & Zero(Hex(CVL(Mid(str, Spot, 4))), 8)
Spot = Spot + 4
Case fTypes.fDWORDStr
FormatPacketDisplay = FormatPacketDisplay & vbCrLf & "(DWORD) " & StrReverse(Mid(str, Spot, 4))
Spot = Spot + 4
Case fTypes.fNTString
Dim X As Long
X = InStr(Spot, str, Chr(0))
FormatPacketDisplay = FormatPacketDisplay & vbCrLf & "(NTString) " & Mid(str, Spot, X - Spot)
Spot = X + 1
Case fTypes.fHash
FormatPacketDisplay = FormatPacketDisplay & vbCrLf & "(HASH) " & HexDump(Mid(str, Spot, 20), "")
Spot = Spot + 20
Case Else
Debug.Assert False
End Select
Next
End Function[/code]

[code]Case &H50: Format = FormatPacketDisplay(Data, fDWORD, fDWORDStr, fDWORDStr, fDWORD, fDWORD, fDWORD, fDWORD, fDWORD, fDWORD, fNTString, fNTString)
Case &H51: Format = FormatPacketDisplay(Data, fDWORD, fDWORD, fDWORD, fDWORD, fDWORD, fDWORD, fDWORD, fDWORD, fDWORD, fhash, fNTString, fNTString)
...[/code]

comments/suggestions welcome :)

[edit] added StrReverse for fDWORDStr
[img]http://camel.ik0ns.com:84/bnubot19.jpg[/img]
June 25, 2003, 8:30 PM
Yoni
+1 to Camel.

Suggestion: Add some more types (WORD, BYTE seem missing... FILETIME might be useful too).
June 25, 2003, 9:33 PM
Camel
Ah yes; right now, I've only got it set up for the first five or six outgoing packets. I will add those, Yoni.
June 25, 2003, 10:48 PM
Grok
Nice Camel. Although I am sad to see yet another same-looking user interface. Where has creativity gone? Chat box, userlist, text input. All so boring.
June 26, 2003, 8:11 PM
Camel
[quote author=Grok link=board=17;threadid=1698;start=0#msg13024 date=1056658287]Where has creativity gone?[/quote]
My bot was unorigional long before any of yours were. =P
And its primary function is to hold ops, so i dont really care. :)

anyways, here's some updated code
i still have yet to do realm packets

[code]Option Explicit

Public Enum fTypes
fByte
fWord
fDWord
fDWordStr
fNTString
fMultiNTString
fHash
fFileTime
End Enum

Public Function FormatPacketDisplay(str As String, ParamArray Format()) As String
Dim t
Dim Spot As Long, X As Long
Spot = 1
For Each t In Format
Select Case CLng(t)
Case fTypes.fByte
X = Asc(Mid(str, Spot, 1))
FormatPacketDisplay = FormatPacketDisplay & vbCrLf & _
"(BYTE) 0x" & Zero(Hex(X), 2) & " (" & X & ")"
Spot = Spot + 1
Case fTypes.fWord
X = CVI(Mid(str, Spot, 2))
FormatPacketDisplay = FormatPacketDisplay & vbCrLf & _
"(DWORD) 0x" & Zero(Hex(X), 4) & " (" & X & ")"
Spot = Spot + 2
Case fTypes.fDWord
X = CVL(Mid(str, Spot, 4))
FormatPacketDisplay = FormatPacketDisplay & vbCrLf & _
"(DWORD) 0x" & Zero(Hex(X), 8) & " (" & X & ")"
Spot = Spot + 4
Case fTypes.fDWordStr
FormatPacketDisplay = FormatPacketDisplay & vbCrLf & _
"(DWORD) " & StrReverse(Mid(str, Spot, 4))
Spot = Spot + 4

Case fTypes.fNTString
X = InStr(Spot, str, Chr(0))
If X = 0 Then Debug.Assert False 'it didn't find a null!
FormatPacketDisplay = FormatPacketDisplay & vbCrLf & _
"(NTString) " & Mid(str, Spot, X - Spot)
Spot = X + 1
Case fTypes.fMultiNTString
X = InStr(Spot, str, Chr(0))
While X > 0
FormatPacketDisplay = FormatPacketDisplay & vbCrLf & _
"(NTString) " & Mid(str, Spot, X - Spot)
Spot = X + 1
X = InStr(Spot, str, Chr(0))
Wend

Case fTypes.fHash
FormatPacketDisplay = FormatPacketDisplay & vbCrLf & _
"(HASH) " & HexDump(Mid(str, Spot, 20), "")
Spot = Spot + 20
Case fTypes.fFileTime
FormatPacketDisplay = FormatPacketDisplay & vbCrLf & _
"(FileTime) " & FTtoDate(Mid(str, Spot, 8))
Spot = Spot + 8
Case Else
Debug.Assert False
End Select
Next
End Function[/code]

outgoing packets
[code] Case &H0: Format = FormatPacketDisplay(Data) 'nothing to see here!
Case &HA: Format = FormatPacketDisplay(Data, fNTString, fNTString)
Case &HC: Format = FormatPacketDisplay(Data, fDWord, fNTString)
Case &HE: Format = FormatPacketDisplay(Data, fNTString)
Case &H14: Format = FormatPacketDisplay(Data, fDWordStr)
Case &H25: Format = FormatPacketDisplay(Data, fDWord)
Case &H26: Format = FormatPacketDisplay(Data, fDWord, fDWord, fDWord, fMultiNTString)
Case &H27: Format = FormatPacketDisplay(Data, fDWord, fDWord, fMultiNTString)
Case &H29: Format = FormatPacketDisplay(Data, fDWord, fDWord, fHash, fNTString)
Case &H2E: Format = FormatPacketDisplay(Data, fDWordStr, fDWord, fDWord, fDWord, fDWord)
Case &H46: Format = FormatPacketDisplay(Data, fDWord)
Case &H50: Format = FormatPacketDisplay(Data, fDWord, fDWordStr, fDWordStr, fDWord, fDWord, fDWord, fDWord, fDWord, fDWord, fNTString, fNTString)
Case &H51: Format = FormatPacketDisplay(Data, fDWord, fDWord, fDWord, fDWord, fDWord, fDWord, fDWord, fDWord, fDWord, fHash, fNTString, fNTString)[/code]

incoming packets:
[code] Case &H0: Format = FormatPacketDisplay(Format) 'nothing! :)
Case &HA: Format = FormatPacketDisplay(Format, fNTString, fNTString, fNTString)
Case &HF: Format = FormatPacketDisplay(Format, fDWord, fDWord, fDWord, fDWord, fDWord, fDWord, fNTString, fNTString)
Case &H25: Format = FormatPacketDisplay(Format, fDWord)
Case &H26: Format = FormatPacketDisplay(Format, fDWord, fDWord, fDWord, fMultiNTString)
Case &H29: Format = FormatPacketDisplay(Format, fDWord)
Case &H2E: Format = FormatPacketDisplay(Format, fDWordStr) 'there is WAAAAAAY more, too much to display it all
Case &H46: Format = FormatPacketDisplay(Format, fByte, fDWord, fDWord, fDWord, fDWord, fNTString)
Case &H50: Format = FormatPacketDisplay(Format, fDWord, fDWord, fDWord, fDWord, fDWord, fNTString, fNTString)
Case &H51: Format = FormatPacketDisplay(Format, fDWord, fNTString)[/code]
June 27, 2003, 10:40 PM
Skywing
If it's primarily an op bot, why are you making a GUI that will only slow it down?
June 28, 2003, 12:00 AM
Camel
[quote author=Skywing link=board=17;threadid=1698;start=0#msg13099 date=1056758447]
If it's primarily an op bot, why are you making a GUI that will only slow it down?
[/quote]

[code]#If DEBUG_ Then
...
#End If[/code]
VB isn't that ghetto...yet. :)
June 28, 2003, 1:15 AM

Search