Example #1
0
        private void ProcessButton_Click(object sender, EventArgs e)
        {
            if (Files == null)
            {
                return;
            }

            if (!Directory.Exists(txtOutput.Text))
            {
                try { Directory.CreateDirectory(txtOutput.Text); }
                catch (Exception ex) { }

                if (!Directory.Exists(txtOutput.Text))
                {
                    MessageBox.Show("Output dir doesn't exists!", "Output", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }


            DeObfuscator = new TDeObfuscator(Files);
            DeObfuscator.RenameClasses = RenameClassCheckBox.Checked;

            DeObfuscator.OutputDir     = txtOutput.Text;
            DeObfuscator.UseUniqueNums = chkUseUniqueNums.Checked;

            Progress.Maximum = Files.Count;
            Progress.Visible = true;

            TDeObfuscator.Progress += new TDeObfuscator.ProgressHandler(OnProgress);

            // update the classfile with the new deobfuscated version
            ArrayList NewFileList = DeObfuscator.DeObfuscateAll(RenameStore);

            if (NewFileList != null)
            {
                MessageBox.Show("DeObfuscated everything ok!", "DeObfuscator");
                Files = NewFileList;
            }
            else
            {
                MessageBox.Show("Error!!!", "DeObfuscator");
            }

            Progress.Visible = false;
            RenameStore      = new RenameDatabase();
            UpdateTree();
        }
Example #2
0
        private void ProcessButton_Click(object sender, EventArgs e)
        {
            if (Files == null)
            {
                return;
            }

            if (!Directory.Exists(txtOutput.Text))
            {
                //MessageBox.Show("Output dir doesn't exists!", "Output", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Directory.CreateDirectory(txtOutput.Text);
                return;
            }


            DeObfuscator = new TDeObfuscator(Files);
            DeObfuscator.RenameClasses = RenameClassCheckBox.Checked;

            DeObfuscator.OutputDir     = txtOutput.Text;
            DeObfuscator.UseUniqueNums = chkUseUniqueNums.Checked;

            // update the classfile with the new deobfuscated version
            ArrayList NewFileList = DeObfuscator.DeObfuscateAll(RenameStore);

            if (NewFileList != null)
            {
                //MessageBox.Show("DeObfuscated everything ok!", "DeObfuscator");
                Files = NewFileList;
            }
            else
            {
                MessageBox.Show("Error!!!", "Deobfuscator Stage Two");
            }

            RenameStore = new RenameDatabase();
            UpdateTree();
        }
Example #3
0
        private void UpdateTree()
        {
            TreeClassView.Nodes.Clear();

            DeObfuscator = new TDeObfuscator(Files);

            foreach (string fn in Files)
            {
                TClassFile ClassFile = new TClassFile(fn);

                if (!ClassFile.Open())
                {
                    TreeClassView.Nodes.Add("Invalid class file: " + fn);
                    continue;
                }

                if (ClassFile != null)
                {
                    TreeNode bigroot;

                    // check if the user wants to rename the class file
                    string original_class_name = ClassFile.ThisClassName + " : " + ClassFile.SuperClassName;
                    string class_name = RenameStore.GetNewClassName(original_class_name);

                    if (class_name == null)
                    {
                        class_name = original_class_name;
                        bigroot = TreeClassView.Nodes.Add(class_name);
                    }
                    else
                    {
                        bigroot = TreeClassView.Nodes.Add(class_name);
                        bigroot.BackColor = Color.DodgerBlue;
                    }

                    bigroot.Tag = original_class_name;

                    TreeNode root = bigroot.Nodes.Add("Constants");
                    TreeNode methodsroot = root.Nodes.Add("Methods/Interfaces/Fields");
                    TreeNode methods = methodsroot.Nodes.Add("Methods");
                    TreeNode interfaces = methodsroot.Nodes.Add("Interfaces");
                    TreeNode fields = methodsroot.Nodes.Add("Fields");
                    TreeNode variables = root.Nodes.Add("Values");
                    TreeNode classes = root.Nodes.Add("Classes");

                    for (int i = 0; i < ClassFile.ConstantPool.MaxItems(); i++)
                    {
                        ConstantPoolInfo cc = ClassFile.ConstantPool.Item(i);

                        if (cc is ConstantPoolMethodInfo)
                        {
                            if (cc is ConstantMethodrefInfo)
                            {
                                TreeNode temp = methods.Nodes.Add("\"" + ((ConstantMethodrefInfo)cc).NameAndType.Name + "\"");
                                temp.Nodes.Add("Descriptor = " + ((ConstantMethodrefInfo)cc).NameAndType.Descriptor);
                                temp.Nodes.Add("Parent = " + ((ConstantMethodrefInfo)cc).ParentClass.Name);

                                if (DeObfuscator.DoRename(((ConstantMethodrefInfo)cc).NameAndType.Name))
                                    temp.BackColor = Color.Red;

                                continue;
                            }

                            if (cc is ConstantInterfaceMethodrefInfo)
                            {
                                TreeNode temp = interfaces.Nodes.Add("\"" + ((ConstantInterfaceMethodrefInfo)cc).NameAndType.Name + "\"");
                                temp.Nodes.Add("Descriptor = " + ((ConstantInterfaceMethodrefInfo)cc).NameAndType.Descriptor);
                                temp.Nodes.Add("Parent = " + ((ConstantInterfaceMethodrefInfo)cc).ParentClass.Name);

                                if (DeObfuscator.DoRename(((ConstantInterfaceMethodrefInfo)cc).NameAndType.Name))
                                    temp.BackColor = Color.Red;

                                continue;
                            }

                            if (cc is ConstantFieldrefInfo)
                            {
                                TreeNode temp = fields.Nodes.Add("\"" + ((ConstantFieldrefInfo)cc).NameAndType.Name + "\"");
                                temp.Nodes.Add("Descriptor = " + ((ConstantFieldrefInfo)cc).NameAndType.Descriptor);
                                if (((ConstantFieldrefInfo)cc).ParentClass != null)
                                    temp.Nodes.Add("Parent = " + ((ConstantFieldrefInfo)cc).ParentClass.Name);

                                if (DeObfuscator.DoRename(((ConstantFieldrefInfo)cc).NameAndType.Name))
                                    temp.BackColor = Color.Red;

                                continue;
                            }
                        }
                        else
                            if (cc is ConstantPoolVariableInfo)
                            {
                                TreeNode temp = variables.Nodes.Add("\"" + ((ConstantPoolVariableInfo)cc).Value.ToString() + "\"");
                                temp.Nodes.Add("References = " + cc.References);
                            }
                            else
                                if (cc is ConstantClassInfo)
                                {
                                    TreeNode temp = classes.Nodes.Add("\"" + ((ConstantClassInfo)cc).Name + "\"");
                                    temp.Nodes.Add("References = " + cc.References);
                                }
                    }

                    root = bigroot.Nodes.Add("Interfaces");
                    foreach (InterfaceInfo ii in ClassFile.Interfaces.Items)
                    {
                        root.Nodes.Add(ii.Interface.Name);
                    }

                    root = bigroot.Nodes.Add("Fields");
                    foreach (FieldInfo fi in ClassFile.Fields.Items)
                    {
                        RenameData rd = RenameStore.GetNewFieldInfo(
                            original_class_name,
                            fi.Descriptor,
                            fi.Name.Value);
                        if (rd != null)
                        {
                            TreeNode temp = root.Nodes.Add(rd.FieldName);
                            temp.Nodes.Add(rd.FieldType);
                            temp.BackColor = Color.DodgerBlue;
                        }
                        else
                        {
                            TreeNode temp = root.Nodes.Add(fi.Name.Value);
                            temp.Nodes.Add(fi.Descriptor);
                            temp.Tag = fi.Name.Value;

                            if (DeObfuscator.DoRename(fi.Name.Value))
                                temp.BackColor = Color.Red;
                        }
                    }

                    root = bigroot.Nodes.Add("Methods");
                    foreach (MethodInfo mi in ClassFile.Methods.Items)
                    {
                        RenameData rd = RenameStore.GetNewMethodInfo(
                            original_class_name,
                            mi.Descriptor,
                            mi.Name.Value);
                        if (rd != null)
                        {
                            TreeNode temp = root.Nodes.Add(rd.FieldName);
                            temp.Nodes.Add(rd.FieldType);
                            temp.BackColor = Color.DodgerBlue;
                        }
                        else
                        {
                            TreeNode temp = root.Nodes.Add(mi.Name.Value);
                            temp.Nodes.Add(mi.Descriptor);
                            temp.Tag = mi.Name.Value;
                            //temp.Nodes.Add(String.Format("Offset = {0:X}", mi.Offset));

                            if (DeObfuscator.DoRename(mi.Name.Value))
                                temp.BackColor = Color.Red;
                        }
                    }
                }
            }
        }
Example #4
0
        private void ProcessButton_Click(object sender, EventArgs e)
        {
            if (Files == null)
                return;

            if (!Directory.Exists(txtOutput.Text))
            {
                MessageBox.Show("Output dir doesn't exists!", "Output", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DeObfuscator = new TDeObfuscator(Files);
            DeObfuscator.RenameClasses = RenameClassCheckBox.Checked;

            DeObfuscator.OutputDir = txtOutput.Text;
            DeObfuscator.UseUniqueNums = chkUseUniqueNums.Checked;

            Progress.Maximum = Files.Count;
            Progress.Visible = true;

            TDeObfuscator.Progress += new TDeObfuscator.ProgressHandler(OnProgress);

            // update the classfile with the new deobfuscated version
            ArrayList NewFileList = DeObfuscator.DeObfuscateAll(RenameStore);
            if (NewFileList != null)
            {
                MessageBox.Show("DeObfuscated everything ok!", "DeObfuscator");
                Files = NewFileList;
            }
            else
                MessageBox.Show("Error!!!", "DeObfuscator");

            Progress.Visible = false;
            RenameStore = new RenameDatabase();
            UpdateTree();
        }
Example #5
0
        private void UpdateTree()
        {
            TreeClassView.Nodes.Clear();

            DeObfuscator = new TDeObfuscator(Files);

            foreach (string fn in Files)
            {
                TClassFile ClassFile = new TClassFile(fn);

                if (!ClassFile.Open())
                {
                    TreeClassView.Nodes.Add("Invalid class file: " + fn);
                    continue;
                }

                if (ClassFile != null)
                {
                    TreeNode bigroot;

                    // check if the user wants to rename the class file
                    string original_class_name = ClassFile.ThisClassName + " : " + ClassFile.SuperClassName;
                    string class_name          = RenameStore.GetNewClassName(original_class_name);

                    if (class_name == null)
                    {
                        class_name = original_class_name;
                        bigroot    = TreeClassView.Nodes.Add(class_name);
                    }
                    else
                    {
                        bigroot           = TreeClassView.Nodes.Add(class_name);
                        bigroot.BackColor = Color.DodgerBlue;
                    }

                    bigroot.Tag = original_class_name;

                    TreeNode root        = bigroot.Nodes.Add("Constants");
                    TreeNode methodsroot = root.Nodes.Add("Methods/Interfaces/Fields");
                    TreeNode methods     = methodsroot.Nodes.Add("Methods");
                    TreeNode interfaces  = methodsroot.Nodes.Add("Interfaces");
                    TreeNode fields      = methodsroot.Nodes.Add("Fields");
                    TreeNode variables   = root.Nodes.Add("Values");
                    TreeNode classes     = root.Nodes.Add("Classes");

                    for (int i = 0; i < ClassFile.ConstantPool.MaxItems(); i++)
                    {
                        ConstantPoolInfo cc = ClassFile.ConstantPool.Item(i);

                        if (cc is ConstantPoolMethodInfo)
                        {
                            if (cc is ConstantMethodrefInfo)
                            {
                                TreeNode temp = methods.Nodes.Add("\"" + ((ConstantMethodrefInfo)cc).NameAndType.Name + "\"");
                                temp.Nodes.Add("Descriptor = " + ((ConstantMethodrefInfo)cc).NameAndType.Descriptor);
                                temp.Nodes.Add("Parent = " + ((ConstantMethodrefInfo)cc).ParentClass.Name);

                                if (DeObfuscator.DoRename(((ConstantMethodrefInfo)cc).NameAndType.Name))
                                {
                                    temp.BackColor = Color.Red;
                                }

                                continue;
                            }

                            if (cc is ConstantInterfaceMethodrefInfo)
                            {
                                TreeNode temp = interfaces.Nodes.Add("\"" + ((ConstantInterfaceMethodrefInfo)cc).NameAndType.Name + "\"");
                                temp.Nodes.Add("Descriptor = " + ((ConstantInterfaceMethodrefInfo)cc).NameAndType.Descriptor);
                                temp.Nodes.Add("Parent = " + ((ConstantInterfaceMethodrefInfo)cc).ParentClass.Name);

                                if (DeObfuscator.DoRename(((ConstantInterfaceMethodrefInfo)cc).NameAndType.Name))
                                {
                                    temp.BackColor = Color.Red;
                                }

                                continue;
                            }

                            if (cc is ConstantFieldrefInfo)
                            {
                                TreeNode temp = fields.Nodes.Add("\"" + ((ConstantFieldrefInfo)cc).NameAndType.Name + "\"");
                                temp.Nodes.Add("Descriptor = " + ((ConstantFieldrefInfo)cc).NameAndType.Descriptor);
                                if (((ConstantFieldrefInfo)cc).ParentClass != null)
                                {
                                    temp.Nodes.Add("Parent = " + ((ConstantFieldrefInfo)cc).ParentClass.Name);
                                }

                                if (DeObfuscator.DoRename(((ConstantFieldrefInfo)cc).NameAndType.Name))
                                {
                                    temp.BackColor = Color.Red;
                                }

                                continue;
                            }
                        }
                        else
                        if (cc is ConstantPoolVariableInfo)
                        {
                            TreeNode temp = variables.Nodes.Add("\"" + ((ConstantPoolVariableInfo)cc).Value.ToString() + "\"");
                            temp.Nodes.Add("References = " + cc.References);
                        }
                        else
                        if (cc is ConstantClassInfo)
                        {
                            TreeNode temp = classes.Nodes.Add("\"" + ((ConstantClassInfo)cc).Name + "\"");
                            temp.Nodes.Add("References = " + cc.References);
                        }
                    }

                    root = bigroot.Nodes.Add("Interfaces");
                    foreach (InterfaceInfo ii in ClassFile.Interfaces.Items)
                    {
                        root.Nodes.Add(ii.Interface.Name);
                    }

                    root = bigroot.Nodes.Add("Fields");
                    foreach (FieldInfo fi in ClassFile.Fields.Items)
                    {
                        RenameData rd = RenameStore.GetNewFieldInfo(
                            original_class_name,
                            fi.Descriptor,
                            fi.Name.Value);
                        if (rd != null)
                        {
                            TreeNode temp = root.Nodes.Add(rd.FieldName);
                            temp.Nodes.Add(rd.FieldType);
                            temp.BackColor = Color.DodgerBlue;
                        }
                        else
                        {
                            TreeNode temp = root.Nodes.Add(fi.Name.Value);
                            temp.Nodes.Add(fi.Descriptor);
                            temp.Tag = fi.Name.Value;

                            if (DeObfuscator.DoRename(fi.Name.Value))
                            {
                                temp.BackColor = Color.Red;
                            }
                        }
                    }

                    root = bigroot.Nodes.Add("Methods");
                    foreach (MethodInfo mi in ClassFile.Methods.Items)
                    {
                        RenameData rd = RenameStore.GetNewMethodInfo(
                            original_class_name,
                            mi.Descriptor,
                            mi.Name.Value);
                        if (rd != null)
                        {
                            TreeNode temp = root.Nodes.Add(rd.FieldName);
                            temp.Nodes.Add(rd.FieldType);
                            temp.BackColor = Color.DodgerBlue;
                        }
                        else
                        {
                            TreeNode temp = root.Nodes.Add(mi.Name.Value);
                            temp.Nodes.Add(mi.Descriptor);
                            temp.Tag = mi.Name.Value;
                            //temp.Nodes.Add(String.Format("Offset = {0:X}", mi.Offset));

                            if (DeObfuscator.DoRename(mi.Name.Value))
                            {
                                temp.BackColor = Color.Red;
                            }
                        }
                    }
                }
            }
        }