Packets packets packets...

10/05/2012 23:40 badguy4you#1
I have been struggling to understand what is a Packet how could i create one with the data i want then send it to my server

So please any one tell if as example i want to send some info from my client to my server, then handle them from the server

how could i do that


[Note] : i have my socket server, also i don't wanna copy and paste codes i want to UNDERSTAND.

My PacketReader.cs

Handler.cs

Operations is an Enum : ushort
10/06/2012 00:32 I don't have a username#2

Pointers #1

Structs & Pointers #2


DataPackets & Packet Structures


Sockets #1


Sockets #2

Ref: [Only registered and activated users can see links. Click Here To Register...] (also in my sig.)
10/06/2012 00:35 go for it#3
well the next words im gona say not a perfect explanation but it's what i know and i think that should be enough information to start with
shit im drunk lmao well
packet is a data , byte array , it's send from/to server and from/to client
why you send packets ?
to add information of what you actually do or what client should show you
so lets give a good example about packet 1004
i won't really go inside about encryptions and stuff , just plain packet explaining after i got it
lemme get a 1004 packet and it's structure
1004: chat packet
Offsettypevalue
0ushortlength
2ushorttype
4uintChat_Color
8uintChat_Type
12uintMessageUID1
16uintMessageUID2
20uintChat_Mesh
26String[25]_From
(27 + _From.Length)string[26 + _From.Length])_to
(29 + _From.Length)string[(28 + _From.Length) + _To.Length]_Message

so lets try to get a packet and see if it fit this packet structure and explain it
fuck that took forever to find old packet logging text on my lap shit

Code:
Packet Nr 1959. Server -> Client, Length : 101, PacketType: 1004
5D 00 EC 03 00 00 00 FF D0 07 00 00 00 00 00 00      ;] ì   ÿÐ      
00 00 00 00 00 00 00 00 04 06 53 59 53 54 45 4D      ;        SYSTEM
03 41 4C 4C 00 33 43 6F 6E 67 72 61 74 75 6C 61      ;ALL 3Congratula
74 69 6F 6E 73 21 20 61 68 6D 65 64 31 30 35 35      ;tions! ahmed1055
39 20 77 6F 6E 20 45 78 70 42 61 6C 6C 20 69 6E      ;9 won ExpBall in
20 6C 6F 74 74 65 72 79 2E 00 00 00 00 54 51 53      ; lottery.    TQS
65 72 76 65 72                                       ;erver
forget the titles about packet num. from and to , length and type we will get them from the packet together now
okay now ill split this code out with umm colors ? okay
ill make it like the packet structure , shit i lost words , just look what ill do
fuck i need this types so umm here
Quote:
Talk = 2000,
Whisper = 2001,
Team = 2003,
Guild = 2004,
TopLeft = 2005,
Clan = 2006,
Qualifier = 2007,
Friend = 2009,
Center = 2011,
Service = 2014,
World = 2021,
PopUP = 2100,
Dialog = 2101,
HawkMessage = 2104,
Website = 2105,
FirstRightCorner = 2108,
ContinueRightCorner = 2109,
GuildBulletin = 2111,
BroadcastMessage = 2500;
5D 00 EC 03 00 00 00 FF D0 07 00 00 00 00 00 00 ;] ì ÿÐ
00 00 00 00 00 00 00 00 04 06 53 59 53 54 45 4D ; SYSTEM
03 41 4C 4C 00 33 43 6F 6E 67 72 61 74 75 6C 61 ;ALL 3Congratula
74 69 6F 6E 73 21 20 61 68 6D 65 64 31 30 35 35 ;tions! ahmed1055
39 20 77 6F 6E 20 45 78 70 42 61 6C 6C 20 69 6E ;9 won ExpBall in
20 6C 6F 74 74 65 72 79 2E 00 00 00 00 54 51 53 ; lottery. TQS
65 72 76 65 72 ;erver

colors should be kinda fucked up but this is for illustration

okay now lets get started
in brown at offset 0 there is 005D
notice how i read it ? this is ushort , that's how i read it
get calculator , convert this from hex to dec and you should get 93 yes this is the packet length and we add the server/client seal to it to be 101
and usually at tq packets they ALWAYS send the length in the very first ushort in client with offset 0
and they ALWAYS send the packet type in the next ushort at offset 2 which is umm 1004 right ? so umm try to convert 1004 to hex and you should get 3EC on calculator which is actually 03EC and should be written in the packet as EC 03

so yeah lets move to something more interesting ?
well what is the 00 00 00 FF ? go check the packet structure above
yes indeed it's chat color
what about those 2 uints ? of 00 00 00 00 00 00 00 00 ?
those are MessageUID1 and MessageUID2 , not really important for now

then D0 07 , how to type this down ? yes indeed 07D0 which is 2000 and yup i know you notice this Talk = 2000 , so this chat_type is talk

then 04 06 , pretty unknown to me , dun bother for now

then some long string starting with 53 ending with 2E
so what the hell is that ? isn't this a string ? yes prolly you need to look up the packet structure once more
well how to convert this packets to hex to string (letters and numbers?)
well i actually know them as i used them alot in reverse engineering but here
basically you need to use bit converter in coding and stuff but if you want to read something you may look up for assic converter or umm wait
here is a cool table i was using years before
[Only registered and activated users can see links. Click Here To Register...]

now what is the last bytes ?
54 51 53 65 72 76 65 72 ? this is tq server seal

im so damn sleepy and can't type anymore
now you got an idea about what's going on about packets and stuff
you won't find packet structure for last packets , you need to try and make wild guesses to figure them out , do something in game and try to figure out what's changed in the packet
goodluck maybe tomorrow ill try to edit this shit to make it more better but that mostly won't happen if i got a hang over >.<
peace out nigga pray for me not to fall while walking to my bed ^^
10/06/2012 00:36 shadowman123#4
@go for it : am afraid to say that he talks in general .. which means all u posted is useless to him Lol
10/06/2012 00:36 pro4never#5
The client is responsible for filling in various packet structures and sending them to the server.

What exactly is it you're trying to do? The most common way to send packets TO server is to write a proxy to sit between the client and the server in order to send fake packets to the server (aka botting/aimbotting/etc)

That being said, there's no LEGITIMATE reason to be trying to manually send packets Client>Server. That's what the client exists for in the first place.
10/06/2012 00:39 badguy4you#6
Quote:
Originally Posted by pro4never View Post
The client is responsible for filling in various packet structures and sending them to the server.

What exactly is it you're trying to do? The most common way to send packets TO server is to write a proxy to sit between the client and the server in order to send fake packets to the server (aka botting/aimbotting/etc)

That being said, there's no LEGITIMATE reason to be trying to manually send packets Client>Server. That's what the client exists for in the first place.
I want to understand packets in general so i can understand conquer ones if i wanted to.
10/06/2012 00:43 I don't have a username#7
Okay edited my post.
10/06/2012 00:45 badguy4you#8
Quote:
Originally Posted by shadowman123 View Post
@go for it : am afraid to say that he talks in general .. which means all u posted is useless to him Lol
Although i am talking in general he helped me alot but still a small question, how could you or anyone who gets a packet from a game to analyze it to know each part What it do, and get all the information about it. ! and indeed create a replay for it
10/06/2012 00:48 I don't have a username#9
Quote:
Originally Posted by badguy4you View Post
Although i am talking in general he helped me alot but still a small question, how could you or anyone who gets a packet from a game to analyze it to know each part What it do, and get all the information about it. ! and indeed create a replay for it
Packet analyzing is easy actually as long it's not encrypted and you don't have to reverse the cryptography.

Basically you check each offset with different datatypes until you get a value that is proper.

It can take some time unless you do it automatic. If I can get time I will finish Buu V3 which is so much better than V2 but short on time atm. as I'm coding a few things for a few people xD

I might write a guide for it as well.
10/06/2012 00:50 shadowman123#10
Quote:
Originally Posted by badguy4you View Post
Although i am talking in general he helped me alot but still a small question, how could you or anyone who gets a packet from a game to analyze it to know each part What it do, and get all the information about it. ! and indeed create a replay for it
by lots of trial and Error .. ( Analizing packet needs patience ) and Human Scense for example in packet 1004 ( chat packet ) when u type hello my friend Am shadowman u gonna see alot of sucessive bytes at packet dump so by human scense its string information and you can make sure of that by using Hex to String converter
10/06/2012 01:53 badguy4you#11
if i am receiving packet like this [i am testing on a game called Darkeden] and this is what i receive on login

[Only registered and activated users can see links. Click Here To Register...]

is this encrypted or what, i think no because the username and password just appears normally but how could i make my own replay to it specially that this game has been terminated and the real server closed. [can't sniff real packets]

I brought you that example to help me learn practically.
10/06/2012 02:42 shadowman123#12
Quote:
Originally Posted by badguy4you View Post
if i am receiving packet like this [i am testing on a game called Darkeden] and this is what i receive on login

[Only registered and activated users can see links. Click Here To Register...]

is this encrypted or what, i think no because the username and password just appears normally but how could i make my own replay to it specially that this game has been terminated and the real server closed. [can't sniff real packets]

I brought you that example to help me learn practically.
so forget about making this game cuz u cant depend on guessing in making packet structure as there are surely loads of packets and each packet have type / length and offsets first 2 are very easy as the client request some of the packets to server then the server send the right action to be done to client .. so the hardest part in this offsets which u cant get by guessing specially if it has long packet length
10/06/2012 08:31 pro4never#13
Quote:
Originally Posted by badguy4you View Post
if i am receiving packet like this [i am testing on a game called Darkeden] and this is what i receive on login

[Only registered and activated users can see links. Click Here To Register...]

is this encrypted or what, i think no because the username and password just appears normally but how could i make my own replay to it specially that this game has been terminated and the real server closed. [can't sniff real packets]

I brought you that example to help me learn practically.

There are 3 main ways.

#1: Sniff real packets (most common and easiest way).

You record a sequence of packets being sent between the client and server as you perform actions, then compare the packets to known values to speed up structuring them and allow yourself to create a full packet structure for the systems being written.

#2: Reverse engineer the client. (bit more difficult, provides a more accurate picture when done properly)

You reverse engineer the client to view how packets are being processed and sent in order to get a very clear picture of how each offset in packets are being used and give yourself a much better idea of how things are being done.

#3: Trial and error. (time consuming, rare and less efficient in most cases)

Use known partial structures and trial and error to fill out unknown offsets or in very rare cases, come up with complete structures.




There's a video from my now defunct proxy paradise project where I get into partial structuring from packet dumps (obviously it's not a complete structure but it gives you a bit of an idea of how to go about it from packet dumps)
10/06/2012 09:17 go for it#14
omg :D i should not explain anything when im drunk XD forgot to continue it
well my point from the post was to show a real packet , how server handle it and how client send it , how to get it's structure with testing/guessing
anyway goodluck mate