Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Nostale
You last visited: Today at 11:03

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



c# gamePacket decryption

Discussion on c# gamePacket decryption within the Nostale forum part of the MMORPGs category.

Reply
 
Old   #1
 
0Lucifer0's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 1,005
Received Thanks: 1,018
c# gamePacket decryption

Hi. I try to create a world server in c# for my own learning but i have a probleme with uncrypt packet...
This is the code i have in c# (translate of the trollface's C++ code thanks to him)
but there is a big probleme with my code i've replace char by byte witch is equivalent in the most of case but not in this case... In fact byte = 1 byte( \o/) and it's seems that in c++ char is 4byte:

how can i change this code in order to make it work?
Thanks in advance.
Code:
  public static string DecryptGamePacket(int session_id, byte[] str, int length)
        {

            string encrypted_string = "";
            int session_key = session_id & Convert.ToChar(0xFF);
            long session_number = Convert.ToChar(session_id >> 6);//Comprendre ca
            session_number &= Convert.ToChar(0xFF);
            session_number &= Convert.ToInt64(0x80000003);//Comprendre ca

            switch (session_number)
            {
                case 0:
                    for (int i = 0; i < length; i++)
                    {
                        int firstbyte = Convert.ToChar(Convert.ToChar(session_key) + Convert.ToChar(0x40));
                        int highbyte = Convert.ToInt32(Convert.ToInt32(str[i]) - Convert.ToInt32(firstbyte));
                        encrypted_string += highbyte;
                    }
                    break;

                case 1:
                    for (int i = 0; i < length; i++)
                    {
                       char firstbyte = Convert.ToChar(session_key + 0x40);
                       int highbyte = Convert.ToInt32((int)str[i] + (int)firstbyte);
                        encrypted_string += highbyte;
                    }
                    break;

                case 2:
                    for (int i = 0; i < length; i++)
                    {
                        char firstbyte = Convert.ToChar(session_key + 0x40);
                        int highbyte = Convert.ToInt32((int)str[i] - (int)firstbyte ^ 0xC3);
                        encrypted_string += highbyte;
                    }
                    break;

                case 3:
                    for (int i = 0; i < length; i++)
                    {
                        char firstbyte = Convert.ToChar(session_key + 0x40);
                        int highbyte = Convert.ToInt32((int)str[i] + firstbyte ^ 0xC3);
                        encrypted_string += highbyte;
                    }
                    break;

                default:
                    encrypted_string += 0xF;
                    break;
            }

            List<string> temp = new List<string>(encrypted_string.Split(Function.getextendedascii(0xFF)[0]));

            string save = "";

            for (int i = 0; i < temp.Count; i++)
            {
                save += DecryptGamePacket2(Function.ToByte(temp[i]));
                save += 0xFF;
            }

            return save;

        } public static string DecryptGamePacket2(byte[] str)
        {
              string decrypted_string="";
	char[] table = {' ','-','.','0','1','2','3','4','5','6','7','8','9','n'};
	int count = 0;
	byte len;
	byte highbyte;
    byte lowbyte;
	int str_length = Function.strlen(str);

	for (count = 0; count < str_length; )
	{
		if (str[count] <= 0x7A)
		{
			len = str[count];

			for (int i = 0; i < (int)len; i++)
			{
				count++;
				decrypted_string += Convert.ToChar((int)str[(int)count] ^ (int)0xFF);
			}

			count++;
		} else
		{
			len = str[count];
			len &= 0x7F;

			for (int i = 0; i < (int)len;)
			{
				count++;

				highbyte = str[count];
				highbyte &= 0xF0;
				highbyte >>= 0x4;

				lowbyte = str[count];
				lowbyte &= 0x0F;

				if (highbyte != 0x0 && highbyte != 0xF)
				{
					decrypted_string += table[highbyte-1];
					i++;
				}

				if (lowbyte != 0x0 && lowbyte != 0xF)
				{
					decrypted_string += table[lowbyte-1];
					i++;
				}
			}
			count++;
		}
	}

	return decrypted_string;
            
            }
0Lucifer0 is offline  
Old 03/14/2015, 14:55   #2
 
elite*gold: 0
Join Date: Nov 2014
Posts: 180
Received Thanks: 157
You must edit the code using CODE tag,
*-OMG-* is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
[Help] Rsa Decryption
04/21/2014 - .NET Languages - 1 Replies
I am trying to decrypt a RSA encrypted string, which i encrypted with phpseclib, with vb.net. The problem: I generated a keypair (public and private) with phpseclib and enrcypted the string with php and publickey. Now i want to decrypt this with a simple vb.net tool. but i can't load the private key i generated with phpseclib... Can anybody help me, how to import or load the private key into vb.net, so that i can decrypt messages? Thanks!
Rc4 decryption
10/22/2012 - General Coding - 3 Replies
Hallo Bin auf RC4 Verschlüsselung gestoßen. Wollte mal nachforschen, wie schwer diese zu cracken ist. Wer damit schon Erfahrung hat, bitte um Einstiegshilfe, Wo soll ich anfagen? Überhaupt möglich zu cracken ohne key? Key rausfinden?
XFS Decryption?
11/29/2011 - General Coding - 4 Replies
Hey, ich hab ein Problem, und zwar will ich eine Datei decrypten, die 700MB groß ist, und eine XFS ist. Womit könnte ich das decrypten? Weiß das jemand? Falls jemand sich daran antasten will, kann er gerne eine gleiche Datei runterladen, die aber nur 4kb groß ist. --
HELP Item Decryption
10/24/2009 - CO2 Private Server - 2 Replies
When i use the one from ElitePvpers, then when i click it to decrypt,ecrypt or what ever. Then nothing happens to it. The file stays with Chinese, so what do i do? The one that help me will get thousand thanks:handsdown:
after decryption
05/20/2009 - Soldier Front Philippines - 10 Replies
pagkatpos nun ano sunod? san makikita ung mga details nung file na nadecrypt?



All times are GMT +1. The time now is 11:03.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.