Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
[C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)
Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

  1. #1

    [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    Hello,

    So after studying some books about C# I'm trying to create a proxy, but first I want to get a login packet from Tibia 7.6, as far as I know it doesn't needs any encryption or RSA, or Adler32 Checksum stuff.

    So I just made a simple code to get the first receivedbuffer from the Client's connection, and this is how my code is starting to look like;

    [code=c#]
    public string FirstReceivedBuffer()
    {
    int i;

    while ((i = m_Stream.Read(m_ReceivedBuffer, 0, m_ReceivedBuffer.Length)) != 0)
    {
    m_ReceivedBufferString = null;

    //m_ReceivedBufferString = System.Text.Encoding.ASCII.GetString(m_ReceivedBuf fer, 0, i);
    m_ReceivedBufferString = System.Text.ASCIIEncoding.ASCII.GetString(m_Receiv edBuffer);

    return "Received Buffer: " + m_ReceivedBufferString;
    }
    return "Received Buffer: " + m_ReceivedBufferString;
    }
    [/code]

    And the result;



    Uploaded with ImageShack.us

    As you can see there are weird stuff in there, but the "bbbbbb" characters are the password I placed in the password text box in the client.

    Someone can tell me what's wrong?. I tho I was gonna get bytes like;

    Code:
    01 01 account bytes 01 01 password bytes
    But totally no clue.

  2. #2
    Senior Member
    Join Date
    Apr 2008
    Posts
    689

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    Passing a number to System.Text.ASCIIEncoding.ASCII.GetString won't give you a string with the corresponding number. Instead, it will give you the corresponding character that is encoded by that number.
    You can look at tibiaapi's packet analyzer for code on how to do the appropriate conversion.

  3. #3
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    I'm guessing you want BitConverter.ToString(byte[])

  4. #4

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    Thank you! It's working now.

    However, my Buffer's sizes are 16394 and it's filling my console window until I see no packet structures but 0x00, is there a way just to show the length of the buffer, or resize it?.

    Anyway, it's working now but on the packet I can't see the account information, what's wrong?.
    Besides the the first byte of the buffer seems to change everytime I type a different account number, I can see the password tho, but the from buffer[3] to buffer[13] are like setup bytes, i dunno what does they contain since no matter how many times i change my account or password they look the same, I'm seen a protocol76.h file from OTServ, but seems not working for me tho.

    Edit; I think ima try on Tibia 8.74 with XTea Encryption files from SharpOT which I haven't see not even a piece of code.

  5. #5
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    Here's the packet structure for logging in to login server (note: account number, not account name):
    2 byets packet length
    1 byte packet type
    2 bytes OS (1=linux, 2=windows)
    2 bytes tibia client version (i.e. 7.4=740, 7.6=760)
    12 bytes files version (tibia.dat, tibia.spr, tibia.pic)
    4 bytes account number
    2 bytes password length
    x bytes password

    edit: use Array.Copy() to get rid of the superfluous bytes

  6. #6

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    Ima check this one just wait 'till the VS 2010 Installation wizard ends installing C# since I only had C++.

  7. #7

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    Aight so I got the packet and I can read it's information, however, somehow if my password length is higher than 4 characters it will debug my app.

    This is the code I'm currently using;

    [code=c#]
    Packet.Length = BitConverter.ToInt16(t, 0);
    Packet.Version = BitConverter.ToInt16(t, 5);
    Packet.OS = BitConverter.ToInt16(t, 3);
    Packet.Type = t[2];
    Packet.TibiaDat = BitConverter.ToInt32(t, 7);
    Packet.TibiaSpr = BitConverter.ToInt32(t, 11);
    Packet.TibiaPic = BitConverter.ToInt32(t, 15);
    Packet.AccountNumber = BitConverter.ToInt32(t, 19);
    Packet.PasswordLength = BitConverter.ToInt16(t, 23);
    Packet.Password = Encoding.ASCII.GetString(t, 25, Packet.PasswordLength);//25
    Console.WriteLine("Length: " + Packet.Length.ToString());
    Console.WriteLine("Ver: " + Packet.Version.ToString());
    Console.WriteLine("OS: " + Packet.OS.ToString() + " - 2 = Windows");
    Console.WriteLine("Type: " + "0x01");
    Console.WriteLine("TibiaDat: " + Packet.TibiaDat.ToString());
    Console.WriteLine("TibiaSpr: " + Packet.TibiaSpr.ToString());
    Console.WriteLine("TibiaPic: " + Packet.TibiaPic.ToString());
    Console.WriteLine("AccountNumber: " + Packet.AccountNumber.ToString());
    Console.WriteLine("Password: " + Packet.Password.ToString());
    Console.WriteLine("PasswordLength: " + Packet.PasswordLength.ToString());
    [/code]

    Edit;

    Dumb me forgot to change the buffer size...



    Uploaded with ImageShack.us

  8. #8

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    For gods sake! I formatted my PC and while remaking my partitions I lost the source code '-,.,-'

    Guess I'll need to remake it with a Tutorial so anyone interested may try it on too.

  9. #9
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    I'm not sure if the data files (.pic, .spr and .dat) are in correct order. If you want to be sure, read the first 4 bytes of each file and compare the data to the packet (you can read binary files using BinaryReader)

    edit: You might be unfamiliar with streams, so here's a piece of example code:
    [code=c#]
    List<uint> data = new List<uint>();
    using (FileStream filestream = File.OpenRead("path to tibia.dat/spr/pic")) // you can also use File.Open() if you'd like
    {
    using (BinaryReader binreader = new BinaryReader(filestream))
    {
    data.Add(binreader.ReadUInt32());
    }
    }
    // now compare these values to the packet
    [/code]
    edit2: Streams and the File class are part of System.IO, so you can access them by either adding using System.IO; in your class or by calling them from System.IO directly (System.IO.FileStream for example)

  10. #10

    RE: [C#] Trying to get a login packet from TcpListener and TcpClient (Tibia 7.6)

    Quote Originally Posted by Blaster_89
    I'm not sure if the data files (.pic, .spr and .dat) are in correct order. If you want to be sure, read the first 4 bytes of each file and compare the data to the packet (you can read binary files using BinaryReader)

    edit: You might be unfamiliar with streams, so here's a piece of example code:
    [code=c#]
    List<uint> data = new List<uint>();
    using (FileStream filestream = File.OpenRead("path to tibia.dat/spr/pic")) // you can also use File.Open() if you'd like
    {
    using (BinaryReader binreader = new BinaryReader(filestream))
    {
    data.Add(binreader.ReadUInt32());
    }
    }
    // now compare these values to the packet
    [/code]
    edit2: Streams and the File class are part of System.IO, so you can access them by either adding using System.IO; in your class or by calling them from System.IO directly (System.IO.FileStream for example)
    Thank you, but I really don't mind about the signatures, since I'm first learning this thing of Packets and Proxies. So now, you got any info about the CharacterList Packet Structure?¿. So I can try writting it to the stream of the client, it will be the first advancement to the code.

    Already re-wrote the code with also included the NETWORKMESSAGE from SharpOT, and is working really well.

    I hesitate you to tell me the structure of the characterlist packet.[hr]
    Small Dumb & Small Edit;

    Why i can't send a disconnected message?.

    [code=c#]
    Packet Size, Space, Type, Space, MsgLen, MsgByte = Num 1
    Server.Client.GetStream().Write(new byte[]{Convert.ToByte(6), 0x00, 0x14, 0x00, 0x01, 0x31}, 0, 6);
    [/code]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •