示例#1
0
        static void HandleArguments(string[] args)
        {
            if (args.Length < 1)
            {
                string commands = string.Empty;
                commands += RequestFile();

                if (Ask("Would you like to disable RC4 encryption?"))
                    commands += "\ndisablerc4";

                if (Ask($"Default Exponent(e): {Exponent}\r\nDefault Modulus(n): {KeepEnds(Modulus, 25)}\r\nWould you like to use your own RSA keys?"))
                {
                    if (Ask("Would you like to generate a new pair of RSA keys? | "))
                    {
                        WriteLine("Generating 1024-bit keys...");
                        var exchange = HKeyExchange.Create(1024);

                        string e = exchange.Exponent.ToString("x");
                        Console.WriteLine("Exponenet(e): " + e);
                        commands += "\ne:" + e;

                        string n = exchange.Modulus.ToString("x");
                        Console.WriteLine("Modulus(n): " + KeepEnds(n, 25));
                        commands += "\nn:" + n;

                        PrivateExponent = exchange.PrivateExponent.ToString("x");
                        Console.WriteLine("Private Exponent(d): " + KeepEnds(PrivateExponent, 25));
                    }
                    else
                    {
                        Console.Write("Custom Exponent(e): ");
                        commands += ("\ne:" + Console.ReadLine());

                        Console.Write("Custom Modulus(n): ");
                        commands += ("\nn:" + Console.ReadLine());
                    }
                    Console.WriteLine("---------------");
                }

                if (!Ask("Would you like to compress the file once reconstruction is finished?"))
                    commands += "\nskipcompress";

                if (Ask("Example: Outgoing[XXXX](%HASH%): _-AB(arg1:int, arg2:String, arg3:Boolean)\r\nWould you like to dump a file containing a list of headers paired with their associated type/handler?"))
                {
                    commands += "\ndumpheaders";
                    if (Ask("Example #1: connection.send(new _-AB());\r\nExample #2: addHabboConnectionMessageEvent(new _-CD(this._-EF));\r\nWould to like to include references of the message type in the hashing process?"))
                        commands += "\nreferencescan";
                }
                args = commands.Split('\n');
                Console.Clear();
            }

            Client = new HFlash(args[0]);
            for (int i = 1; i < args.Length; i++)
            {
                string[] values = args[i].Split(':');
                switch (values[0].ToLower())
                {
                    case "e":
                    {
                        int exponent = 0;
                        string e = values[1];
                        if (int.TryParse(e, NumberStyles.HexNumber,
                            CultureInfo.InvariantCulture, out exponent))
                        {
                            IsCustomE = (exponent != Exponent);
                            Exponent = exponent;
                        }
                        break;
                    }

                    case "n":
                    {
                        string n = values[1];
                        IsCustomN = (n != Modulus);
                        Modulus = n;
                        break;
                    }

                    case "disablerc4":
                    DisableRC4 = true;
                    break;

                    case "skipcompress":
                    CompressClient = false;
                    break;

                    case "dumpheaders":
                    DumpHeaders = true;
                    break;

                    case "referencescan":
                    ReferenceScan = true;
                    break;
                }
            }
        }
示例#2
0
        static IList<Tuple<ushort, string, ASInstance>> OrganizeByHash(IDictionary<ushort, ASClass> messages, HFlash flash, bool isOutgoing)
        {
            var organizedMessages = new List<Tuple<ushort, string, ASInstance>>(messages.Count);
            var hashedMessages = new Dictionary<string, List<Tuple<ushort, string, ASInstance>>>();
            foreach (ushort header in messages.Keys)
            {
                ASClass messageClass = messages[header];
                string hash = flash.GetHash(messageClass, ReferenceScan, isOutgoing);

                var messageData = new Tuple<ushort, string, ASInstance>(
                    header, hash, messageClass.Instance);

                if (!hashedMessages.ContainsKey(hash))
                {
                    hashedMessages[hash] =
                        new List<Tuple<ushort, string, ASInstance>>();
                }
                hashedMessages[hash].Add(messageData);
            }

            return hashedMessages.Values
                .OrderBy(l => l.Count)
                .SelectMany(l => l).ToList();
        }