Code Monkey home page Code Monkey logo

agario-protocol's Introduction

##Agar.io Protocol

Agar.io has decided to change their protocol once again. Many extension makers are not happy with the update since all extensions that do not use the newest protocol are broken.

Index

Reverse engineer techniques

To determine how the protocol is built you could use one of the following techniques:

  • Replace window.WebSocket with code from pastebin to listen between data that gets received and send.
  • Create an server and let it connect to your server with agar.io?ip=yourserverip:port to see what you receive.

agario-protocol's People

Contributors

daawesomerazor avatar issy123 avatar issy321 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

agario-protocol's Issues

Packet 64

Packet 64 isn't used anymore. Seems to be all data is included in packet 255 though.

Protocol 18 - message 05

Message 05 is used to notify client/server about friends.

The client sends message 05 with ascii null terminated string, which lists facebook friend id of all friends separated by character '|'.

Offset Size Description
0 byte =0x05
1 string zero terminated ascii string

For example the string with facebook id list may looks like this: "110139034002111|104404922207222" (these are fake id just for example), where 110139034002111 and 104404922207222 are facebook friend id

When server receives that message it starts to notify if listed players are present on the server. Without it, the server sends just empty 05 message.

The server sends message 05 with ascii null terminated string, which lists facebook friend id of all ONLINE friends separated by character '|'.

Offset Size Description
0 byte =0x05
1 uint32 playerId for online friend 1
5 string zero terminated ascii string with online friend 1 id
x uint32 playerId for online friend 2
x string zero terminated ascii string with online friend 2 id
... ... ...

with playerId you can find your friends on leaderboard and his cells

Packet 241

Sent from server after client connected to the room, maybe it contains server version.

Example data:

[241, 18, 118, 183, 49]

Packet 255

Does anybody know about this packet!?

unrelated but...

how do you bypass anti bots on agario clone like senpa.io and some other's?

bots get packet from agario clone site when they connect
bots can spawn if bots return correct packet

but how do i do that

New protocol 7 for Ogar server (since 05/05/2016)

Basically the protocol is almost the same as previous.

The new client sends the following 2 messages to private server at connection begin:

FE 07 00 00 00  // protocol version 
FF 00 00 00 00  // just ignore it

Protocol 6, 7 change list:

1) Cell Update message 0x10

A little change in the structure of cell update message:

Offset Value Type Description
0 0x10 byte Cell Update message code
1 xx uint16 Eat Record Count
3 xx record list Eat Records
xx xx record list Cell Update Records. Ends with 4-zero bytes
xx xx uint16 Remove Record Count
xx xx record list Remove Records

Structure of Eat Record:

Offset Type Description
0 uint32 Hunter Cell Id
4 uint32 Prey Cell Id

Structure of Cell Update Record:

Offset Value Type Description
0 xx uint32 Cell ID (0x00000000 is used as terminator)
4 xx int32 Coordinate X
8 xx int32 Coordinate Y
12 xx int16 Cell size
14 xx byte Flags
15 xx 3 byte (optional) Color (r,g,b components)
xx xx string (optional) Skin name (zero-terminated string)
xx xx string (optional) Cell name (zero-terminated string, UTF8 encoding)

Structure of Remove Record:

Offset Type Description
0 uint32 Cell ID (which should be removed)

The flags:

Bit Hex Mask Description
0 0x01 isVirus
1 0x02 isColorPresent (3 bytes with R,G,B components included into update)
2 0x04 isSkinPresent (zero terminated string with skin name included into update)
3 0x08 isNamePresent (zero terminated string with skin name included into update, UTF8 encoding)
4 0x10 isAgitated (if 1 then increases the amplitude of the waves on a blob outline)
5 0x20 isEject (if 1 then this is not a player cell, just W ejected blob)

Message example:

10                                                 // Cell Update message code
02 00                                              // 2 eat records
B5 FF 55 AA E7 FF 55 AA                            // eat record #1
51 FF 55 AA 44 FF 55 AA                            // eat record #2
38 FF 55 AA 59 0B 00 00 7B 00 00 00 CF 00 00       // cell update record #1
51 FF 55 AA 1D 0E 00 00 F0 00 00 00 C5 00 00       // cell update record #2
CC FF 55 AA D3 12 00 00 C8 FE FF FF E4 00 00       // cell update record #3
B5 FF 55 AA D8 0C 00 00 94 FE FF FF 9E 01 00       // cell update record #4
00 00 00 00                                        // cell update record terminator
02 00                                              // 2 remove records
44 FF 55 AA                                        // remove record #1
E7 FF 55 AA                                        // remove record #2

The main difference here is that color and name fields of the cell now is optional and may not be included into message.
The second difference is position of the Flags field. Now it placed before the cell size field.
And third difference is that there is no other fields.
What optional field is included into message is controlled with flags.

This change in update cell message structure leads to problem with private servers with old protocol.
But difference is not significant and can be easily fixed.

2) String encoding

All string encoding were changed to UTF8. It still uses zero-terminated strings, but now strings encoded in UTF8 format. It affects Cell Update message, Leaderboard FFA message and Join command.

3) Clear Message 0x12.

Actually this message was used since protocol 5. But I found that ogar server still uses 0x14 (partial clear message). They both 1-byte length. But the new client uses 0x12. And it's important to send this message just when connection established and also on each join command.

Protocol 20

Protocol 20 is just rolled out. Looks that there is no significant difference with protocol 19.

Discovered changes:

  1. server version string is moved from Border Update message (0x40) to Cipher Key message (0xF1)

  2. Replaced client side encryption key generator, now it depends on server host and server version.

Still under investigation, if you have any info about it, you're welcome.

Dimensions

Who knows dimensions of field are the same!?

Update reverse engineering teachnique

I updated https://github.com/SNSA/agario-code to hook custom Websocket to Agar.io. It also allows you to debug pretty version of agario.core.js and of course you can easily put break points there.

Note that whenever the script is outdate, Agar.io will ask to redownload the script. To have latest version of the agario.core.js script, run: gulp update (and don't forget to send a PR to update it).

Packet 112 and 113

Packet 112 is sent from server to client, example data:

[112, 49, 55, 55, 55, 52, 49, 52, 52, 57, 56, 51, 53, 57, 51, 55, 50, 55, 57, 54, 55]

Client musts send back packet 112 to complete authentication (without this client cannot spawn), example data:

[113, 124, 3, -106, 47, -90, 92, 16, 78, 119, 97, 73, -13, 9, 75, 104, 100, -8, -75, -27, 123]

Note that packet 113 is calculated from packet 112, if client sends wrong data for packet 113, the server will close the socket by sending back packet 128, see #4

The algorithm is quite complicated, I tried debugging but didn't get much.

Protocol 20 - messages 0x71 and 0x72

These messages was added in protocol 18, but there is still no description, so I just write it here.

Message { 0x72 } is sent from server the the client in response to spectate command. This message leads to show the message "Spectate mode is full".

Message { 0x71, 0x02 } is sent from server to the client after long timeout with no gameplay. The server will disconnect the client just after this message.

Message { 0x71, 0x01 } leads client to disconnect, find new server, connect to it and automatically join the game. I don't have what is the reason for that, but it works in such way ;)

Protocol 19 - message 0x45 - minimap

Since 2018/20/12, a new protocol 19 is rolled out. The difference is just in cipher key.
Also added a new message 0x45 - Minimap

sv_protocol 19
sv_secret 0x0000765D
sv_versionClient "3.3.1"
sv_versionProto "12.0.1"

Protocol 15

May be it will be interesting for someone.
Here is the latest protocol 15:

1) Cell Update message 0x10

A little change in the structure of cell update message:

Offset Value Type Description
0 0x10 byte Cell Update message code
1 xx uint16 Eat Record Count
3 xx record list Eat Records
xx xx record list Cell Update Records. Ends with 4-zero bytes
xx xx uint16 Remove Record Count
xx xx record list Remove Records

Structure of Eat Record:

Offset Type Description
0 uint32 Hunter Cell Id
4 uint32 Prey Cell Id

Structure of Cell Update Record:

Offset Value Type Description
0 xx uint32 Cell ID (0x00000000 is used as terminator)
4 xx int32 Coordinate X
8 xx int32 Coordinate Y
12 xx uint16 Cell size
14 xx byte Flags
xx xx byte (optional) Extended Flags (Present when bit 7 of Flags is set to 1)
xx xx 3 byte (optional) Color (r,g,b components)
xx xx string (optional) Skin name (zero-terminated string)
xx xx string (optional) Cell name (zero-terminated string, UTF8 encoding)
xx xx uint32 (optional) PlayerId - it is resent when bit isPlayerIdPresent of Extended Flags is set to 1. It contains pleayer ID (do not confuse with cell ID, this is player ID)

Structure of Remove Record:

Offset Type Description
0 uint32 Cell ID (which should be removed)

The Flags:

Bit Hex Mask Description
0 0x01 isVirus
1 0x02 isColorPresent (3 bytes with R,G,B components included into update)
2 0x04 isSkinPresent (zero terminated string with skin name included into update)
3 0x08 isNamePresent (zero terminated string with skin name included into update, UTF8 encoding)
4 0x10 isAgitated (if 1 then increases the amplitude of the waves on a blob outline)
5 0x20 isEject (if 1 then this is not a player cell, just W ejected blob)
6 0x40 isEjectEnemy (if 1 then this is W ejected blob, but it's set to 0 for self ejected blobs)
7 0x80 isExtendedFlags (if 1 then Extended Flags field is present)

The Extended Flags:

Bit Hex Mask Description
0 0x01 isPellet (if 1 then this is pellet cell)
1 0x02
2 0x04 isPlayerIdPresent (if 1 then PlayerId field is present in the record)
3 0x08
4 0x10
5 0x20
6 0x40
7 0x80

If someone knows some more details, please let me know,
I will update the table.

2) Leaderboard FFA message 0x35

Offset Value Type Description
0 0x35 byte Leaderboard FFA message code
3 xx record list FFA Records

3) Leaderboard FFA teams message 0x36

Offset Value Type Description
0 0x36 byte Leaderboard FFA message code
1 xx uint16 ?? probably the count of facebook friends
3 xx record list FFA Records

The structure of FFA Record is the following:

Offset Type Description
0 byte RecordFlags
xx utf8 zero string (optional) Cell Name (present when isNamePresent is set)
xx uint32 (optional) Player ID (present when isPlayerIdPresent is set)

RecordFlags description:

Bit Hex Mask Description
0 0x01 (not used) ?probably isOrderPresent?
1 0x02 (optional) isNamePresent
2 0x04 (optional) isPlayerIdPresent (usually appears with isNamePresent)
3 0x08 (optional) isMe (usually appears without isNamePresent and without isPlayerIdPresent, because it's already known for the client )
4 0x10 (optional) ?probably isFriend?
5 0x20
6 0x40
7 0x80

That's it :)
Please let me know if you know more details.

History:
26.05.2018: updated description for Extended flags and leaderboard RecordFlags description

Protocol 20 - custom skin proto-message research

I found very interesting proto-message: agario_proto_User_$skins_$create_$request
But unfortunately there are no usage for this message in the web client.

    agario_proto_User_$skins_$create_$request.prototype = $extend(protohx_Message.prototype, {
        content: null,
        meta: null
    }

It has two string fields: content and meta.
But it's not so clear what content and format is expected for these fields?

Let's look how agario downloading custom skins. For example, here is a data of custom skin:

At a glance, it looks that the meta field should contains meta xml file the same as downloaded from agario server. But what about content field?

Any idea on how to place my custom skin from PNG file into these two string fields? (content and meta)
๐Ÿ˜Š

Share

Can you share us on how you do reverse engineering to get these protocol specification? For example, which tools do you use? This is important because other (many) people can help maintaining the specficiation.

Packet 128

  • Sent from server to client
  • Example data: [128]

This packet asks client to reload agario.core.js, maybe due to outdate version of agario.core.js.

Protocol 18 - Battle Royale

sv_protocol 18
sv_secret 0x00007539
sv_versionClient 3.0.9
sv_versionProto 9.0.2
Server 20.0.3

Almost all is the same, but there are some new messages were introduced.
Primarily related to the new BattleRoyale game mode.
Here it is:

F2 - SERVER TIME

B0 - BATTLE TIMER

B1 - BATTLE START

B2 - BATTLE AREA

B3 - BATTLE EVENT

B4 - BATTLE RESULT

If you have any info about these messages, please let me know

First two authorisation tokens

I got another auth tokens

new Int8Array([-2,6,0,0,0]);
new Int8Array([-1,-59,42,64,54]);

Can be the second frame different!?

Packet 17

Send to split

Receive: contain view update

Protocol 21

idk whats new but its a thing
SERVER SECRET IS 30503

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.