The Password Cipher for Patch 5532+!!

06/30/2012 00:40 Spirited#1
FAKE
This is 100% fake. I can't tell you how many times I've been spammed with this. I'm not trying to hide anything, I'm not trying to throw people off. The truth about this cipher is that it's not for patches 5532 and above.

Code:
namespace Conquer_Online_Server.Network.Cryptography
{
    using System;
    using System.Text;

    public sealed class ConquerPasswordCryptpographer
    {
        private byte[] defaultPass = new byte[] { 
            0, 0, 190, 0x1a, 0x92, 0x7e, 4, 0x7d, 220, 0x35, 0xe2, 80, 0xf8, 0x8e, 0x8f, 0x19, 
            0x19, 0x49, 0x43, 0xd6, 0xfd, 0xd4, 0xb2, 0x8a, 0x54, 230, 0xa6, 0x69, 0xd0, 0xa4, 0x8a, 240
         };
        private readonly byte[] key = new byte[0x200];
        private static byte[] scanCodeToVirtualKeyMap = new byte[] { 
            0, 0x1b, 0x31, 50, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0xbd, 0xbb, 8, 9, 
            0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x55, 0x49, 0x4f, 80, 0xdb, 0xdd, 13, 0x11, 0x41, 0x53, 
            0x44, 70, 0x47, 0x48, 0x4a, 0x4b, 0x4c, 0xba, 0xc0, 0xdf, 0x10, 0xde, 90, 0x58, 0x43, 0x56, 
            0x42, 0x4e, 0x4d, 0xbc, 190, 0xbf, 0x10, 0x6a, 0x12, 0x20, 20, 0x70, 0x71, 0x72, 0x73, 0x74, 
            0x75, 0x76, 0x77, 120, 0x79, 0x90, 0x91, 0x24, 0x26, 0x21, 0x6d, 0x25, 12, 0x27, 0x6b, 0x23, 
            40, 0x22, 0x2d, 0x2e, 0x2c, 0, 220, 0x7a, 0x7b, 12, 0xee, 0xf1, 0xea, 0xf9, 0xf5, 0xf3, 
            0, 0, 0xfb, 0x2f, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 130, 0x83, 0x84, 0x85, 0x86, 0xed, 
            0, 0xe9, 0, 0xc1, 0, 0, 0x87, 0, 0, 0, 0, 0xeb, 9, 0, 0xc2, 0
         };
        private static byte[] virtualKeyToScanCodeMap = new byte[] { 
            0, 0, 0, 70, 0, 0, 0, 0, 14, 15, 0, 0, 0x4c, 0x1c, 0, 0, 
            0x2a, 0x1d, 0x38, 0, 0x3a, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 
            0x39, 0x49, 0x51, 0x4f, 0x47, 0x4b, 0x48, 0x4d, 80, 0, 0, 0, 0x54, 0x52, 0x53, 0x63, 
            11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 
            0, 30, 0x30, 0x2e, 0x20, 0x12, 0x21, 0x22, 0x23, 0x17, 0x24, 0x25, 0x26, 50, 0x31, 0x18, 
            0x19, 0x10, 0x13, 0x1f, 20, 0x16, 0x2f, 0x11, 0x2d, 0x15, 0x2c, 0x5b, 0x5c, 0x5d, 0, 0x5f, 
            0x52, 0x4f, 80, 0x51, 0x4b, 0x4c, 0x4d, 0x47, 0x48, 0x49, 0x37, 0x4e, 0, 0x4a, 0x53, 0x35, 
            0x3b, 60, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x57, 0x58, 100, 0x65, 0x66, 0x67, 
            0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 110, 0x76, 0, 0, 0, 0, 0, 0, 0, 0, 
            0x45, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0x2a, 0x36, 0x1d, 0x1d, 0x38, 0x38, 0x6a, 0x69, 0x67, 0x68, 0x65, 0x66, 50, 0x20, 0x2e, 0x30, 
            0x19, 0x10, 0x24, 0x22, 0x6c, 0x6d, 0x6b, 0x21, 0, 0, 0x27, 13, 0x33, 12, 0x34, 0x35, 
            40, 0x73, 0x7e, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1a, 0x56, 0x1b, 0x2b, 0x29, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0x71, 0x5c, 0x7b, 0, 0x6f, 90, 0, 
            0, 0x5b, 0, 0x5f, 0, 0x5e, 0, 0, 0, 0x5d, 0, 0x62, 0, 0, 0, 0
         };

        public ConquerPasswordCryptpographer(string key)
        {
            int seed = 0;
            foreach (byte num2 in Encoding.ASCII.GetBytes(key))
            {
                seed += num2;
            }
            msvcrt.msvcrt.srand(seed);
            byte[] buffer = new byte[0x10];
            for (int i = 0; i < 0x10; i++)
            {
                buffer[i] = (byte) msvcrt.msvcrt.rand();
            }
            for (int j = 1; j < 0x100; j++)
            {
                this.key[j * 2] = (byte) j;
                this.key[(j * 2) + 1] = (byte) (j ^ buffer[j & 15]);
            }
            for (int k = 1; k < 0x100; k++)
            {
                for (int m = 1 + k; m < 0x100; m++)
                {
                    if (this.key[(k * 2) + 1] < this.key[(m * 2) + 1])
                    {
                        this.key[k * 2] = (byte) (this.key[k * 2] ^ this.key[m * 2]);
                        this.key[m * 2] = (byte) (this.key[m * 2] ^ this.key[k * 2]);
                        this.key[k * 2] = (byte) (this.key[k * 2] ^ this.key[m * 2]);
                        this.key[(k * 2) + 1] = (byte) (this.key[(k * 2) + 1] ^ this.key[(m * 2) + 1]);
                        this.key[(m * 2) + 1] = (byte) (this.key[(m * 2) + 1] ^ this.key[(k * 2) + 1]);
                        this.key[(k * 2) + 1] = (byte) (this.key[(k * 2) + 1] ^ this.key[(m * 2) + 1]);
                    }
                }
            }
        }

        public byte[] Decrypt(byte[] data)
        {
            byte[] buffer = new byte[data.Length];
            for (int i = 0; i < buffer.Length; i++)
            {
                bool flag = false;
                if (buffer[i] == 0)
                {
                    return buffer;
                }
                int index = (buffer[i] & 0xff) * 2;
                byte num3 = this.key[index];
                if (num3 < 0)
                {
                    num3 = (byte)(num3 + 0x80);
                    flag = true;
                }
                buffer[i] = (byte)(buffer[i] + ((byte)scanCodeToVirtualKeyMap[num3]));
                if (buffer[i] < 0)
                {
                    buffer[i] = (byte)(buffer[i] + 0x80);
                }
                if ((!flag && (buffer[i] >= 0x41)) && (buffer[i] <= 90))
                {
                    buffer[i] = (byte)(buffer[i] + 0x20);
                }
                if ((buffer[i] < 0x30) || (buffer[i] > 0x7a))
                {
                    buffer[i] = GetNumber(buffer[i]);
                }
            }
            return buffer;
        }

        public byte[] Encrypt(byte[] data)
        {
            byte[] buffer = new byte[data.Length];
            this.defaultPass.CopyTo(buffer, 0);
            for (int i = 0; i < data.Length; i++)
            {
                byte num2 = data[i];
                if ((data[i] >= 0x61) && (data[i] <= 0x7a))
                {
                    data[i] = (byte)(data[i] - 0x20);
                }
                byte num3 = virtualKeyToScanCodeMap[data[i]];
                if ((num2 >= 0x41) && (num2 <= 90))
                {
                    num3 = (byte)(num3 + 0x80);
                }
                if (num3 == 0)
                {
                    buffer[i] = 0;
                    return buffer;
                }
                int num4 = 0;
                while (num4 <= 0xff)
                {
                    byte num5 = this.key[num4 * 2];
                    if (num5 == num3)
                    {
                        goto Label_008C;
                    }
                    num4++;
                }
                continue;
            Label_008C:
                buffer[i] = (byte)num4;
            }
            return buffer;
        }


        public static byte GetNumber(byte b)
        {
            switch (b)
            {
                case 0x21:
                    return 0x39;

                case 0x22:
                    return 0x33;

                case 0x23:
                    return 0x31;

                case 0x24:
                    return 0x37;

                case 0x25:
                    return 0x34;

                case 0x26:
                    return 0x38;

                case 0x27:
                    return 0x36;

                case 40:
                    return 50;

                case 0x2d:
                    return 0x30;
            }
            return 0x35;
        }
    }
}
06/30/2012 00:54 -impulse-#2
You should have kept the indentation... the code looks so awful.

As for those who want to apply this algorithm for the latest password encryption, you should see if it fits the protocol just by peaking at what TQ sends... It's nothing big just a bit of packet analyzing, I mean after all, you do want to keep up with TQ right?
06/30/2012 01:15 Zeroxelli#3
That would be the password cipher (there's actually three, that's one of three.) that either CoGenius or ConquerAI include (Don't remember.)

It's probably either just to mess with people, outdated, or their own password cipher.
06/30/2012 01:19 Spirited#4
Quote:
Originally Posted by Zeroxelli View Post
That would be the password cipher (there's actually three, that's one of three.) that either CoGenius or ConquerAI include (Don't remember.)

It's probably either just to mess with people, outdated, or their own password cipher.
Ultimation originally released it to mess with people. It worked very well, so congrats to him. I thought it was funny until noobs started cursing at me and spamming me.