Jump to content
  • 0

About Login Packet


Hello i try to make a discord bot whit potential feature.


One my problem is try to connection in rAthena Server.
Actually i use c#


my code


            Socket soc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPAddress ip = IPAddress.Parse("");
            IPEndPoint host = new IPEndPoint(ip, 6900);


            //Static Packet
            byte packet = 0x64;
            byte[] id = Encoding.ASCII.GetBytes("Thejuster");
            byte[] pass = Encoding.ASCII.GetBytes("123456789");

            //Packet Builder
            List<byte> pacchetto = new List<byte>();

            //Assembly packet
            foreach(byte b in id)
            foreach(byte b in pass)

            //Send full pachet


When i try to connect, rAthena Login Server say this:




anyone know reason of this problem?

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 1

Structure padding screwed you up there



Add Pack = 1 to the StructLayout attribute and change version to uint since ulong is 64 bit integer (8 bytes)

Edited by Secrets
Link to comment
Share on other sites

  • 0

Tanks Zell i try whit this example.

First step is done but server cant read my username or password send

in src/loginclif.cpp




 * Received a connection request.
 * @param fd: file descriptor to parse from (client)
 * @param sd: client session
 * @param command: packet type sent
 * @param ip: ipv4 address (client)
 *  S 0064 <version>.L <username>.24B <password>.24B <clienttype>.B
 *  S 0277 <version>.L <username>.24B <password>.24B <clienttype>.B <ip address>.16B <adapter address>.13B
 *  S 02b0 <version>.L <username>.24B <password>.24B <clienttype>.B <ip address>.16B <adapter address>.13B <g_isGravityID>.B
 *  S 01dd <version>.L <username>.24B <password hash>.16B <clienttype>.B
 *  S 01fa <version>.L <username>.24B <password hash>.16B <clienttype>.B <?>.B(index of the connection in the clientinfo file (+10 if the command-line contains "pc"))
 *  S 027c <version>.L <username>.24B <password hash>.16B <clienttype>.B <?>.13B(junk)
 *  S 0825 <packetsize>.W <version>.L <clienttype>.B <userid>.24B <password>.27B <mac>.17B <ip>.15B <token>.(packetsize - 0x5C)B
 * @param fd: fd to parse from (client fd)
 * @return 0 failure, 1 success
static int logclif_parse_reqauth(int fd, struct login_session_data *sd, int command, char* ip){
	size_t packet_len = RFIFOREST(fd);


i see for command 0x64  ( Request login authentification )


S 0064 <version>.L <username>.24B <password>.24B <clienttype>.B


my code


Packet Structure

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
    struct DataPacket
        public ushort command;

        public ulong version;

        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 24)] //.24B byte, Server Code Ask 24B ( 24 Bytes )
        public String Username;

        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 24)] //Some 24 Byte Lenght
        public String Password;

        public byte clienttype;  //is wrong?

      public byte[] Serialize()
            // allocate a byte array for the struct data
            var buffer = new byte[Marshal.SizeOf(typeof(DataPacket))];

            // Allocate a GCHandle and get the array pointer
            var gch = GCHandle.Alloc(buffer, GCHandleType.Pinned);
            var pBuffer = gch.AddrOfPinnedObject();

            Marshal.StructureToPtr(this, pBuffer, false);

            return buffer;

       // this method will deserialize a byte array into the struct.
        public void Deserialize(ref byte[] data)
            var gch = GCHandle.Alloc(data, GCHandleType.Pinned);
            this = (DataPacket)Marshal.PtrToStructure(gch.AddrOfPinnedObject(), typeof(DataPacket));




DataPacket packet = new DataPacket();

            packet.command = 0x64;
            packet.version = 55;
            packet.Username = "Thejuster";
            packet.Password = "123456789";
            packet.clienttype = 0;

 var bytes = packet.Serialize();




If i try to connect whit my code, i see this on server.

I see username and password server dont read.


Normal Connection whit Ragnarok Client





Uhmmm i dont have idea for this problem.

I have download roBrowser, and see src.
because javascript and c# are similar.


i find this i on source


	// 0x64
		this.Version = 0;
		this.ID = '';
		this.Passwd = '';
		this.clienttype = 0;

//Here i think the author build a packet structure.
	PACKET.CA.LOGIN.prototype.build = function() {
		// i think is a size of all packet 
      //[2] Command + [4] ???? No have idea. + [24] Username  + [24] Password + [1] Client type
      var pkt_len = 2 + 4 + 24 + 24 + 1; 
		var pkt_buf = new BinaryWriter(pkt_len);

		pkt_buf.writeString(this.ID, 24);
		pkt_buf.writeString(this.Passwd, 24);
		return pkt_buf;



Edited by Thejuster
Link to comment
Share on other sites

  • 0

nope 😕

uhmm here are a problem.



look total size sent is 72bytes.

Simple i pack command,verion,username,password,clienttype   total = 72byte

but rAthena server ask:



static int logclif_parse_reqauth(int fd, struct login_session_data *sd, int command, char* ip){
	size_t packet_len = RFIFOREST(fd);

	if( (command == 0x0064 && packet_len < 55)  //For command 0x64 packet max lenght is 55 byte i use this. 0x64
	||  (command == 0x0277 && packet_len < 84)
	||  (command == 0x02b0 && packet_len < 85)
	||  (command == 0x01dd && packet_len < 47)
	||  (command == 0x01fa && packet_len < 48)
	||  (command == 0x027c && packet_len < 60)


my packet size is 72byte but a conditional branch on server is limited under 55byte.

Strange for me. 

No have idea for wath reason my structure is 72bytes.
I follow step by step server parameters and Unmanaged conversion.

Link to comment
Share on other sites

  • 0

Hello again try whit this error


 Connection refused: IP isn't authorised (deny/allow, ip:




changed structure to ulong and int to sbyte and work.

i have an bytes array around  51bytes total



if( (command == 0x0064 && packet_len < 55)


And i think now work but server block address


Edited by Thejuster
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.