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 archive_postsperpage - assumed 'archive_postsperpage' (this will throw an Error in a future version of PHP) in ..../archive/index.php on line 456
NetworkMessage Creating a new [Archive] - Forums

PDA

View Full Version : NetworkMessage Creating a new



vincity
11-03-2014, 05:16 PM
In that code i have a exception.. my buffer always is 126 bytes long... so i have a diff of 2 between temp and usable area of buffer. Why i have that ? is a xteaKey Problem ? A protocol problem ? where is my mistake ?



Here information about how i try make that instance.


//Rsa class
public static bool RsaEncrypt(BigInteger e, BigInteger m, ref byte[] buffer, int position)
{

byte[] temp = new byte[128];
try {
Array.Copy(buffer, position, temp, 0, 128);
}
catch (Exception ex)
{
Console.WriteLine("temp["+temp.Length+"] buffer["+(buffer.Length-position)+"]");
Console.WriteLine(ex.GetBaseException());

}
BigInteger input = new BigInteger(temp);
BigInteger output = input.modPow(e, m);
// it's sometimes possible for the results to be a byte short
// and this can break some software so we 0x00 pad the result
Array.Copy(GetPaddedValue(output), 0, buffer, position, 128);


return true;
}

//NetworkMessage creator
public static NetworkMessage Create(byte OS, ushort Version,
byte[] Signatures, byte[] XteaKey, string AccountName, string Password, bool OpenTibia)
{
NetworkMessage msg = new NetworkMessage(149);
msg.AddByte(0x95);
msg.AddByte(0x00);
msg.Position += 4;
msg.AddByte(0x01);
msg.AddUInt16(OS);
msg.AddUInt16(Version);
msg.AddBytes(Signatures);
int offset = msg.Data.Length;
int rsaStart = msg.Position;
msg.AddByte(0x0);
msg.AddBytes(XteaKey);
msg.AddString(AccountName);
msg.AddString(Password);
int toAdd = 128 - (msg.Position - 6 - rsaStart);
System.Console.WriteLine("offset " + offset + " rsaStart " + rsaStart + " " + toAdd);
msg.RsaOTEncrypt(23);
msg.AddAdler32();
return msg;
}


byte[] xteaKey = new byte[16];
rand.NextBytes(xteaKey);
// Instancing a new NetworkMessage
NetworkMessage networkMessage = LoginServerRequestPacket.Create(
(byte)2, // SO Version
(ushort)860, // Tibia Version
(new byte[12]{0x7A,0x60,0x3D,0x49,0x7C,0x4E,0x3D,0x49,0x78,0x41 ,0x14,0x49}), // Signature is Right ?
xteaKey, // key generate above
"1", //user
"1", //passwd
true // OpenTibia
);



Topics unsolved about login protocol.

http://tpforums.org/forum/threads/4881-C-Clientless-bot-for-8-6?highlight=AddPaddingBytes
http://tpforums.org/forum/threads/4704-C-8-57-login-packet-structure-what-s-wrong-here?highlight=AddPaddingBytes


I really dont have any reference to that problem.
{ Remember that code dont use client it is not a possibility }

vincity
11-04-2014, 06:06 PM
bring up my post

vincity
11-06-2014, 06:17 PM
bring up my post

vincity
11-07-2014, 11:05 PM
bring up my post

vincity
11-10-2014, 01:31 AM
bring up my post

Cater
11-10-2014, 12:20 PM
Try that.

NetworkMessage msg = new NetworkMessage(0x94);
msg.AddByte(0x94); // implementing msg.SetSize() instead of calculating by yourself would be better
msg.AddByte(0x00);
msg.Position += 4;
//msg.AddByte(0x01); ?
msg.AddUInt16(OS);
msg.AddUInt16(Version);
msg.AddBytes(Signatures);
int offset = msg.Data.Length;
int rsaStart = msg.Position;
msg.AddByte(0x0);
msg.AddBytes(XteaKey);
msg.AddString(AccountName);
msg.AddString(Password);
int toAdd = 128 - (msg.Position - rsaStart);
System.Console.WriteLine("offset " + offset + " rsaStart " + rsaStart + " " + toAdd);
msg.RsaOTEncrypt(rsaStart);
msg.AddAdler32();

Hard to tell without rest of code, also this may help you
https://github.com/opentibia/server/blob/master/src/protocollogin.cpp

vincity
11-10-2014, 07:59 PM
im using default clientless class from tibia api with some modifications in tibiaapi class ( for understand how in 8 60 login. )


I will post here.. ( that project is focused in debuging so have some ugly things )

Here project..
@Cater
https://mega.co.nz/#!QchgFCKT!khL6-Rq4d3cZUurNRNT6QBg49JYTDs1Q_rRClOeg6Yo

Cater
11-11-2014, 03:36 AM
http://speedy.sh/Xrr8a/Mono.zip

vincity
11-11-2014, 06:58 PM
It working O:
I will check what i do wrong..

Thnkx bro you help me alot


Now I will try understand gameServer join packets omg..