Habbo V1 RC4 Encryption - C#

Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Club Slinky Helsinki Quackster is online now
    SubscriberRank
    Dec 2010 Join Date
    AustraliaLocation
    3,431Posts

    Habbo V1 RC4 Encryption - C#

    Hello,

    So I know this is 21 years late but I decided to try and get RC4 working in the very first version of Habbo, since we have the decompiled Habbo shockwave files, this was a task that only took me two days to complete!

    Of course the RC4 in V1 can always be bypassed, but it's a cool feature to have regardless!

    Screenshots:



    How to use:

    After you receive VERSIONCHECK, generate a public key (can be anything with letters and numbers) and then send these two packets below:

    Code:
    player.Send(new EncryptionOnComposer());
    player.Send(new SecretKeyComposer(player.Connection.PublicKey));
    Translates to

    Code:
    ##ENCRYPTION_ON{13}#
    ##SECRET_KEY{13}PUBLIC_KEY{13}#
    Initialise the RC4 with the decoded public key:

    Code:
    public void InitialiseEncryption()
    {
        if (Encryption != null)
        {
            return;
        }
    
        Encryption = new RC4();
        Encryption.SetKey(SecretKey.SecretDecode(PublicKey));
    
        Channel.Pipeline.AddFirst("encryption", new EncryptionDecoder(this.Encryption));
    }
    And then any incoming packets after this will be enciphered by the client and must be deciphered by the server:

    Code:
    byte[] payload = new byte[buffer.ReadableBytes];
    buffer.ReadBytes(payload);
    
    var messagePayload = StringUtil.GetEncoding().GetString(payload);
    var decodedPayload = StringUtil.GetEncoding().GetBytes(this.rc4.Decipher(messagePayload));
    
    var result = Unpooled.Buffer();
    result.WriteBytes(decodedPayload);
    output.Add(result);
    The RC4 and SecretKey classes I've written:

    Ported from:

    https://github.com/Quackster/habbo_s...eScript/RC4.ls

    https://github.com/Quackster/habbo_s...ecret%20Key.ls

    RC4:

    Code:
    /**
     * Habbo Hotel V1 RC4 class by Quackster (Alex)
     * Written in December 2021
     */
    
    using System;
    using System.Globalization;
    
    namespace Euclid.Util.Encryption
    {
        public class RC4
        {
            private int i;
            private int k;
            private int j;
    
            private int[] sbox;
            private int[] skey;
    
            /// <summary>
            /// Create key, not used, but ported from Habbo V1 RC4 class written in Lingo
            /// </summary>
            public int CreateKey()
            {
                var k = "";
                var random = new Random();
                var i = 0;
    
                while (i < 4)
                {
                    k += int2hex(random.Next(256) - 1);
                    i++;
                }
    
                return Math.Abs(hex2int(k));
            }
    
            /// <summary>
            /// Initialise the encryption class
            /// </summary>
            /// <param name="myKey"></param>
            public void SetKey(int myKey)
            {
                // Console.WriteLine("New key assigned to RC4: " + myKey);
                
                skey = new int[256];
                sbox = new int[256];
    
                i = 0;
                k = 0;
    
                var tempKey = Convert.ToString(myKey);
    
                while (i <= 255)
                {
                    skey[i] = (int)tempKey[i % tempKey.Length];
                    sbox[i] = i;
                    i = 1 + i;
                }
    
                i = 0;
                j = 0;
    
                while (i <= 255)
                {
                    j = (j + sbox[i] + skey[i]) % 256;
                    k = sbox[i];
                    sbox[i] = sbox[j];
                    sbox[j] = k;
                    i = 1 + i;
                }
    
    
                i = 0;
                j = 0;
    
                //Print(sbox);
                //Print(skey);
            }
    
            /// <summary>
            /// Recreate the enciphering performed on the client
            /// </summary>
            public string Encipher(string data)
            {
                string cipher = string.Empty;
                int a = 0;
    
                while (a < data.Length)
                {
                    cipher += int2hex(data[a] ^ shift());
                    a++;
                }
    
                return cipher;
            }
    
            /// <summary>
            /// Decipher incoming packets from client
            /// </summary>
            public string Decipher(string data)
            {
                string cipher = string.Empty;
                int a = 0;
    
                while (a < data.Length)
                {
                    var t = hex2int(data.Substring(a, 2));
                    cipher += (char)(t ^ shift());
                    a += 2;
                }
    
                return cipher;
            }
    
            /// <summary>
            /// Shift RC4 tables
            /// </summary>
            private int shift()
            {
                i = (i + 1) % 256;
                j = (j + sbox[i]) % 256;
                var temp = sbox[i];
                sbox[i] = sbox[j];
                sbox[j] = temp;
                return sbox[(sbox[i] + sbox[j]) % 256];
            }
    
            /// <summary>
            /// int2hex ported from Lingo
            /// </summary>
            public static string int2hex(int aint)
            {
                var digits = "0123456789ABCDEF";
                var hexstr = "";
    
                if (aint <= 0)
                    hexstr = "00";
                else
                {
                    while (aint > 0)
                    {
                        var sd = (aint % 16);
                        aint /= 16;
                        hexstr = digits[sd] + hexstr;
                    }
                }
    
                if ((hexstr.Length % 2) == 1)
                    hexstr = "0" + hexstr;
    
                return hexstr;
            }
    
            /// <summary>
            /// hex2int method used for deciphering
            /// </summary>
            public static int hex2int(string ahex)
            {
                return int.Parse(ahex, NumberStyles.HexNumber);
            }
            
            /// <summary>
            /// Used for debugging tables
            /// </summary>
            private void Print(int[] array)
            {
                foreach (int i in array)
                    Console.Write(i + ", ");
    
                Console.WriteLine();
            }
        }
    }
    SecretKey:

    Code:
    /**
     * Habbo Hotel V1 RC4 class by Quackster (Alex)
     * Written in December 2021
     */
    
    namespace Euclid.Util.Encryption
    {
        public class SecretKey
        {
            /// <summary>
            /// Decode the secret sent from client
            /// </summary>
            public static int SecretDecode(string key)
            {
                string table = key.Substring(0, key.Length / 2); ;
                string tempKey = key.Substring(key.Length / 2);
    
                int checkSum = 0;
                int i = 0;
    
                while (i < tempKey.Length)
                {
                    var a = table.IndexOf(tempKey[i]);
    
                    if (a % 2 == 0)
                    {
                        a *= 2;
                    }
    
                    if (i % 3 == 0)
                    {
                        a *= 3;
                    }
    
                    if (a < 0)
                    {
                        a = (tempKey.Length % 2);
                    }
    
                    checkSum += a;
                    i++;
                }
    
                return checkSum;
            }
        }
    }
    Last edited by Quackster; 30-12-21 at 11:48 PM.
    The Habbo archives: http://alex-dev.org/archive/


  2. #2
    The Legend Returns vista4life is offline
    True MemberRank
    Mar 2007 Join Date
    The NetherlandsLocation
    842Posts

    Re: Habbo V1 RC4 Encryption - C#

    Well.. i'm a oldskooler, so i guess i will response to this. Alex u did a great job again. handfull for guys who loves the old retro's. I miss those days :)

    And happy new year buddy, and for everyone who knows me.

    Smell ya later.

  3. #3
    Account Upgraded | Title Enabled! Dimii15 is offline
    True MemberRank
    Jan 2008 Join Date
    The NetherlandsLocation
    415Posts

    Re: Habbo V1 RC4 Encryption - C#

    Quote Originally Posted by vista4life View Post
    Well.. i'm a oldskooler, so i guess i will response to this. Alex u did a great job again. handfull for guys who loves the old retro's. I miss those days :)

    And happy new year buddy, and for everyone who knows me.

    Smell ya later.
    Back when we were all setting up Debbo and Holograph as kids behind a slow pc with MSN messenger on the background

    and @Quackster nice release, I don't think I have the knowledge to do anything with this but the more complete the better of course!

  4. #4
    Club Slinky Helsinki Quackster is online now
    SubscriberRank
    Dec 2010 Join Date
    AustraliaLocation
    3,431Posts

    Re: Habbo V1 RC4 Encryption - C#

    Quote Originally Posted by vista4life View Post
    Well.. i'm a oldskooler, so i guess i will response to this. Alex u did a great job again. handfull for guys who loves the old retro's. I miss those days :)

    And happy new year buddy, and for everyone who knows me.

    Smell ya later.
    Hey thank you, speaking of which, did you ever do any encryption stuff for v30+?
    The Habbo archives: http://alex-dev.org/archive/

  5. #5
    Newbie Veelox is offline
    MemberRank
    Nov 2020 Join Date
    4Posts

    Re: Habbo V1 RC4 Encryption - C#

    Quote Originally Posted by vista4life View Post
    Well.. i'm a oldskooler, so i guess i will response to this. Alex u did a great job again. handfull for guys who loves the old retro's. I miss those days :)

    And happy new year buddy, and for everyone who knows me.

    Smell ya later.
    Now there's a name I certainly remember.. welcome back. Quite suprising how many users are still interested in old school, shockwave development.

    Anyway, excellent work as always @Quackster this shit makes me feel hella old.
    Formerly Roper but lost account details.

  6. #6
    Account Upgraded | Title Enabled! AWA is offline
    True MemberRank
    Feb 2008 Join Date
    1,320Posts

    Re: Habbo V1 RC4 Encryption - C#

    I remember people saying that decompiling the old Shockwave clients would be impossible – it's cool to see that they were proven wrong! There were several features I wanted to implement back in the day, but I could only do so much with missing packet logs.

    Anyways, nice to see you're still making cool stuff @Quackster, and happy new year!

  7. #7
    The World Is Yours PixelPro is offline
    GammaRank
    Jun 2007 Join Date
    UKLocation
    3,253Posts

    Re: Habbo V1 RC4 Encryption - C#

    It's mind blowing to still see this old school stuff in 2021/22 and I'm glad you are keeping the retro development alive. Well done.

    Do people still play old school retros anymore? Let alone the official Habbo Hotel?

  8. #8
    Registered alcom98 is online now
    MemberRank
    May 2008 Join Date
    8Posts

    Re: Habbo V1 RC4 Encryption - C#

    Quote Originally Posted by PixelPro View Post
    Do people still play old school retros anymore? Let alone the official Habbo Hotel?
    Sure. That's the nostalgia. The modern hotel or any fancy modded hotel don't have that for me. If I need a kick of nostalgia then I start the client on the SDD and sit in a kind of time capsule. That's why I'm still interested in the first place. And thanks to Quackster and everyone who contributes, the experience is so good that i can really immerse myself. They keep something great alive

  9. #9
    Club Slinky Helsinki Quackster is online now
    SubscriberRank
    Dec 2010 Join Date
    AustraliaLocation
    3,431Posts

    Re: Habbo V1 RC4 Encryption - C#

    Quote Originally Posted by AWA View Post
    I remember people saying that decompiling the old Shockwave clients would be impossible – it's cool to see that they were proven wrong! There were several features I wanted to implement back in the day, but I could only do so much with missing packet logs.

    Anyways, nice to see you're still making cool stuff @Quackster, and happy new year!
    Yeah understandable, being able to decompile Shockwave is a relatively recent development, probably only a few years old now :>

    The trick is to decompress the .cct and .dcr and then have the ability to read the bytecode.
    The Habbo archives: http://alex-dev.org/archive/

  10. #10
    <insert title here> Shorty is offline
    Alpha MaleRank
    Feb 2007 Join Date
    United KingdomLocation
    1,860Posts

    Re: Habbo V1 RC4 Encryption - C#

    Quote Originally Posted by vista4life View Post
    Well.. i'm a oldskooler, so i guess i will response to this. Alex u did a great job again. handfull for guys who loves the old retro's. I miss those days :)

    And happy new year buddy, and for everyone who knows me.

    Smell ya later.
    Another oldie checking in! I'm no longer around the scene these days, however this brings back some fond memories! Nice to see the release, hope you're well!

  11. #11
    ThuGie.NL - Webmaster ThuGie is offline
    True MemberRank
    Apr 2006 Join Date
    NetherlandsLocation
    1,129Posts

    Re: Habbo V1 RC4 Encryption - C#

    Haha, nice going, never thought about enabling it to be honest.
    But its fun to have :).
    Hate me or Love me, Just dont bother me!
    Only argument i lose, is a argument with my gf, where even when i am right i lose

  12. #12
    I use to love it more! Jmandupree is offline
    True MemberRank
    Oct 2009 Join Date
    /ragezone/homeLocation
    996Posts

    Re: Habbo V1 RC4 Encryption - C#

    I remember back in the day when I got my first server to start how exciting it was thanks for the memories !

  13. #13
    ThuGie.NL - Webmaster ThuGie is offline
    True MemberRank
    Apr 2006 Join Date
    NetherlandsLocation
    1,129Posts

    Re: Habbo V1 RC4 Encryption - C#

    I also remember my first habbo server, it was such a headache figuring out parts of the protocol as it just didnt exist in any of the already pre-existing servers..
    No decompiler as well pff.
    Hate me or Love me, Just dont bother me!
    Only argument i lose, is a argument with my gf, where even when i am right i lose

  14. #14
    Alpha Member Emily is offline
    Alpha MaleRank
    Oct 2012 Join Date
    The NetherlandsLocation
    2,407Posts

    Re: Habbo V1 RC4 Encryption - C#

    I wish more encryptions for later versions (v22+ or something), especially for the v31+ era, sadly it's too complicated for me. I really appreciate your amazing contributions even though they're for older versions.
    We sail onwards. We don't know where we'll end up, but we'll go where the river takes us. Past everything we fought for, past all memories, onto something new. You'll be missed, my old friend, but it's time to part ways.

  15. #15
    Club Slinky Helsinki Quackster is online now
    SubscriberRank
    Dec 2010 Join Date
    AustraliaLocation
    3,431Posts

    Re: Habbo V1 RC4 Encryption - C#

    Quote Originally Posted by Emily View Post
    I wish more encryptions for later versions (v22+ or something), especially for the v31+ era, sadly it's too complicated for me. I really appreciate your amazing contributions even though they're for older versions.
    You're welcome! I could look into doing encryption for most Habbo shockwave versions for v9-20~ something (sadly when it gets to v30+ they introduced the Diffie-Hellman key exchange and that is far beyond my knowledge and I'm not sure if I can do that on my own). I know Woodpecker has v14 RC4 done, however.
    The Habbo archives: http://alex-dev.org/archive/



Page 1 of 2 12 LastLast

Advertisement