public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
        {
            foreach (var methodDef in methodDefs)
            {
                if (!HasStrings(methodDef, "Are you sure you want to exit osu!?"))
                {
                    continue;
                }

                var @class = MappingManager.GetClass(UnobfuscatedName)
                             .OrElse(new ClassObj(UnobfuscatedName, className));
                MappingManager.AddClass(@class);

                @class.AddMethod("ExitGame", methodDef.Name); //methodSig (1): bool
                var insn = methodDef.Body.Instructions;
                if (!(insn[insn.Count - 2].Operand is MethodDef showScreenDef))
                {
                    Console.WriteLine("Can't get ShowScreen");
                    return;
                }

                @class.AddMethod("ShowScreen", showScreenDef.Name); //methodSig (1): GuiScreen

                FindKeyPressMethod(@class, methodDefs);
                return;
            }
        }
Пример #2
0
        public static void Main(string[] args)
        {
            const string fileName = @"E:\osu!\osu!.exe";

            osu_exe = ModuleDefMD.Load(fileName);

            Console.WriteLine("Getting String Deobfuscator method...");
            StringDeobfuscator.Init(osu_exe);

            Console.WriteLine("Searching for classes...");
            foreach (var type in osu_exe.Types)
            {
                _classMaps.ForEach(c =>
                {
                    c.GetMethods(type.Name, type, type.Methods);
                    c.GetFields(type.Name, type, type.Fields);
                });
            }

            var @class = MappingManager.GetClass("StringDeobf")
                         .OrElse(new ClassObj("StringDeobf", StringDeobfuscator.DeobfClassName));

            MappingManager.AddClass(@class);
            @class.AddMethod("Deobfuscate", StringDeobfuscator.DeobfMethodName);

            MappingManager.SaveMappingFile("C:/Users/Andrew/Documents/Annex/Annex/config/mapping.json", _classMaps.Count);
            MappingManager.LoadMappingFile();
        }
Пример #3
0
        public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
        {
            ClassObj @class = null;

            foreach (var method in methodDefs)
            {
                if (!HasStrings(method,
                                "chickenmcnuggets{0}o15{1}{2}smustard{3}{4}uu{5}{6}{7}{8}{9}{10}{11}Q{12}{13}{15}{14:yyMMddHHmmss}{16}")
                    )
                {
                    continue;
                }

                @class = MappingManager.GetClass(UnobfuscatedName)
                         .OrElse(new ClassObj(UnobfuscatedName, className));

                MappingManager.AddClass(@class);
                //@class.AddMethod("GetJoinedMods", method.Name); //Mods mods, bool abreviated, bool displayNone, bool parens, bool ?space?
            }

            if (@class != null)
            {
                FindSubmitRequest(@class, methodDefs);
                FindFields(@class, methodDefs);
            }
        }
Пример #4
0
        private void checkIfExePath(string className, MethodDef methodDef)
        {
            if (methodDef.Body?.Instructions == null)
            {
                return;
            }

            foreach (var insn in methodDef.Body.Instructions)
            {
                if (insn.OpCode != OpCodes.Call)
                {
                    continue;
                }

                if (!insn.ToString().EndsWith("System.Windows.Forms.Application::get_ExecutablePath()"))
                {
                    continue;
                }

                var @class = MappingManager.GetClass(UnobfuscatedName)
                             .OrElse(new ClassObj(UnobfuscatedName, className));
                MappingManager.AddClass(@class);

                @class.AddMethod("ExePath", methodDef.Name);
            }
        }
Пример #5
0
        public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
        {
            var stringList = new List <string>();

            foreach (var method in methodDefs)
            {
                MethodDef addMethod = null;
                if (method.Body != null && method.Body.Instructions != null)
                {
                    for (int i = 0; i < method.Body.Instructions.Count; i++)
                    {
                        var previnsn = i == 0 ? null : method.Body.Instructions[i - 1];
                        var insn     = method.Body.Instructions[i];
                        var nextinsn = i + 1 == method.Body.Instructions.Count ? null : method.Body.Instructions[i + 1];

                        if (insn.OpCode == OpCodes.Call && previnsn != null && previnsn.OpCode == OpCodes.Ldloc_1)
                        {
                            if (insn.Operand is IMethodDefOrRef)
                            {
                                var callingMethod = insn.Operand as IMethodDefOrRef;
                                if (ClrHelper.MatchesSig(callingMethod.MethodSig, "?"))
                                {
                                    addMethod = callingMethod.ResolveMethodDef();
                                }
                            }
                        }

                        if (insn.OpCode != OpCodes.Call || previnsn == null || previnsn.OpCode != OpCodes.Ldc_I4)
                        {
                            continue;
                        }

                        if (!insn.ToString().EndsWith(Program.DeobfuscatorInsn))
                        {
                            continue;
                        }


                        var str = StringDeobfuscator.Deobfuscate((int)previnsn.Operand);
                        stringList.Add(str);
                    }
                }

                if (IsInitOpts(stringList))
                {
                    var @class = MappingManager.GetClass("GuiOptions").OrElse(new ClassObj("GuiOptions", className));
                    MappingManager.AddClass(@class);
                    @class.AddMethod("OnInit", method.Name);

                    if (addMethod != null)
                    {
                        @class.AddMethod("AddOption", addMethod.Name);
                    }
                }

                stringList.Clear();
            }
        }
        private void AddDrawableClass(MethodDef methodDef)
        {
            var drawableParam = methodDef.MethodSig.Params[0];

            Console.WriteLine("Drawable: " + methodDef.MethodSig.Params[0]);
            var drawableClass = MappingManager.GetClass("Drawable")
                                .OrElse(new ClassObj("Drawable", drawableParam.TypeName));

            MappingManager.AddClass(drawableClass);
        }
Пример #7
0
        public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
        {
            ClassObj @class;

            if ((@class = FindByStrings(className, methodDefs, "hit0", "hit300", "spinner-osu", "particle")) == null)
            {
                return;
            }

            foreach (var methodDef in methodDefs)
            {
                if (!methodDef.HasBody)
                {
                    continue;
                }
                var instructions = methodDef.Body.Instructions;
                if (instructions.Count < 7)
                {
                    continue;
                }

                for (var i = 3; i < instructions.Count - 3; i++)
                {
                    bool IsDouble(Instruction x) => x.OpCode == OpCodes.Ldc_R8;
                    double Val(Instruction x) => (double)x.Operand;

                    var insn   = instructions[i];
                    var insnP1 = instructions[i + 1];
                    var insnP2 = instructions[i + 2];
                    if (!IsDouble(insn) || !IsDouble(insnP1) || !IsDouble(insnP2))
                    {
                        continue;
                    }
                    if (Val(insn) != 1800f || Val(insnP1) != 1200f || Val(insnP2) != 450f)
                    {
                        continue;
                    }
                    @class.AddMethod("UpdateMapValues", methodDef.Name);
                    var field = instructions[i + 5].Operand as FieldDef;
                    Console.WriteLine("PreEmpt" + field.FullName);

                    var @parentClass = MappingManager.GetClass("HitObjectManagerParent")
                                       .OrElse(new ClassObj("HitObjectManagerParent", field.DeclaringType.Name));

                    MappingManager.AddClass(@parentClass);
                    @parentClass.AddField("ApproachRatePrecise", field.Name);


                    return;
                }
            }
        }
Пример #8
0
        public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
        {
            foreach (var methodDef in methodDefs)
            {
                if (!methodDef.Name.Equals("ToString") || !HasStrings(methodDef, "0", "1"))
                {
                    continue;
                }

                var @class = MappingManager.GetClass("BoolObj").OrElse(new ClassObj("BoolObj", className));
                MappingManager.AddClass(@class);
            }
        }
Пример #9
0
        public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
        {
            var rect = methodDefs.Where(m => ClrHelper.MatchesSig(m, "Vector2", "Vector2", "Single", "Color"));

            if (!rect.Any())
            {
                return;
            }

            var clazz = new ClassObj("CompRect", className);

            MappingManager.AddClass(clazz);
        }
 public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
 {
     foreach (var method in methodDefs)
     {
         if (method.Name.Equals(".ctor"))
         {
             if (ClrHelper.MatchesSig(method, "String", "String", "Boolean", "EventHandler"))
             {
                 MappingManager.AddClass(new ClassObj("OptionsCheckbox", className));
             }
         }
     }
 }
Пример #11
0
        public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
        {
            foreach (var methodDef in methodDefs)
            {
                checkIfExePath(className, methodDef);
                if (!HasStrings(methodDef, ".require_update", "help.txt", "Force update requested", "osu!.exe"))
                {
                    continue;
                }

                var @class = MappingManager.GetClass(UnobfuscatedName)
                             .OrElse(new ClassObj(UnobfuscatedName, className));
                MappingManager.AddClass(@class);
                @class.AddMethod("Main", methodDef.Name);
            }
        }
        public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
        {
            foreach (var method in methodDefs)
            {
                var strings = GetMethodStrings(method);

                if (!strings.Contains("stars") || !strings.Contains("length") ||
                    !strings.Contains("keys") || !strings.Contains("played"))
                {
                    continue;
                }

                var @class = MappingManager.GetClass(UnobfuscatedName)
                             .OrElse(new ClassObj(UnobfuscatedName, className));
                MappingManager.AddClass(@class);
            }
        }
Пример #13
0
        private static void FindAddCallback(ClassObj clazz, IList <MethodDef> methodDefs)
        {
            foreach (var method in methodDefs)
            {
                var insn          = method.Body.Instructions;
                var isAddCallback = insn.Any(f => f.ToString().Contains("Delegate::Combine"));
                if (!isAddCallback)
                {
                    continue;
                }

                clazz.AddMethod("AddToggleCallback", method.Name);

                MappingManager.AddClass(new ClassObj("CheckboxCheckedDelegate", method.MethodSig.Params[0].FullName));
                return;
            }
        }
Пример #14
0
        public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
        {
            ClassObj @class = null;

            foreach (var method in methodDefs)
            {
                if (!HasStrings(method, "Cannot convert a map to osz2 which does not have a Beatmapset ID."))
                {
                    continue;
                }

                @class = MappingManager.GetClass(UnobfuscatedName)
                         .OrElse(new ClassObj(UnobfuscatedName, className));

                MappingManager.AddClass(@class);
                //@class.AddMethod("GetJoinedMods", method.Name); //Mods mods, bool abreviated, bool displayNone, bool parens, bool ?space?
            }
        }
Пример #15
0
        public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
        {
            ClassObj @class = null;

            foreach (var method in methodDefs)
            {
                var strings = GetMethodStrings(method);

                if (!ClrHelper.MatchesSig(method, "Mods", "Boolean", "Boolean", "Boolean", "Boolean"))
                {
                    continue;
                }

                if (!strings.Contains("DoubleTime") || !strings.Contains("DT") ||
                    !strings.Contains("None") || !strings.Contains("Cinema"))
                {
                    continue;
                }

                @class = MappingManager.GetClass(UnobfuscatedName)
                         .OrElse(new ClassObj(UnobfuscatedName, className));
                MappingManager.AddClass(@class);
                @class.AddMethod("GetJoinedMods", method.Name); //Mods mods, bool abreviated, bool displayNone, bool parens, bool ?space?
            }

            if (@class == null)
            {
                return;
            }

            foreach (var method in methodDefs)
            {
                if (!ClrHelper.MatchesSig(method, "Mods"))
                {
                    continue;
                }

                if (method.Body.Instructions.Count == 5)
                {
                    @class.AddMethod("IsModActive", method.Name); //Mods mods
                }
            }
        }
        public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
        {
            var sigCheck = methodDefs.Where(m =>
                                            ClrHelper.MatchesSig(m, "?", "Double", "Double", "Double", "Vector2", "Int32")).ToList();

            if (!sigCheck.Any())
            {
                return;
            }

            var clazz = new ClassObj(UnobfuscatedName, className);

            MappingManager.AddClass(clazz);

            var callbackSearch = methodDefs
                                 .Where(m => ClrHelper.MatchesSig(m, "Object", "EventArgs")).ToList();

            if (!callbackSearch.Any())
            {
                return;
            }

            foreach (var methodDef in callbackSearch)
            {
                var insn = GetOpcodePattern(methodDef, 0, OpCodes.Ldfld, OpCodes.Brfalse_S, OpCodes.Ldarg_0,
                                            OpCodes.Ldfld, OpCodes.Ldc_I4_1, OpCodes.Callvirt);

                if (!insn.IsPresent())
                {
                    continue;
                }

                var i        = insn.Get();
                var fieldDef = i.Operand as FieldDef;
                clazz.AddField("SliderCallbacks", fieldDef.Name);

                var sliderChangeClass = new ClassObj("SliderChanged", fieldDef.FieldType.FullName);
                MappingManager.AddClass(sliderChangeClass);
            }

            FindSetTooltip(clazz, methodDefs);
            FindValueField(clazz, methodDefs);
        }
Пример #17
0
 public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
 {
     foreach (var method in methodDefs)
     {
         if (!method.Name.Equals(".ctor"))
         {
             continue;
         }
         if (!HasStrings(method, "circle-full") &&
             !ClrHelper.MatchesSig(method, "String", "Single", "Vector2", "Single", "Boolean", "Single"))
         {
             continue;
         }
         ClrHelper.PrintSig(method);
         var clazz = new ClassObj("CompCheckbox", className);
         MappingManager.AddClass(clazz);
         FindComponentList(clazz, type.Fields);
         FindAddCallback(clazz, methodDefs);
     }
 }
Пример #18
0
        public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
        {
            var HasCtor = methodDefs.Where(m => ClrHelper.MatchesSig(m,
                                                                     "String", "Single", "Vector2", "Vector2", "Single", "Boolean", "Color", "Boolean"));
            var ContainsStrings = methodDefs.Where(m => HasStrings(m, "Text: "));

            //string text, float textSize, Vector2 startPosition, Vector2 bounds, float drawDepth, bool alwaysDraw, Color colour, bool shadow = true
            if (!HasCtor.Any() || !ContainsStrings.Any())
            {
                return;
            }

            var clazz = new ClassObj("CompLabel", className);

            MappingManager.AddClass(clazz);

            var str = methodDefs.First(m => ClrHelper.MatchesSig(m, "String"));

            clazz.AddMethod("SetText", str.Name); //MethodSig (1): String
        }
Пример #19
0
        public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
        {
            var keys =
                from method in methodDefs
                let strings = GetMethodStrings(method)
                              where strings.Count != 0
                              where strings.Contains("D") || strings.Contains("")
                              select method.Body.Instructions.Where(i => i.ToString().Contains("Microsoft.Xna.Framework.Input.Keys"));

            if (!keys.Any(insn => insn.Any()))
            {
                return;
            }

            var @class = MappingManager.GetClass(UnobfuscatedName)
                         .OrElse(new ClassObj(UnobfuscatedName, className));

            MappingManager.AddClass(@class);
            FindComponentManager(methodDefs, @class);
        }
Пример #20
0
        protected ClassObj FindByStrings(string className, IList <FieldDef> fieldDefs, params string[] strings)
        {
            ClassObj @class = null;

            foreach (var method in fieldDefs)
            {
                if (!HasStrings(method, strings))
                {
                    continue;
                }

                @class = MappingManager.GetClass(UnobfuscatedName)
                         .OrElse(new ClassObj(UnobfuscatedName, className));

                MappingManager.AddClass(@class);

                return(@class);
                //@class.AddMethod("GetJoinedMods", method.Name); //Mods mods, bool abreviated, bool displayNone, bool parens, bool ?space?
            }

            return(null);
        }
Пример #21
0
        public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
        {
            bool Contains(List <string> strings) => strings.Contains(fallbackStr) || strings.Contains(timeoutStr);

            if (MappingManager.Classes.Find(c => c.Name.Equals(UnobfuscatedName)) != null)
            {
                return;
            }
            if (!methodDefs.Select(GetMethodStrings).Any(Contains))
            {
                return;
            }

            var @class = MappingManager.GetClass(UnobfuscatedName)
                         .OrElse(new ClassObj(UnobfuscatedName, className));

            MappingManager.AddClass(@class);

            Optional <MethodDef> .OfNullable(methodDefs
                                             .First(method => method.Body.Instructions.Any(insn => insn.ToString().Contains("GetResponseStream"))))
            .IfPresent(m => @class.AddMethod("StartResponse", m.Name));
        }
        public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
        {
            ClassObj @class = null;

            foreach (var method in methodDefs)
            {
                if (!HasStrings(method, "SubmissionCache"))
                {
                    continue;
                }
                if (!ClrHelper.MatchesSig(method, "String", "Boolean"))
                {
                    continue;
                }


                @class = MappingManager.GetClass(UnobfuscatedName)
                         .OrElse(new ClassObj(UnobfuscatedName, className));

                MappingManager.AddClass(@class);
                //@class.AddMethod("GetJoinedMods", method.Name); //Mods mods, bool abreviated, bool displayNone, bool parens, bool ?space?
            }
        }
Пример #23
0
        public override void GetMethods(string className, TypeDef type, IList <MethodDef> methodDefs)
        {
            Console.WriteLine("wwww");
            bool Contains(List <string> strings) => strings.Contains("There was an error during timing calculations") ||
            strings.Contains("user is hacking?");

            if (MappingManager.Classes.Find(c => c.Name.Equals(UnobfuscatedName)) != null)
            {
                return;
            }

            if (!methodDefs.Select(GetMethodStrings).Any(Contains))
            {
                return;
            }

            var @class = MappingManager.GetClass(UnobfuscatedName)
                         .OrElse(new ClassObj(UnobfuscatedName, className));

            MappingManager.AddClass(@class);

            Optional <MethodDef> .OfNullable(methodDefs.First(m => Contains(GetMethodStrings(m))))
            .IfPresent(m => @class.AddMethod("AudioCheck", m.Name));
        }
Пример #24
0
        private void AddComponentManagerClass(FieldDef field)
        {
            var componentManagerClass = MappingManager.GetClass("ComponentManager")
                                        .OrElse(new ClassObj("ComponentManager", field.FieldType.TypeName));

            MappingManager.AddClass(componentManagerClass);

            var compManager = Program.osu_exe.Find(field.FieldType.TypeName, false);

            foreach (var compManagerMethod in compManager.Methods)
            {
                var hasNullCheck   = HasOpcodePattern(compManagerMethod, OpCodes.Ldarg_1, OpCodes.Brtrue_S, OpCodes.Ret);
                var hasCount       = HasOpcodePattern(compManagerMethod, OpCodes.Callvirt, OpCodes.Ldc_I4_0, OpCodes.Ble_S);
                var hasGreaterZero = HasOpcodePattern(compManagerMethod, OpCodes.Ldloc_0, OpCodes.Ldc_I4_0, OpCodes.Bge_S);
                if (!hasNullCheck || !hasCount || !hasGreaterZero)
                {
                    continue;
                }

                componentManagerClass.AddMethod("AddComponent", compManagerMethod.Name);
                AddDrawableClass(compManagerMethod);
                return;
            }
        }