Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: Lenny on July 23, 2003, 11:20 PM

Title: Packet Tutorials
Post by: Lenny on July 23, 2003, 11:20 PM
Any tutorials about packet buffers and battle.net packets available?
Title: Re:Packet Tutorials
Post by: CrAz3D on July 23, 2003, 11:29 PM
I think feanor wrote one.  try some where within http://blizzside.com/feanor/ (http://blizzside.com/feanor/)
Title: Re:Packet Tutorials
Post by: Lenny on July 23, 2003, 11:47 PM
Its not posted anymore...
Title: Re:Packet Tutorials
Post by: Lenny on July 24, 2003, 12:13 AM
Also I remember Camel posting a very good feature that shows the 0x packets....But cant seem to find it
Title: Re:Packet Tutorials
Post by: Camel on July 24, 2003, 01:28 AM
Quote from: Lenny on July 24, 2003, 12:13 AM
Also I remember Camel posting a very good feature that shows the 0x packets....But cant seem to find it

http://forum.valhallalegends.com/phpbbs/index.php?board=17;action=display;threadid=1698
Title: Re:Packet Tutorials
Post by: Lenny on July 24, 2003, 11:25 PM
Thanks

Any packet tutorials available?
Title: Re:Packet Tutorials
Post by: Mesiah / haiseM on July 24, 2003, 11:37 PM
http://www.valhallalegends.com/arta/bnetdocs
Title: Re:Packet Tutorials
Post by: Lenny on July 25, 2003, 12:07 AM
Down....BNET Docs is down :'(
Title: Re:Packet Tutorials
Post by: Mesiah / haiseM on July 25, 2003, 12:36 PM
yeah arta was never very reliable :P

you may be able to find a few packet examples at the bot development site: http://botdev.valhallalegends.com

also i have a really really old out-of-date thingy on zorms forums: http://zorm.phactorx.com/forum/viewtopic.php?t=5

might wanna check that out too. (i think there might be a few common errors in it though, beware.)
Title: Re:Packet Tutorials
Post by: Skywing on July 25, 2003, 02:03 PM
Quote from: MesiaH on July 25, 2003, 12:36 PM
yeah arta was never very reliable :P

you may be able to find a few packet examples at the bot development site: http://botdev.valhallalegends.com

also i have a really really old out-of-date thingy on zorms forums: http://zorm.phactorx.com/forum/viewtopic.php?t=5

might wanna check that out too. (i think there might be a few common errors in it though, beware.)
Actually, this was planned, unavoidable downtime for him.
Title: Re:Packet Tutorials
Post by: Adron on July 25, 2003, 02:27 PM
Didn't he say he'd be back within a few days though? Seems he's been gone longer?
Title: Re:Packet Tutorials
Post by: Lenny on July 25, 2003, 11:21 PM
Anything a little more introductory?
Title: Re:Packet Tutorials
Post by: CrAz3D on July 26, 2003, 10:49 PM
http://blizzside.com/illed/ (http://blizzside.com/illed/)?
Title: Re:Packet Tutorials
Post by: Lenny on July 26, 2003, 11:11 PM
Ironically the programing area is down on that site exept for open sources....
Title: Re:Packet Tutorials
Post by: CrAz3D on July 26, 2003, 11:27 PM
I don't have any idea where then, all the good palces are down.

'Eventos
Public Const ID_USER        As Integer = &H1
Public Const ID_JOIN        As Integer = &H2
Public Const ID_LEAVE       As Integer = &H3
Public Const ID_WHISPER     As Integer = &H4
Public Const ID_TALK        As Integer = &H5
Public Const ID_BROADCAST   As Integer = &H6
Public Const ID_MOVE        As Integer = &H7
Public Const ID_FLAGS       As Integer = &H9
Public Const ID_SEND        As Integer = &HA
Public Const ID_FULL        As Integer = &HD
Public Const ID_NOTEXIST    As Integer = &HE
Public Const ID_RESTRICTED  As Integer = &HF
Public Const ID_INFO        As Integer = &H12
Public Const ID_ERROR       As Integer = &H13
Public Const ID_EMOTE       As Integer = 23

'Flagage
Public Const BNFLAGS_BLIZZ = &H1
Public Const BNFLAGS_OP = &H2
Public Const BNFLAGS_SPKR = &H4
Public Const BNFLAGS_SYSOP = &H8
Public Const BNFLAGS_PLUG = &H10
Public Const BNFLAGS_SQUELCH = &H20
Public Const BNFLAGS_GLASSES = &H40
Title: Re:Packet Tutorials
Post by: Camel on July 27, 2003, 01:41 AM
You're missing a few flags, CrAz3D

   'Flags (in order of appearance)
   '0x1 - Blizzard rep
   '0x8 - Bnet rep
   '0x2 - Channel op
   '0x4 - Speaker
   '0x40 - Blizzard guest
   '0x20 - Squelched
   '0x400 - PGL official
   '0x200 - PGL player

   '0x10 - No UDP support (plug replaces lag)
Title: Re:Packet Tutorials
Post by: Lenny on July 27, 2003, 03:13 AM
Can someone teach me how to utilize the Packet Buffer?  THe one created by Darkminion specifially :-\
Title: Re:Packet Tutorials
Post by: CrAz3D on July 27, 2003, 08:59 AM
My oops, thnx Camel.
Quote
Can someone teach me how to utilize the Packet Buffer?  THe one created by Darkminion specifially  
Like PacketBuffer.sendPacket?
Title: Re:Packet Tutorials
Post by: Dark-Feanor on July 28, 2003, 09:39 AM
I will post my tutorial thing up here. It is still incomplete, but it gets the job done.
QuoteInformation on reading packetlog information (hex) and using DarkMinion's PacketBuffer Class.
-Writen by Feanor[xL] aka DaRk-FeAnOr

Most of battle.net connection is run on TCP packets. A good packet
logger to use is WPE packet logger or Ufasoft's packet logger
(found at www.ufasoft.com). When you packet log a program, you will get
a whole lot of hex, that for new programmers is difficult to
understand.

Your first question is probably: Why is packet logging important?

The answer to this is, that in order to write about anything that has to do with battle.net,
you must packetlog it and emulate the packets that your computer sends to battle.net and
recieves from them. For example, we will anaylze Packet 0x1C. You must send this packet to
battle.net in order to create a game.


Here is an example of packet: 0x1C (which is used to create games)
- Packet log taken from Barumonk[xL]'s Melee winbot.

0000  FF 1C 5B 00 00 00 00 00 00 00 00 00 02 00 01 00    ..[.............
0010  1F 00 00 00 00 00 00 00 53 6F 6D 65 47 61 6D 65    ........SomeGame
0020  4E 61 6D 65 00 00 2C 34 34 2C 31 34 2C 36 2C 32    Name..,44,14,6,2
0030  2C 32 2C 31 2C 36 38 36 34 34 37 30 33 2C 34 2C    ,2,1,68644703,4,
0040  2C 6E 65 74 77 6F 72 6B 7A 0D 54 68 65 20 4C 6F    ,networkz.The Lo
0050  73 74 20 54 65 6D 70 6C 65 0D 00 FF 10 04 00       st Temple......

The first collum of information with (0000, 0010, 0020 etc.) should be ignored.
The hex begins with the packet FF. Most battle.net packets begin with FF and the Pbuffer class
writen by DarkMinion, takes this into account when sending packets. The next packet after FF is
the name of the packet that you are sending. The Visual Basic for this packet would look like:

With PacketBuf
   .InsertDWORD &H0
   .InsertDWORD &H0
   .InsertWORD &H2
   .InsertWORD &H1
   .InsertDWORD &H1
   .InsertDWORD &H0
   .InsertNTString gamename
   .InsertNTString gamename
   .InsertNonNTString gameinfo
   .sendPacket &H1C
End With

Now compare this to the hex you see above. Lets brake the hex down:

FF 1C (header of hex)
5B 00 (ignore)
00 00 00 00 (first DWord)     .InsertDWORD &H0
00 00 00 00 (Second DWord)    .InsertDWORD &H0
02 00 (first Word)            .InsertWORD &H1
01 00 (second word)           .InsertWORD &H1
1F 00 00 00 (third DWord)   .InsertDWORD &H1F
00 00 00 00 (forth DWord)     .insertDWord &H0

The rest of the information is the gamename and gameinfo writen into the hex.
FF 10 04 00 (start of next packet)-
sometimes you get two packets being sent in the same packet log.

You might be asking yourself what a DWOrd and word is. Here is how it works

DWord is the inserted byte, followed by three 0s.
Example:
.InsertDWORD &H1

in the hex it translates to
01 00 00 00

Word inserts the byte, followed by one 0.
Example:
.insertWord &H1
01 00

Some other functions are:
.insertbyte &H1
Which inserts the selected byte followed by no 0s
.insertbytes "01 00 00 00"
which inserts a bitch load of bytes at the same time
Insertbytes is good to use if you are too lazy to put everything into DWords and words.

Also, for inserting strings to hex you can use
.insertNTstring "hey"
and
.insertnonNTstring "hey"
I am pretty sure that the difference is that a NTstring is followed by a 0x00 (null) packet and an NONnTstring is not.


That is about it. The best way to learn is by trial and error, but I hope this helped. [/quote
Title: Re:Packet Tutorials
Post by: Mesiah / haiseM on July 28, 2003, 11:43 AM
Not bad, but i think your using your terms wrong in a few places, might wanna overlook it.
Title: Re:Packet Tutorials
Post by: Lenny on July 29, 2003, 03:39 AM
Quote from: CrAz3D on July 27, 2003, 08:59 AM
My oops, thnx Camel.
Quote
Can someone teach me how to utilize the Packet Buffer?  THe one created by Darkminion specifially  
Like PacketBuffer.sendPacket?

Yes...
Title: Re:Packet Tutorials
Post by: Dark-Feanor on July 29, 2003, 09:49 AM
I just posted that two up.
Title: Re:Packet Tutorials
Post by: Lenny on July 29, 2003, 11:22 PM
Quote from: DaRk-FeAnOr on July 29, 2003, 09:49 AM
I just posted that two up.

It's helped me understand packet tutorials but I'm still not quite sure how to create packets
Title: Re:Packet Tutorials
Post by: Mesiah / haiseM on July 30, 2003, 07:00 PM
its all in your structure, in binary protocol, there are bytes (00), words (00 00), dwords (00 00 00 00), qwords (00 00 00 00 00 00 00 00), strings (hi my name is bob), and null terminated strings (hi my name is bob, followed by a null byte {00}), you will need to format your data for each term that is required.

here are the examples once again to see more clearly:

byte - 00
word - 00 00
dword - 00 00 00 00
qword - 00 00 00 00 00 00 00 00
string - hi my name is bob
null terminated string - hi my name is bob + 00

using darkminions packet buffer will allow you to stack these in order to form your packet, then you just need to slap the header on it, and send it...
Title: Re:Packet Tutorials
Post by: Lenny on July 30, 2003, 10:35 PM
Do I always need to send the null string?  And how do I process recieved packets?
Title: Re:Packet Tutorials
Post by: Dark-Feanor on July 30, 2003, 11:34 PM
It automatically does the null bytes for you, based on the type of byte you added (Dword, Word, Byte, ect.)
Title: Re:Packet Tutorials
Post by: Lenny on July 31, 2003, 11:32 PM
How Do I process recieved packets from battle.net?
Title: Re:Packet Tutorials
Post by: CrAz3D on August 01, 2003, 11:46 PM
By parsing it all
Title: Re:Packet Tutorials
Post by: Lenny on August 01, 2003, 11:49 PM
Quote from: CrAz3D on August 01, 2003, 11:46 PM
By parsing it all
Any Examples?
Title: Re:Packet Tutorials
Post by: Eibro on August 02, 2003, 01:11 AM
I fail to understand what a "Packet Tutorial" would entail. It seems to me what ye lassies really need is a basic understanding of computer organization/architecture.
Title: Re:Packet Tutorials
Post by: Lenny on August 02, 2003, 02:07 AM
I need to understand how to build packets to send to battle.net and what to send....
Title: Re:Packet Tutorials
Post by: Lenny on August 04, 2003, 03:20 AM
Can anyone give a good summary on  how creating a packet works and how checksum works?