From 33f8d22f280692bf2714f6fc6d763857fcd6a757 Mon Sep 17 00:00:00 2001 From: Boris Batteux Date: Thu, 29 Oct 2020 11:09:07 +0100 Subject: [PATCH] Initial commit --- .gitignore | 7 + AUTHORS.md | 3 + D810.py | 75 ++ LICENSE | 661 ++++++++++++ README.md | 67 ++ d810/__init__.py | 0 d810/ast.py | 605 +++++++++++ d810/cfg_utils.py | 473 +++++++++ d810/conf/__init__.py | 73 ++ d810/conf/default_instruction_only.json | 921 +++++++++++++++++ d810/conf/default_unflattening_ollvm.json | 926 +++++++++++++++++ .../default_unflattening_switch_case.json | 926 +++++++++++++++++ d810/conf/example_anel.json | 942 ++++++++++++++++++ d810/conf/options.json | 14 + .../images/gui_plugin_configuration.png | Bin 0 -> 69428 bytes d810/emulator.py | 505 ++++++++++ d810/errors.py | 41 + d810/hexrays_formatters.py | 95 ++ d810/hexrays_helpers.py | 356 +++++++ d810/hexrays_hooks.py | 280 ++++++ d810/ida_ui.py | 541 ++++++++++ d810/log.ini | 102 ++ d810/log.py | 23 + d810/manager.py | 196 ++++ d810/manager_info.json | 60 ++ d810/optimizers/__init__.py | 0 d810/optimizers/flow/__init__.py | 5 + d810/optimizers/flow/flattening/__init__.py | 6 + d810/optimizers/flow/flattening/generic.py | 469 +++++++++ .../optimizers/flow/flattening/unflattener.py | 115 +++ .../flow/flattening/unflattener_fake_jump.py | 95 ++ .../flow/flattening/unflattener_indirect.py | 116 +++ .../flattening/unflattener_switch_case.py | 60 ++ d810/optimizers/flow/flattening/utils.py | 56 ++ d810/optimizers/flow/handler.py | 39 + d810/optimizers/flow/jumps/__init__.py | 11 + d810/optimizers/flow/jumps/handler.py | 183 ++++ d810/optimizers/flow/jumps/opaque.py | 184 ++++ d810/optimizers/flow/jumps/tricks.py | 98 ++ d810/optimizers/handler.py | 36 + d810/optimizers/instructions/__init__.py | 7 + .../instructions/analysis/__init__.py | 5 + .../instructions/analysis/handler.py | 42 + .../instructions/analysis/pattern_guess.py | 89 ++ .../optimizers/instructions/analysis/utils.py | 39 + .../optimizers/instructions/chain/__init__.py | 5 + .../instructions/chain/chain_rules.py | 375 +++++++ d810/optimizers/instructions/chain/handler.py | 9 + .../optimizers/instructions/early/__init__.py | 5 + d810/optimizers/instructions/early/handler.py | 9 + .../optimizers/instructions/early/mem_read.py | 73 ++ d810/optimizers/instructions/handler.py | 138 +++ .../instructions/pattern_matching/__init__.py | 18 + .../instructions/pattern_matching/handler.py | 340 +++++++ .../pattern_matching/rewrite_add.py | 243 +++++ .../pattern_matching/rewrite_and.py | 253 +++++ .../pattern_matching/rewrite_bnot.py | 272 +++++ .../pattern_matching/rewrite_cst.py | 448 +++++++++ .../pattern_matching/rewrite_mov.py | 50 + .../pattern_matching/rewrite_mul.py | 153 +++ .../pattern_matching/rewrite_neg.py | 126 +++ .../pattern_matching/rewrite_or.py | 259 +++++ .../pattern_matching/rewrite_predicates.py | 403 ++++++++ .../pattern_matching/rewrite_sub.py | 177 ++++ .../pattern_matching/rewrite_xor.py | 325 ++++++ .../instructions/pattern_matching/weird.py | 117 +++ d810/optimizers/instructions/z3/__init__.py | 7 + d810/optimizers/instructions/z3/cst.py | 51 + d810/optimizers/instructions/z3/handler.py | 9 + d810/optimizers/instructions/z3/predicates.py | 78 ++ d810/tracker.py | 477 +++++++++ d810/utils.py | 69 ++ d810/z3_utils.py | 158 +++ 73 files changed, 14194 insertions(+) create mode 100644 .gitignore create mode 100644 AUTHORS.md create mode 100644 D810.py create mode 100644 LICENSE create mode 100644 README.md create mode 100644 d810/__init__.py create mode 100644 d810/ast.py create mode 100644 d810/cfg_utils.py create mode 100644 d810/conf/__init__.py create mode 100644 d810/conf/default_instruction_only.json create mode 100644 d810/conf/default_unflattening_ollvm.json create mode 100644 d810/conf/default_unflattening_switch_case.json create mode 100644 d810/conf/example_anel.json create mode 100644 d810/conf/options.json create mode 100644 d810/docs/source/images/gui_plugin_configuration.png create mode 100644 d810/emulator.py create mode 100644 d810/errors.py create mode 100644 d810/hexrays_formatters.py create mode 100644 d810/hexrays_helpers.py create mode 100644 d810/hexrays_hooks.py create mode 100644 d810/ida_ui.py create mode 100644 d810/log.ini create mode 100644 d810/log.py create mode 100644 d810/manager.py create mode 100644 d810/manager_info.json create mode 100644 d810/optimizers/__init__.py create mode 100644 d810/optimizers/flow/__init__.py create mode 100644 d810/optimizers/flow/flattening/__init__.py create mode 100644 d810/optimizers/flow/flattening/generic.py create mode 100644 d810/optimizers/flow/flattening/unflattener.py create mode 100644 d810/optimizers/flow/flattening/unflattener_fake_jump.py create mode 100644 d810/optimizers/flow/flattening/unflattener_indirect.py create mode 100644 d810/optimizers/flow/flattening/unflattener_switch_case.py create mode 100644 d810/optimizers/flow/flattening/utils.py create mode 100644 d810/optimizers/flow/handler.py create mode 100644 d810/optimizers/flow/jumps/__init__.py create mode 100644 d810/optimizers/flow/jumps/handler.py create mode 100644 d810/optimizers/flow/jumps/opaque.py create mode 100644 d810/optimizers/flow/jumps/tricks.py create mode 100644 d810/optimizers/handler.py create mode 100644 d810/optimizers/instructions/__init__.py create mode 100644 d810/optimizers/instructions/analysis/__init__.py create mode 100644 d810/optimizers/instructions/analysis/handler.py create mode 100644 d810/optimizers/instructions/analysis/pattern_guess.py create mode 100644 d810/optimizers/instructions/analysis/utils.py create mode 100644 d810/optimizers/instructions/chain/__init__.py create mode 100644 d810/optimizers/instructions/chain/chain_rules.py create mode 100644 d810/optimizers/instructions/chain/handler.py create mode 100644 d810/optimizers/instructions/early/__init__.py create mode 100644 d810/optimizers/instructions/early/handler.py create mode 100644 d810/optimizers/instructions/early/mem_read.py create mode 100644 d810/optimizers/instructions/handler.py create mode 100644 d810/optimizers/instructions/pattern_matching/__init__.py create mode 100644 d810/optimizers/instructions/pattern_matching/handler.py create mode 100644 d810/optimizers/instructions/pattern_matching/rewrite_add.py create mode 100644 d810/optimizers/instructions/pattern_matching/rewrite_and.py create mode 100644 d810/optimizers/instructions/pattern_matching/rewrite_bnot.py create mode 100644 d810/optimizers/instructions/pattern_matching/rewrite_cst.py create mode 100644 d810/optimizers/instructions/pattern_matching/rewrite_mov.py create mode 100644 d810/optimizers/instructions/pattern_matching/rewrite_mul.py create mode 100644 d810/optimizers/instructions/pattern_matching/rewrite_neg.py create mode 100644 d810/optimizers/instructions/pattern_matching/rewrite_or.py create mode 100644 d810/optimizers/instructions/pattern_matching/rewrite_predicates.py create mode 100644 d810/optimizers/instructions/pattern_matching/rewrite_sub.py create mode 100644 d810/optimizers/instructions/pattern_matching/rewrite_xor.py create mode 100644 d810/optimizers/instructions/pattern_matching/weird.py create mode 100644 d810/optimizers/instructions/z3/__init__.py create mode 100644 d810/optimizers/instructions/z3/cst.py create mode 100644 d810/optimizers/instructions/z3/handler.py create mode 100644 d810/optimizers/instructions/z3/predicates.py create mode 100644 d810/tracker.py create mode 100644 d810/utils.py create mode 100644 d810/z3_utils.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8dc9798 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +**/__pycache__/ +**/.idea/ +**/.vscode/ +**/venv/ +**~ +**.pyc +**.log diff --git a/AUTHORS.md b/AUTHORS.md new file mode 100644 index 0000000..a235d15 --- /dev/null +++ b/AUTHORS.md @@ -0,0 +1,3 @@ +# Authors list + +- Boris Batteux diff --git a/D810.py b/D810.py new file mode 100644 index 0000000..fffaee1 --- /dev/null +++ b/D810.py @@ -0,0 +1,75 @@ +import os +import idaapi +import ida_hexrays +import ida_kernwin + + +from d810.conf import D810Configuration +from d810.manager import D810State, D810_LOG_DIR_NAME +from d810.log import configure_loggers, clear_logs + + +class D810Plugin(idaapi.plugin_t): + # variables required by IDA + flags = 0 # normal plugin + wanted_name = "D-810" + wanted_hotkey = "Ctrl-Shift-D" + comment = "Interface to the D-810 plugin" + help = "" + initialized = False + + def __init__(self): + super(D810Plugin, self).__init__() + self.d810_config = None + self.state = None + self.initialized = False + + + def reload_plugin(self): + if self.initialized: + self.term() + + self.d810_config = D810Configuration() + + #TO-DO: if [...].get raises an exception because log_dir is not found, handle exception + real_log_dir = os.path.join(self.d810_config.get("log_dir"), D810_LOG_DIR_NAME) + + #TO-DO: if [...].get raises an exception because erase_logs_on_reload is not found, handle exception + if self.d810_config.get("erase_logs_on_reload"): + clear_logs(real_log_dir) + + configure_loggers(real_log_dir) + self.state = D810State(self.d810_config) + print("D-810 reloading...") + self.state.start_plugin() + self.initialized = True + + + # IDA API methods: init, run, term + def init(self): + if not ida_hexrays.init_hexrays_plugin(): + print("D-810 need Hex-Rays decompiler. Skipping") + return idaapi.PLUGIN_SKIP + + kv = ida_kernwin.get_kernel_version().split(".") + if (int(kv[0]) < 7) or (int(kv[1]) < 5): + print("D-810 need IDA version >= 7.5. Skipping") + return idaapi.PLUGIN_SKIP + + return idaapi.PLUGIN_OK + + + def run(self, args): + self.reload_plugin() + + + def term(self): + print("Terminating D-810...") + if self.state is not None: + self.state.stop_plugin() + + self.initialized = False + + +def PLUGIN_ENTRY(): + return D810Plugin() diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9c3b923 --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..752ef89 --- /dev/null +++ b/README.md @@ -0,0 +1,67 @@ +# Introduction + +## What is D-810 + +D-810 is an IDA Pro plugin which can be used to deobfuscate code at decompilation time by modifying IDA Pro microcode. +It was designed with the following goals in mind: + +* It should have as least as possible impact on our standard reverse engineering workflow + * Fully integrated to IDA Pro +* It should be easily extensible and configurable + * Fast creation of new deobfuscation rules + * Configurable so that we don't have to modify the source code to use rules for a specific project +* Performance impact should be reasonable + * Our goal is to be transparent for the reverse engineer + * But we don't care if the decompilation of a function takes 1 more second if the resulting code is much more simplier. + + +# Installation + +**Only IDA v7.5 or later is supported** (since we need the microcode Python API) + +Copy this repository in `.idapro/plugins` + +We recommend to install Z3 to be able to use several features of D-810: +```bash +pip3 install z3-solver +``` + +# Using D-810 + +* Load the plugin by using the `Ctrl-Shift-D` shortcut, you should see this configuration GUI + +![](d810/docs/source/images/gui_plugin_configuration.png) + +* Choose or create your project configuration + * If you are not sure what to do here, leave *default_instruction_only.json*. +* Click on the `Start` button to enable deobfuscation +* Decompile an obfuscated function, the code should be simplified (hopefully) +* When you want to disable deobfuscation, just click on the `Stop` button. + +# Warnings + +This plugin is still in early stage of development, so issues ~~may~~ will happen. + + * Modifying incorrectly IDA microcode may lead IDA to crash. We try to detect that as much as possible to avoid crash, but since it may still happen **save you IDA database often** + * We only tested this plugin on Linux, but it should work on Windows too. + +# Documentation + +Work in progress + +Currently, you can read our [blog post](https://eshard.com/posts/) to get some information. + + +# Licenses + +This library is licensed under LGPL V3 license. See the [LICENSE](LICENSE) file for details. + +## Authors + +See [AUTHORS](AUTHORS.md) for the list of contributors to the project. + +# Acknowledgement + +Rolf Rolles for the huge work he has done with his [HexRaysDeob plugin](https://github.com/RolfRolles/HexRaysDeob) and all the information about Hex-Rays microcode internals described in his [blog post](https://www.hex-rays.com/blog/hex-rays-microcode-api-vs-obfuscating-compiler/). We are still using some part of his plugin in D-810. + +Dennis Elser for the [genmc plugin](https://github.com/patois/genmc) plugin which was very helpful for debugging D-810 errors. diff --git a/d810/__init__.py b/d810/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/d810/ast.py b/d810/ast.py new file mode 100644 index 0000000..4f21e43 --- /dev/null +++ b/d810/ast.py @@ -0,0 +1,605 @@ +from __future__ import annotations +import logging +from typing import List, Union, Dict, Tuple + +from ida_hexrays import * + +from d810.utils import unsigned_to_signed, signed_to_unsigned, \ + get_add_cf, get_add_of, get_sub_of, get_parity_flag +from d810.hexrays_helpers import OPCODES_INFO, MBA_RELATED_OPCODES, Z3_SPECIAL_OPERANDS, MINSN_TO_AST_FORBIDDEN_OPCODES, \ + equal_mops_ignore_size, AND_TABLE +from d810.hexrays_formatters import format_minsn_t, format_mop_t +from d810.errors import AstEvaluationException + +logger = logging.getLogger('D810') + + +def check_and_add_to_list(new_ast: Union[AstNode, AstLeaf], known_ast_list: List[Union[AstNode, AstLeaf]]): + is_new_ast_known = False + for existing_elt in known_ast_list: + if equal_mops_ignore_size(new_ast.mop, existing_elt.mop): + new_ast.ast_index = existing_elt.ast_index + is_new_ast_known = True + break + + if not is_new_ast_known: + ast_index = len(known_ast_list) + new_ast.ast_index = ast_index + known_ast_list.append(new_ast) + + +def mop_to_ast_internal(mop: mop_t, ast_list: List[Union[AstNode, AstLeaf]]) -> Union[None, AstNode, AstLeaf]: + if mop is None: + return None + + if mop.t != mop_d or (mop.d.opcode not in MBA_RELATED_OPCODES): + tree = AstLeaf(format_mop_t(mop)) + tree.mop = mop + dest_size = mop.size if mop.t != mop_d else mop.d.d.size + tree.dest_size = dest_size + else: + left_ast = mop_to_ast_internal(mop.d.l, ast_list) + right_ast = mop_to_ast_internal(mop.d.r, ast_list) + dst_ast = mop_to_ast_internal(mop.d.d, ast_list) + tree = AstNode(mop.d.opcode, left_ast, right_ast, dst_ast) + tree.mop = mop + tree.dest_size = mop.d.d.size + tree.ea = mop.d.ea + + check_and_add_to_list(tree, ast_list) + return tree + + +def mop_to_ast(mop: mop_t) -> Union[None, AstNode, AstLeaf]: + mop_ast = mop_to_ast_internal(mop, []) + mop_ast.compute_sub_ast() + return mop_ast + + +def minsn_to_ast(instruction: minsn_t) -> Union[None, AstNode, AstLeaf]: + try: + if instruction.opcode in MINSN_TO_AST_FORBIDDEN_OPCODES: + # To avoid error 50278 + return None + + ins_mop = mop_t() + ins_mop.create_from_insn(instruction) + + if instruction.opcode == m_mov: + tmp = AstNode(m_mov, mop_to_ast(ins_mop)) + tmp.mop = ins_mop + tmp.dest_size = instruction.d.size + tmp.ea = instruction.ea + tmp.dst_mop = instruction.d + return tmp + + tmp = mop_to_ast(ins_mop) + tmp.dst_mop = instruction.d + return tmp + except RuntimeError as e: + logger.error("Error while transforming instruction {0}: {1}".format(format_minsn_t(instruction), e)) + return None + + +class AstInfo(object): + def __init__(self, ast: Union[AstNode, AstLeaf], number_of_use: int): + self.ast = ast + self.number_of_use = number_of_use + + def __str__(self): + return "{0} used {1} times: {2}".format(self.ast, self.number_of_use, format_mop_t(self.ast.mop)) + + +class AstNode(dict): + def __init__(self, opcode, left=None, right=None, dst=None): + super(dict, self).__init__() + self.opcode = opcode + self.left = left + self.right = right + self.dst = dst + self.dst_mop = None + + self.opcodes = [] + self.mop = None + self.is_candidate_ok = False + + self.leafs = [] + self.leafs_by_name = {} + + self.ast_index = 0 + self.sub_ast_info_by_index = {} + + self.dest_size = None + self.ea = None + + @property + def size(self): + return self.mop.d.d.size + + def compute_sub_ast(self): + self.sub_ast_info_by_index = {} + self.sub_ast_info_by_index[self.ast_index] = AstInfo(self, 1) + + if self.left is not None: + self.left.compute_sub_ast() + for ast_index, ast_info in self.left.sub_ast_info_by_index.items(): + if ast_index not in self.sub_ast_info_by_index.keys(): + self.sub_ast_info_by_index[ast_index] = AstInfo(ast_info.ast, 0) + self.sub_ast_info_by_index[ast_index].number_of_use += ast_info.number_of_use + + if self.right is not None: + self.right.compute_sub_ast() + for ast_index, ast_info in self.right.sub_ast_info_by_index.items(): + if ast_index not in self.sub_ast_info_by_index.keys(): + self.sub_ast_info_by_index[ast_index] = AstInfo(ast_info.ast, 0) + self.sub_ast_info_by_index[ast_index].number_of_use += ast_info.number_of_use + + def get_information(self): + leaf_info_list = [] + cst_list = [] + opcode_list = [] + self.compute_sub_ast() + + for _, ast_info in self.sub_ast_info_by_index.items(): + if (ast_info.ast.mop is not None) and (ast_info.ast.mop.t != mop_z): + if ast_info.ast.is_leaf(): + if ast_info.ast.is_constant(): + cst_list.append(ast_info.ast.mop.nnn.value) + else: + leaf_info_list.append(ast_info) + else: + opcode_list += [ast_info.ast.opcode] * ast_info.number_of_use + + return leaf_info_list, cst_list, opcode_list + + def __getitem__(self, k) -> AstLeaf: + return self.leafs_by_name[k] + + def get_leaf_list(self) -> List[AstLeaf]: + leafs = [] + if self.left is not None: + leafs += self.left.get_leaf_list() + if self.right is not None: + leafs += self.right.get_leaf_list() + return leafs + + def is_leaf(self) -> bool: + # An AstNode is not a leaf, so returns False + return False + + def add_leaf(self, leaf_name: str, leaf_mop: mop_t): + leaf = AstLeaf(leaf_name) + leaf.mop = leaf_mop + self.leafs.append(leaf) + self.leafs_by_name[leaf_name] = leaf + + def add_constant_leaf(self, leaf_name: str, cst_value: int, cst_size: int): + cst_mop = mop_t() + cst_mop.make_number(cst_value & AND_TABLE[cst_size], cst_size) + self.add_leaf(leaf_name, cst_mop) + + def check_pattern_and_copy_mops(self, ast: Union[AstNode, AstLeaf]) -> bool: + self.reset_mops() + is_matching_shape = self._copy_mops_from_ast(ast) + if not is_matching_shape: + return False + return self._check_implicit_equalities() + + def reset_mops(self): + self.mop = None + if self.left is not None: + self.left.reset_mops() + if self.right is not None: + self.right.reset_mops() + + def _copy_mops_from_ast(self, other: Union[AstNode, AstLeaf]) -> bool: + self.mop = other.mop + self.dst_mop = other.dst_mop + self.dest_size = other.dest_size + self.ea = other.ea + + if not isinstance(other, AstNode): + return False + if self.opcode != other.opcode: + return False + if self.left is not None: + if not self.left._copy_mops_from_ast(other.left): + return False + if self.right is not None: + if not self.right._copy_mops_from_ast(other.right): + return False + return True + + def _check_implicit_equalities(self) -> bool: + self.leafs = self.get_leaf_list() + self.leafs_by_name = {} + self.is_candidate_ok = True + + for leaf in self.leafs: + ref_leaf = self.leafs_by_name.get(leaf.name) + if ref_leaf is not None: + if not equal_mops_ignore_size(ref_leaf.mop, leaf.mop): + self.is_candidate_ok = False + self.leafs_by_name[leaf.name] = leaf + return self.is_candidate_ok + + def update_leafs_mop(self, other: Union[AstNode, AstLeaf], other2: Union[None, AstNode, AstLeaf] = None) -> bool: + self.leafs = self.get_leaf_list() + all_leafs_found = True + for leaf in self.leafs: + if leaf.name in other.leafs_by_name.keys(): + leaf.mop = other.leafs_by_name[leaf.name].mop + elif (other2 is not None) and (leaf.name in other2.leafs_by_name.keys()): + leaf.mop = other2.leafs_by_name[leaf.name].mop + else: + all_leafs_found = False + return all_leafs_found + + def create_mop(self, ea: int) -> mop_t: + new_ins = self.create_minsn(ea) + new_ins_mop = mop_t() + new_ins_mop.create_from_insn(new_ins) + return new_ins_mop + + def create_minsn(self, ea: int, dest=None) -> minsn_t: + new_ins = minsn_t(ea) + new_ins.opcode = self.opcode + + if self.left is not None: + new_ins.l = self.left.create_mop(ea) + if self.right is not None: + new_ins.r = self.right.create_mop(ea) + + new_ins.d = mop_t() + + if self.left is not None: + new_ins.d.size = new_ins.l.size + if dest is not None: + new_ins.d = dest + return new_ins + + def get_pattern(self) -> str: + nb_operands = OPCODES_INFO[self.opcode]["nb_operands"] + if nb_operands == 0: + return "AstNode({0})".format(OPCODES_INFO[self.opcode]["name"]) + elif nb_operands == 1: + return "AstNode(m_{0}, {1})".format(OPCODES_INFO[self.opcode]["name"], self.left.get_pattern()) + elif nb_operands == 2: + return "AstNode(m_{0}, {1}, {2})" \ + .format(OPCODES_INFO[self.opcode]["name"], self.left.get_pattern(), self.right.get_pattern()) + + def evaluate_with_leaf_info(self, leafs_info, leafs_value): + dict_index_to_value = {leaf_info.ast.ast_index: leaf_value for leaf_info, leaf_value in + zip(leafs_info, leafs_value)} + res = self.evaluate(dict_index_to_value) + return res + + def evaluate(self, dict_index_to_value): + if self.ast_index in dict_index_to_value: + return dict_index_to_value[self.ast_index] + res_mask = AND_TABLE[self.dest_size] + if self.opcode == m_mov: + return (self.left.evaluate(dict_index_to_value)) & res_mask + elif self.opcode == m_neg: + return (- self.left.evaluate(dict_index_to_value)) & res_mask + elif self.opcode == m_lnot: + return self.left.evaluate(dict_index_to_value) != 0 + elif self.opcode == m_bnot: + return (self.left.evaluate(dict_index_to_value) ^ res_mask) & res_mask + elif self.opcode == m_xds: + left_value_signed = unsigned_to_signed(self.left.evaluate(dict_index_to_value), self.left.dest_size) + return signed_to_unsigned(left_value_signed, self.dest_size) & res_mask + elif self.opcode == m_xdu: + return (self.left.evaluate(dict_index_to_value)) & res_mask + elif self.opcode == m_low: + return (self.left.evaluate(dict_index_to_value)) & res_mask + elif self.opcode == m_add: + return (self.left.evaluate(dict_index_to_value) + self.right.evaluate(dict_index_to_value)) & res_mask + elif self.opcode == m_sub: + return (self.left.evaluate(dict_index_to_value) - self.right.evaluate(dict_index_to_value)) & res_mask + elif self.opcode == m_mul: + return (self.left.evaluate(dict_index_to_value) * self.right.evaluate(dict_index_to_value)) & res_mask + elif self.opcode == m_udiv: + return (self.left.evaluate(dict_index_to_value) // self.right.evaluate(dict_index_to_value)) & res_mask + elif self.opcode == m_sdiv: + return (self.left.evaluate(dict_index_to_value) // self.right.evaluate(dict_index_to_value)) & res_mask + elif self.opcode == m_umod: + return (self.left.evaluate(dict_index_to_value) % self.right.evaluate(dict_index_to_value)) & res_mask + elif self.opcode == m_smod: + return (self.left.evaluate(dict_index_to_value) % self.right.evaluate(dict_index_to_value)) & res_mask + elif self.opcode == m_or: + return (self.left.evaluate(dict_index_to_value) | self.right.evaluate(dict_index_to_value)) & res_mask + elif self.opcode == m_and: + return (self.left.evaluate(dict_index_to_value) & self.right.evaluate(dict_index_to_value)) & res_mask + elif self.opcode == m_xor: + return (self.left.evaluate(dict_index_to_value) ^ self.right.evaluate(dict_index_to_value)) & res_mask + elif self.opcode == m_shl: + return (self.left.evaluate(dict_index_to_value) << self.right.evaluate(dict_index_to_value)) & res_mask + elif self.opcode == m_shr: + return (self.left.evaluate(dict_index_to_value) >> self.right.evaluate(dict_index_to_value)) & res_mask + elif self.opcode == m_sar: + left_value_signed = unsigned_to_signed(self.left.evaluate(dict_index_to_value), self.left.dest_size) + res_signed = left_value_signed >> self.right.evaluate(dict_index_to_value) + return signed_to_unsigned(res_signed, self.dest_size) & res_mask + elif self.opcode == m_cfadd: + tmp = get_add_cf(self.left.evaluate(dict_index_to_value), self.right.evaluate(dict_index_to_value), + self.left.dest_size) + return tmp & res_mask + elif self.opcode == m_ofadd: + tmp = get_add_of(self.left.evaluate(dict_index_to_value), self.right.evaluate(dict_index_to_value), + self.left.dest_size) + return tmp & res_mask + elif self.opcode == m_sets: + left_value_signed = unsigned_to_signed(self.left.evaluate(dict_index_to_value), self.left.dest_size) + res = 1 if left_value_signed < 0 else 0 + return res & res_mask + elif self.opcode == m_seto: + left_value_signed = unsigned_to_signed(self.left.evaluate(dict_index_to_value), self.left.dest_size) + right_value_signed = unsigned_to_signed(self.right.evaluate(dict_index_to_value), self.right.dest_size) + sub_overflow = get_sub_of(left_value_signed, right_value_signed, self.left.dest_size) + return sub_overflow & res_mask + elif self.opcode == m_setnz: + res = 1 if self.left.evaluate(dict_index_to_value) != self.right.evaluate(dict_index_to_value) else 0 + return res & res_mask + elif self.opcode == m_setz: + res = 1 if self.left.evaluate(dict_index_to_value) == self.right.evaluate(dict_index_to_value) else 0 + return res & res_mask + elif self.opcode == m_setae: + res = 1 if self.left.evaluate(dict_index_to_value) >= self.right.evaluate(dict_index_to_value) else 0 + return res & res_mask + elif self.opcode == m_setb: + res = 1 if self.left.evaluate(dict_index_to_value) < self.right.evaluate(dict_index_to_value) else 0 + return res & res_mask + elif self.opcode == m_seta: + res = 1 if self.left.evaluate(dict_index_to_value) > self.right.evaluate(dict_index_to_value) else 0 + return res & res_mask + elif self.opcode == m_setbe: + res = 1 if self.left.evaluate(dict_index_to_value) <= self.right.evaluate(dict_index_to_value) else 0 + return res & res_mask + elif self.opcode == m_setg: + left_value_signed = unsigned_to_signed(self.left.evaluate(dict_index_to_value), self.left.dest_size) + right_value_signed = unsigned_to_signed(self.right.evaluate(dict_index_to_value), self.right.dest_size) + res = 1 if left_value_signed > right_value_signed else 0 + return res & res_mask + elif self.opcode == m_setge: + left_value_signed = unsigned_to_signed(self.left.evaluate(dict_index_to_value), self.left.dest_size) + right_value_signed = unsigned_to_signed(self.right.evaluate(dict_index_to_value), self.right.dest_size) + res = 1 if left_value_signed >= right_value_signed else 0 + return res & res_mask + elif self.opcode == m_setl: + left_value_signed = unsigned_to_signed(self.left.evaluate(dict_index_to_value), self.left.dest_size) + right_value_signed = unsigned_to_signed(self.right.evaluate(dict_index_to_value), self.right.dest_size) + res = 1 if left_value_signed < right_value_signed else 0 + return res & res_mask + elif self.opcode == m_setle: + left_value_signed = unsigned_to_signed(self.left.evaluate(dict_index_to_value), self.left.dest_size) + right_value_signed = unsigned_to_signed(self.right.evaluate(dict_index_to_value), self.right.dest_size) + res = 1 if left_value_signed <= right_value_signed else 0 + return res & res_mask + elif self.opcode == m_setp: + res = get_parity_flag(self.left.evaluate(dict_index_to_value), self.right.evaluate(dict_index_to_value), + self.left.dest_size) + return res & res_mask + else: + raise AstEvaluationException("Can't evaluate opcode: {0}".format(self.opcode)) + + def get_depth_signature(self, depth): + if depth == 1: + return ["{0}".format(self.opcode)] + tmp = [] + nb_operands = OPCODES_INFO[self.opcode]["nb_operands"] + if (nb_operands >= 1) and self.left is not None: + tmp += self.left.get_depth_signature(depth - 1) + else: + tmp += ["N"] * (2 ** (depth - 2)) + if (nb_operands >= 2) and self.right is not None: + tmp += self.right.get_depth_signature(depth - 1) + else: + tmp += ["N"] * (2 ** (depth - 2)) + return tmp + + def __str__(self): + try: + nb_operands = OPCODES_INFO[self.opcode]["nb_operands"] + if "symbol" in OPCODES_INFO[self.opcode].keys(): + if nb_operands == 0: + return "{0}()".format(OPCODES_INFO[self.opcode]["symbol"]) + elif nb_operands == 1: + return "{0}({1})".format(OPCODES_INFO[self.opcode]["symbol"], self.left) + elif nb_operands == 2: + if OPCODES_INFO[self.opcode]["symbol"] not in Z3_SPECIAL_OPERANDS: + return "({1} {0} {2})".format(OPCODES_INFO[self.opcode]["symbol"], self.left, self.right) + else: + return "{0}({1}, {2})".format(OPCODES_INFO[self.opcode]["symbol"], self.left, self.right) + else: + if nb_operands == 0: + return "{0}()".format(OPCODES_INFO[self.opcode]["name"]) + elif nb_operands == 1: + return "{0}({1})".format(OPCODES_INFO[self.opcode]["name"], self.left) + elif nb_operands == 2: + return "{0}({1}, {2})".format(OPCODES_INFO[self.opcode]["name"], self.left, self.right) + return "Error_AstNode" + except RuntimeError as e: + logger.info("Error while calling __str__ on AstNode: {0}".format(e)) + return "Error_AstNode" + + +class AstLeaf(object): + def __init__(self, name): + self.name = name + self.ast_index = None + + self.mop = None + self.z3_var = None + self.z3_var_name = None + + self.dest_size = None + self.ea = None + + self.sub_ast_info_by_index = {} + + def __getitem__(self, name): + if name == self.name: + return self + raise KeyError + + @property + def size(self): + return self.mop.size + + @property + def dst_mop(self): + return self.mop + + @dst_mop.setter + def dst_mop(self, mop): + self.mop = mop + + @property + def value(self): + if self.is_constant(): + return self.mop.nnn.value + else: + return None + + def compute_sub_ast(self): + self.sub_ast_info_by_index = {} + self.sub_ast_info_by_index[self.ast_index] = AstInfo(self, 1) + + def get_information(self): + # Just here to allow calling get_information on either a AstNode or AstLeaf + return [], [], [] + + def get_leaf_list(self): + return [self] + + def is_leaf(self): + return True + + def is_constant(self): + if self.mop is None: + return False + return self.mop.t == mop_n + + def create_mop(self, ea): + # Currently, we are not creating a new mop but returning the one defined + return self.mop + + def update_leafs_mop(self, other, other2=None): + if self.name in other.leafs_by_name.keys(): + self.mop = other.leafs_by_name[self.name].mop + return True + elif (other2 is not None) and (self.name in other2.leafs_by_name.keys()): + self.mop = other2.leafs_by_name[self.name].mop + return True + return False + + def check_pattern_and_copy_mops(self, ast): + self.reset_mops() + is_matching_shape = self._copy_mops_from_ast(ast) + + if not is_matching_shape: + return False + return self._check_implicit_equalities() + + def reset_mops(self): + self.z3_var = None + self.z3_var_name = None + self.mop = None + + def _copy_mops_from_ast(self, other): + self.mop = other.mop + return True + + @staticmethod + def _check_implicit_equalities(): + # An AstLeaf does not have any implicit equalities to be checked, so we always returns True + return True + + def get_pattern(self): + if self.is_constant(): + return "AstConstant('{0}', {0})".format(self.mop.nnn.value) + if self.ast_index is not None: + return "AstLeaf('x_{0}')".format(self.ast_index) + if self.name is not None: + return "AstLeaf('{0}')".format(self.name) + + def evaluate_with_leaf_info(self, leafs_info, leafs_value): + dict_index_to_value = {leaf_info.ast.ast_index: leaf_value for leaf_info, leaf_value in + zip(leafs_info, leafs_value)} + res = self.evaluate(dict_index_to_value) + return res + + def evaluate(self, dict_index_to_value): + if self.is_constant(): + return self.mop.nnn.value + return dict_index_to_value.get(self.ast_index) + + def get_depth_signature(self, depth): + if depth == 1: + if self.is_constant(): + return ["C"] + return ["L"] + else: + return ["N"] * (2 ** (depth - 1)) + + def __str__(self): + try: + if self.is_constant(): + return "{0}".format(self.mop.nnn.value) + if self.z3_var_name is not None: + return self.z3_var_name + if self.ast_index is not None: + return "x_{0}".format(self.ast_index) + if self.mop is not None: + return format_mop_t(self.mop) + return self.name + except RuntimeError as e: + logger.info("Error while calling __str__ on AstLeaf: {0}".format(e)) + return "Error_AstLeaf" + + +class AstConstant(AstLeaf): + def __init__(self, name, expected_value=None, expected_size=None): + super().__init__(name) + self.expected_value = expected_value + self.expected_size = expected_size + + @property + def value(self): + return self.mop.nnn.value + + def is_constant(self): + # An AstConstant is always constant, so return True + return True + + def _copy_mops_from_ast(self, other): + if other.mop is not None and other.mop.t != mop_n: + return False + + self.mop = other.mop + if self.expected_value is None: + return True + return self.expected_value == other.mop.nnn.value + + def evaluate(self, dict_index_to_value=None): + if self.mop is not None and self.mop.t == mop_n: + return self.mop.nnn.value + return self.expected_value + + def get_depth_signature(self, depth): + if depth == 1: + return ["C"] + else: + return ["N"] * (2 ** (depth - 1)) + + def __str__(self): + try: + if self.mop is not None and self.mop.t == mop_n: + return "0x{0:x}".format(self.mop.nnn.value) + if self.expected_value is not None: + return "0x{0:x}".format(self.expected_value) + return self.name + except RuntimeError as e: + logger.info("Error while calling __str__ on AstConstant: {0}".format(e)) + return "Error_AstConstant" diff --git a/d810/cfg_utils.py b/d810/cfg_utils.py new file mode 100644 index 0000000..4f31f50 --- /dev/null +++ b/d810/cfg_utils.py @@ -0,0 +1,473 @@ +import logging +from ida_hexrays import * +from typing import List, Union, Dict, Tuple + +from d810.errors import ControlFlowException +from d810.hexrays_helpers import CONDITIONAL_JUMP_OPCODES +from d810.hexrays_formatters import block_printer + + +helper_logger = logging.getLogger('D810.helper') + + +def log_block_info(blk: mblock_t, logger_func=helper_logger.info): + if blk is None: + logger_func("Block is None") + return + vp = block_printer() + blk._print(vp) + logger_func("Block {0} with successors {1} and predecessors {2}:\n{3}" + .format(blk.serial, [x for x in blk.succset], [x for x in blk.predset], vp.get_block_mc())) + + +def insert_goto_instruction(blk: mblock_t, goto_blk_serial: int, nop_previous_instruction=False): + if blk.tail is not None: + goto_ins = minsn_t(blk.tail) + else: + goto_ins = minsn_t(blk.start) + + if nop_previous_instruction: + blk.make_nop(blk.tail) + blk.insert_into_block(goto_ins, blk.tail) + + # We nop instruction before setting it to goto to avoid error 52123 + blk.make_nop(blk.tail) + goto_ins.opcode = m_goto + goto_ins.l = mop_t() + goto_ins.l.make_blkref(goto_blk_serial) + + +def change_1way_call_block_successor(call_blk: mblock_t, call_blk_successor_serial: int) -> bool: + if call_blk.nsucc() != 1: + return False + + mba = call_blk.mba + previous_call_blk_successor_serial = call_blk.succset[0] + previous_call_blk_successor = mba.get_mblock(previous_call_blk_successor_serial) + + nop_blk = insert_nop_blk(call_blk) + insert_goto_instruction(nop_blk, call_blk_successor_serial, nop_previous_instruction=True) + is_ok = change_1way_block_successor(nop_blk, call_blk_successor_serial) + if not is_ok: + return False + + # Bookkeeping + call_blk.succset._del(previous_call_blk_successor_serial) + call_blk.succset.push_back(nop_blk.serial) + call_blk.mark_lists_dirty() + + previous_call_blk_successor.predset._del(call_blk.serial) + if previous_call_blk_successor.serial != mba.qty - 1: + previous_call_blk_successor.mark_lists_dirty() + + mba.mark_chains_dirty() + try: + mba.verify(True) + return True + except RuntimeError as e: + helper_logger.error("Error in change_1way_block_successor: {0}".format(e)) + log_block_info(call_blk, helper_logger.error) + log_block_info(nop_blk, helper_logger.error) + raise e + + +def change_1way_block_successor(blk: mblock_t, blk_successor_serial: int) -> bool: + if blk.nsucc() != 1: + return False + + mba: mbl_array_t = blk.mba + previous_blk_successor_serial = blk.succset[0] + previous_blk_successor = mba.get_mblock(previous_blk_successor_serial) + + if blk.tail is None: + # We add a goto instruction + insert_goto_instruction(blk, blk_successor_serial, nop_previous_instruction=False) + elif blk.tail.opcode == m_goto: + # We change goto target directly + blk.tail.l.make_blkref(blk_successor_serial) + elif blk.tail.opcode == m_ijmp: + # We replace ijmp instruction with goto instruction + insert_goto_instruction(blk, blk_successor_serial, nop_previous_instruction=True) + elif blk.tail.opcode == m_call: + # Before maturity MMAT_CALLS, we can't add a goto after a call instruction + if mba.maturity < MMAT_CALLS: + return change_1way_call_block_successor(blk, blk_successor_serial) + else: + insert_goto_instruction(blk, blk_successor_serial, nop_previous_instruction=False) + else: + # We add a goto instruction + insert_goto_instruction(blk, blk_successor_serial, nop_previous_instruction=False) + + # Update block properties + blk.type = BLT_1WAY + blk.flags |= MBL_GOTO + + # Bookkeeping + blk.succset._del(previous_blk_successor_serial) + blk.succset.push_back(blk_successor_serial) + blk.mark_lists_dirty() + + previous_blk_successor.predset._del(blk.serial) + if previous_blk_successor.serial != mba.qty - 1: + previous_blk_successor.mark_lists_dirty() + + new_blk_successor = blk.mba.get_mblock(blk_successor_serial) + new_blk_successor.predset.push_back(blk.serial) + + if new_blk_successor.serial != mba.qty - 1: + new_blk_successor.mark_lists_dirty() + + mba.mark_chains_dirty() + try: + mba.verify(True) + return True + except RuntimeError as e: + helper_logger.error("Error in change_1way_block_successor: {0}".format(e)) + log_block_info(blk, helper_logger.error) + log_block_info(new_blk_successor, helper_logger.error) + log_block_info(previous_blk_successor, helper_logger.error) + raise e + + +def change_0way_block_successor(blk: mblock_t, blk_successor_serial: int) -> bool: + if blk.nsucc() != 0: + return False + mba = blk.mba + + if blk.tail.opcode == m_ijmp: + # We replace ijmp instruction with goto instruction + insert_goto_instruction(blk, blk_successor_serial, nop_previous_instruction=True) + else: + # We add a goto instruction + insert_goto_instruction(blk, blk_successor_serial, nop_previous_instruction=False) + + # Update block properties + blk.type = BLT_1WAY + blk.flags |= MBL_GOTO + + # Bookkeeping + blk.succset.push_back(blk_successor_serial) + blk.mark_lists_dirty() + + new_blk_successor = blk.mba.get_mblock(blk_successor_serial) + new_blk_successor.predset.push_back(blk.serial) + if new_blk_successor.serial != mba.qty - 1: + new_blk_successor.mark_lists_dirty() + + mba.mark_chains_dirty() + try: + mba.verify(True) + return True + except RuntimeError as e: + helper_logger.error("Error in change_0way_block_successor: {0}".format(e)) + log_block_info(blk, helper_logger.error) + log_block_info(new_blk_successor, helper_logger.error) + raise e + + +def change_2way_block_conditional_successor(blk: mblock_t, blk_successor_serial: int) -> bool: + if blk.nsucc() != 2: + return False + + mba = blk.mba + previous_blk_conditional_successor_serial = blk.tail.d.b + previous_blk_conditional_successor = mba.get_mblock(previous_blk_conditional_successor_serial) + + blk.tail.d = mop_t() + blk.tail.d.make_blkref(blk_successor_serial) + + # Bookkeeping + blk.succset._del(previous_blk_conditional_successor_serial) + blk.succset.push_back(blk_successor_serial) + blk.mark_lists_dirty() + + previous_blk_conditional_successor.predset._del(blk.serial) + if previous_blk_conditional_successor.serial != mba.qty - 1: + previous_blk_conditional_successor.mark_lists_dirty() + + new_blk_conditional_successor = blk.mba.get_mblock(blk_successor_serial) + new_blk_conditional_successor.predset.push_back(blk.serial) + if new_blk_conditional_successor.serial != mba.qty - 1: + new_blk_conditional_successor.mark_lists_dirty() + + # Step4: Final stuff and checks + mba.mark_chains_dirty() + try: + mba.verify(True) + except RuntimeError as e: + helper_logger.error("Error in change_2way_block_conditional_successor: {0}".format(e)) + log_block_info(blk, helper_logger.error) + log_block_info(new_blk_conditional_successor, helper_logger.error) + raise e + + +def update_blk_successor(blk: mblock_t, old_successor_serial: int, new_successor_serial: int) -> int: + if blk.nsucc() == 1: + change_1way_block_successor(blk, new_successor_serial) + elif blk.nsucc() == 2: + if old_successor_serial == blk.serial + 1: + helper_logger.info("Can't update direct block successor: {0} - {1} - {2}" + .format(blk.serial, old_successor_serial, new_successor_serial)) + return 0 + else: + change_2way_block_conditional_successor(blk, new_successor_serial) + else: + helper_logger.info("Can't update block successor: {0} ".format(blk.serial)) + return 0 + return 1 + + +def make_2way_block_goto(blk: mblock_t, blk_successor_serial: int) -> bool: + if blk.nsucc() != 2: + return False + mba = blk.mba + previous_blk_successor_serials = [x for x in blk.succset] + previous_blk_successors = [mba.get_mblock(x) for x in previous_blk_successor_serials] + + insert_goto_instruction(blk, blk_successor_serial, nop_previous_instruction=True) + + # Update block properties + blk.type = BLT_1WAY + blk.flags |= MBL_GOTO + + # Bookkeeping + for prev_serial in previous_blk_successor_serials: + blk.succset._del(prev_serial) + blk.succset.push_back(blk_successor_serial) + blk.mark_lists_dirty() + + for prev_blk in previous_blk_successors: + prev_blk.predset._del(blk.serial) + if prev_blk.serial != mba.qty - 1: + prev_blk.mark_lists_dirty() + + new_blk_successor = blk.mba.get_mblock(blk_successor_serial) + new_blk_successor.predset.push_back(blk.serial) + if new_blk_successor.serial != mba.qty - 1: + new_blk_successor.mark_lists_dirty() + + mba.mark_chains_dirty() + try: + mba.verify(True) + return True + except RuntimeError as e: + helper_logger.error("Error in make_2way_block_goto: {0}".format(e)) + log_block_info(blk, helper_logger.error) + log_block_info(new_blk_successor, helper_logger.error) + raise e + + +def create_block(blk: mblock_t, blk_ins: List[minsn_t], is_0_way: bool = False) -> mblock_t: + mba = blk.mba + new_blk = insert_nop_blk(blk) + for ins in blk_ins: + tmp_ins = minsn_t(ins) + new_blk.insert_into_block(tmp_ins, new_blk.tail) + + if is_0_way: + new_blk.type = BLT_0WAY + # Bookkeeping + prev_successor_serial = new_blk.succset[0] + new_blk.succset._del(prev_successor_serial) + prev_succ = mba.get_mblock(prev_successor_serial) + prev_succ.predset._del(new_blk.serial) + if prev_succ.serial != mba.qty - 1: + prev_succ.mark_lists_dirty() + + new_blk.mark_lists_dirty() + mba.mark_chains_dirty() + try: + mba.verify(True) + return new_blk + except RuntimeError as e: + helper_logger.error("Error in create_block: {0}".format(e)) + log_block_info(new_blk, helper_logger.error) + raise e + + +def update_block_successors(blk: mblock_t, blk_succ_serial_list: List[int]): + mba = blk.mba + if len(blk_succ_serial_list) == 0: + blk.type = BLT_0WAY + elif len(blk_succ_serial_list) == 1: + blk.type = BLT_1WAY + elif len(blk_succ_serial_list) == 2: + blk.type = BLT_2WAY + else: + raise + + # Remove old successors + prev_successor_serials = [x for x in blk.succset] + for prev_successor_serial in prev_successor_serials: + blk.succset._del(prev_successor_serial) + prev_succ = mba.get_mblock(prev_successor_serial) + prev_succ.predset._del(blk.serial) + if prev_succ.serial != mba.qty - 1: + prev_succ.mark_lists_dirty() + # Add new successors + for blk_succ_serial in blk_succ_serial_list: + blk.succset.push_back(blk_succ_serial) + new_blk_successor = mba.get_mblock(blk_succ_serial) + new_blk_successor.predset.push_back(blk.serial) + if new_blk_successor.serial != mba.qty - 1: + new_blk_successor.mark_lists_dirty() + + blk.mark_lists_dirty() + + +def insert_nop_blk(blk: mblock_t) -> mblock_t: + mba = blk.mba + nop_block = mba.copy_block(blk, blk.serial + 1) + cur_ins = nop_block.head + while cur_ins is not None: + nop_block.make_nop(cur_ins) + cur_ins = cur_ins.next + + nop_block.type = BLT_1WAY + + # We might have clone a block with multiple or no successor, thus we need to clean all + prev_successor_serials = [x for x in nop_block.succset] + + # Bookkeeping + for prev_successor_serial in prev_successor_serials: + nop_block.succset._del(prev_successor_serial) + prev_succ = mba.get_mblock(prev_successor_serial) + prev_succ.predset._del(nop_block.serial) + if prev_succ.serial != mba.qty - 1: + prev_succ.mark_lists_dirty() + + nop_block.succset.push_back(nop_block.serial + 1) + nop_block.mark_lists_dirty() + + new_blk_successor = mba.get_mblock(nop_block.serial + 1) + new_blk_successor.predset.push_back(nop_block.serial) + if new_blk_successor.serial != mba.qty - 1: + new_blk_successor.mark_lists_dirty() + + mba.mark_chains_dirty() + try: + mba.verify(True) + return nop_block + except RuntimeError as e: + helper_logger.error("Error in insert_nop_blk: {0}".format(e)) + log_block_info(nop_block, helper_logger.error) + raise e + + +def ensure_last_block_is_goto(mba: mbl_array_t) -> int: + last_blk = mba.get_mblock(mba.qty - 2) + if last_blk.nsucc() == 1: + change_1way_block_successor(last_blk, last_blk.succset[0]) + return 1 + elif last_blk.nsucc() == 0: + return 0 + else: + raise ControlFlowException("Last block {0} is not one way (not supported yet)".format(last_blk.serial)) + + +def duplicate_block(block_to_duplicate: mblock_t) -> Tuple[mblock_t, mblock_t]: + mba = block_to_duplicate.mba + duplicated_blk = mba.copy_block(block_to_duplicate, mba.qty - 1) + helper_logger.debug(" Duplicated {0} -> {1}".format(block_to_duplicate.serial, duplicated_blk.serial)) + duplicated_blk_default = None + if (block_to_duplicate.tail is not None) and is_mcode_jcond(block_to_duplicate.tail.opcode): + block_to_duplicate_default_successor = mba.get_mblock(block_to_duplicate.serial + 1) + duplicated_blk_default = insert_nop_blk(duplicated_blk) + change_1way_block_successor(duplicated_blk_default, block_to_duplicate.serial + 1) + helper_logger.debug(" {0} is conditional, so created a default child {1} for {2} which goto {3}" + .format(block_to_duplicate.serial, duplicated_blk_default.serial, duplicated_blk.serial, + block_to_duplicate_default_successor.serial)) + elif duplicated_blk.nsucc() == 1: + helper_logger.debug(" Making {0} goto {1}".format(duplicated_blk.serial, block_to_duplicate.succset[0])) + change_1way_block_successor(duplicated_blk, block_to_duplicate.succset[0]) + elif duplicated_blk.nsucc() == 0: + helper_logger.debug(" Duplicated block {0} has no successor => Nothing to do".format(duplicated_blk.serial)) + + return duplicated_blk, duplicated_blk_default + + +def change_block_address(block: mblock_t, new_ea: int): + # Can be used to fix error 50357 + mb_curr = block.head + while mb_curr: + mb_curr.ea = new_ea + mb_curr = mb_curr.next + + +def is_conditional_jump(blk: mblock_t) -> bool: + if (blk is not None) and (blk.tail is not None): + return blk.tail.opcode in CONDITIONAL_JUMP_OPCODES + return False + + +def is_indirect_jump(blk: mblock_t) -> bool: + if (blk is not None) and (blk.tail is not None): + return blk.tail.opcode == m_ijmp + return False + + +def get_block_serials_by_address(mba: mbl_array_t, address: int) -> List[int]: + blk_serial_list = [] + for i in range(mba.qty): + blk = mba.get_mblock(i) + if blk.start == address: + blk_serial_list.append(i) + return blk_serial_list + + +def get_block_serials_by_address_range(mba: mbl_array_t, address: int) -> List[int]: + blk_serial_list = [] + for i in range(mba.qty): + blk = mba.get_mblock(i) + if blk.start <= address <= blk.end: + blk_serial_list.append(i) + return blk_serial_list + + +def mba_remove_simple_goto_blocks(mba: mbl_array_t) -> int: + last_block_index = mba.qty - 1 + nb_change = 0 + for goto_blk_serial in range(last_block_index): + goto_blk: mblock_t = mba.get_mblock(goto_blk_serial) + if goto_blk.is_simple_goto_block(): + goto_blk_dst_serial = goto_blk.tail.l.b + goto_blk_preset = [x for x in goto_blk.predset] + for father_serial in goto_blk_preset: + father_blk: mblock_t = mba.get_mblock(father_serial) + nb_change += update_blk_successor(father_blk, goto_blk_serial, goto_blk_dst_serial) + return nb_change + + +def mba_deep_cleaning(mba: mbl_array_t) -> int: + if mba.maturity < MMAT_CALLS: + # Doing this optimization before MMAT_CALLS may create blocks with call instruction (not last instruction) + # IDA does like that and will raise a 50864 error + return 0 + mba.remove_empty_blocks() + mba.combine_blocks() + nb_change = mba_remove_simple_goto_blocks(mba) + if nb_change > 0: + mba.remove_empty_blocks() + mba.combine_blocks() + return nb_change + + +def ensure_child_has_an_unconditional_father(father_block: mblock_t, child_block: mblock_t) -> int: + if father_block is None: + return 0 + mba = father_block.mba + if father_block.nsucc() == 1: + return 0 + + if father_block.tail.d.b == child_block.serial: + helper_logger.debug("Father {0} is a conditional jump to child {1}, creating a new father" + .format(father_block.serial, child_block.serial)) + new_father_block = insert_nop_blk(mba.get_mblock(mba.qty - 2)) + change_1way_block_successor(new_father_block, child_block.serial) + change_2way_block_conditional_successor(father_block, new_father_block.serial) + else: + helper_logger.info("Father {0} is a conditional jump to child {1} (default child), creating a new father" + .format(father_block.serial, child_block.serial)) + new_father_block = insert_nop_blk(father_block) + change_1way_block_successor(new_father_block, child_block.serial) + return 1 diff --git a/d810/conf/__init__.py b/d810/conf/__init__.py new file mode 100644 index 0000000..d6290ed --- /dev/null +++ b/d810/conf/__init__.py @@ -0,0 +1,73 @@ +import os +import json + + +class D810Configuration(object): + def __init__(self): + self.config_dir = os.path.join(os.getenv("HOME"), ".idapro", "plugins", "d810", "conf") + self.config_file = os.path.join(self.config_dir, "options.json") + with open(self.config_file, "r") as fp: + self._options = json.load(fp) + + def get(self, name): + if (name == "log_dir") and (self._options[name] is None): + return os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")) + return self._options[name] + + def set(self, name, value): + self._options[name] = value + + def save(self): + with open(self.config_file, "w") as fp: + json.dump(self._options, fp, indent=2) + + +class RuleConfiguration(object): + def __init__(self, name=None, is_activated=False, config=None): + self.name = name + self.is_activated = is_activated + self.config = config if config is not None else {} + + def to_dict(self): + return { + "name": self.name, + "is_activated": self.is_activated, + "config": self.config + } + + @staticmethod + def from_dict(kwargs): + return RuleConfiguration(**kwargs) + + +class ProjectConfiguration(object): + def __init__(self, path=None, description=None, ins_rules=None, blk_rules=None, conf_dir=None): + self.path = path + self.description = description + self.conf_dir = conf_dir + self.ins_rules = [] if ins_rules is None else ins_rules + self.blk_rules = [] if blk_rules is None else blk_rules + self.additional_configuration = {} + + def load(self): + try: + with open(self.path, "r") as fp: + project_conf = json.load(fp) + except FileNotFoundError as e: + if self.conf_dir is not None: + self.path = os.path.join(self.conf_dir, self.path) + with open(self.path, "r") as fp: + project_conf = json.load(fp) + + self.description = project_conf["description"] + self.ins_rules = [RuleConfiguration.from_dict(x) for x in project_conf["ins_rules"]] + self.blk_rules = [RuleConfiguration.from_dict(x) for x in project_conf["blk_rules"]] + + def save(self): + project_conf = { + "description": self.description, + "ins_rules": [x.to_dict() for x in self.ins_rules], + "blk_rules": [x.to_dict() for x in self.blk_rules], + } + with open(self.path, "w") as fp: + json.dump(project_conf, fp, indent=2) diff --git a/d810/conf/default_instruction_only.json b/d810/conf/default_instruction_only.json new file mode 100644 index 0000000..f95ad56 --- /dev/null +++ b/d810/conf/default_instruction_only.json @@ -0,0 +1,921 @@ +{ + "description": "Default configuration of D-810 with only instruction level optimization", + "ins_rules": [ + { + "name": "AddXor_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AddXor_Rule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_5", + "is_activated": true, + "config": {} + }, + { + "name": "Add_OllvmRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Add_OllvmRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Add_OllvmRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Add_OllvmRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Add_SpecialConstantRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Add_SpecialConstantRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Add_SpecialConstantRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "And1_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_FactorRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "AndGetUpperBits_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndOr_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndXor_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "And_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "And_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "And_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "And_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "And_HackersDelightRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "And_HackersDelightRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "And_OllvmRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "And_OllvmRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "And_OllvmRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAdd_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAnd_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAnd_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAnd_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAnd_FactorRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "BnotOr_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotXor_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotXor_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotXor_Rule_2", + "is_activated": true, + "config": {} + }, + { + "name": "BnotXor_Rule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_FactorRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_XorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule1", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule10", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule11", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule12", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule13", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule14", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule15", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule16", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule17", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule18", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule19", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule2", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule20", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule21", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule22", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule3", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule4", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule5", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule6", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule7", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule8", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule9", + "is_activated": true, + "config": {} + }, + { + "name": "GetIdentRule1", + "is_activated": true, + "config": {} + }, + { + "name": "GetIdentRule2", + "is_activated": true, + "config": {} + }, + { + "name": "GetIdentRule3", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_MbaRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_MbaRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_MbaRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "NegAdd_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "NegAdd_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "NegOr_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "NegXor_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "NegXor_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Neg_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Neg_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "OrBnot_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "OrBnot_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "OrBnot_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "OrBnot_FactorRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Or_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Or_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Or_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Or_HackersDelightRule_2_variant_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_MbaRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Or_MbaRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Or_OllvmRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_Rule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Or_Rule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Or_Rule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule1", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule2", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule3", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule4", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule5", + "is_activated": true, + "config": {} + }, + { + "name": "PredFFRule1", + "is_activated": true, + "config": {} + }, + { + "name": "PredFFRule2", + "is_activated": true, + "config": {} + }, + { + "name": "PredFFRule3", + "is_activated": true, + "config": {} + }, + { + "name": "PredFFRule4", + "is_activated": true, + "config": {} + }, + { + "name": "PredOdd1", + "is_activated": true, + "config": {} + }, + { + "name": "PredOdd2", + "is_activated": true, + "config": {} + }, + { + "name": "PredOr1_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "PredOr2_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetbRule1", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule1", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule2", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule3", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule4", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule5", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule6", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule8", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetzRule1", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetzRule2", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetzRule3", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1Add_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1And1_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1And_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1Or_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Sub_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Sub_HackersDelightRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Sub_HackersDelightRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule1", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule2", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule3", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule4", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule5", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule6", + "is_activated": true, + "config": {} + }, + { + "name": "Xor1_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "XorAlmost_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_5", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_MbaRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_MbaRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_NestedStuff", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_Rule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_Rule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_SpecialConstantRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_SpecialConstantRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "AndChain", + "is_activated": true, + "config": {} + }, + { + "name": "ArithmeticChain", + "is_activated": true, + "config": {} + }, + { + "name": "OrChain", + "is_activated": true, + "config": {} + }, + { + "name": "XorChain", + "is_activated": true, + "config": {} + }, + { + "name": "Z3ConstantOptimization", + "is_activated": true, + "config": { + "min_nb_opcode": 4, + "min_nb_constant": 3 + } + }, + { + "name": "Z3SmodRuleGeneric", + "is_activated": true, + "config": {} + }, + { + "name": "Z3lnotRuleGeneric", + "is_activated": true, + "config": {} + }, + { + "name": "Z3setnzRuleGeneric", + "is_activated": true, + "config": {} + }, + { + "name": "Z3setzRuleGeneric", + "is_activated": true, + "config": {} + }, + { + "name": "ExampleGuessingRule", + "is_activated": true, + "config": { + "min_nb_var": 1, + "max_nb_var": 3, + "min_nb_diff_opcodes": 3, + "max_nb_diff_opcodes": 6 + } + } + ], + "blk_rules": [ + { + "name": "JumpFixer", + "is_activated": true, + "config": { + "enabled_rules": [ + "CompareConstantRule1", + "CompareConstantRule2", + "CompareConstantRule3", + "JaeRule1", + "JbRule1", + "JnzRule1", + "JnzRule2", + "JnzRule3", + "JnzRule4", + "JnzRule5", + "JnzRule6", + "JnzRule7", + "JnzRule8" + ] + } + } + ] +} \ No newline at end of file diff --git a/d810/conf/default_unflattening_ollvm.json b/d810/conf/default_unflattening_ollvm.json new file mode 100644 index 0000000..f31e10b --- /dev/null +++ b/d810/conf/default_unflattening_ollvm.json @@ -0,0 +1,926 @@ +{ + "description": "Unflattening O-LLVM with control flow flattening", + "ins_rules": [ + { + "name": "AddXor_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AddXor_Rule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_5", + "is_activated": true, + "config": {} + }, + { + "name": "Add_OllvmRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Add_OllvmRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Add_OllvmRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Add_OllvmRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Add_SpecialConstantRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Add_SpecialConstantRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Add_SpecialConstantRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "And1_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_FactorRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "AndGetUpperBits_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndOr_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndXor_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "And_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "And_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "And_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "And_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "And_HackersDelightRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "And_HackersDelightRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "And_OllvmRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "And_OllvmRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "And_OllvmRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAdd_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAnd_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAnd_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAnd_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAnd_FactorRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "BnotOr_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotXor_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotXor_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotXor_Rule_2", + "is_activated": true, + "config": {} + }, + { + "name": "BnotXor_Rule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_FactorRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_XorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule1", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule10", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule11", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule12", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule13", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule14", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule15", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule16", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule17", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule18", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule19", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule2", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule20", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule21", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule22", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule3", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule4", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule5", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule6", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule7", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule8", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule9", + "is_activated": true, + "config": {} + }, + { + "name": "GetIdentRule1", + "is_activated": true, + "config": {} + }, + { + "name": "GetIdentRule2", + "is_activated": true, + "config": {} + }, + { + "name": "GetIdentRule3", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_MbaRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_MbaRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_MbaRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "NegAdd_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "NegAdd_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "NegOr_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "NegXor_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "NegXor_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Neg_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Neg_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "OrBnot_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "OrBnot_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "OrBnot_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "OrBnot_FactorRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Or_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Or_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Or_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Or_HackersDelightRule_2_variant_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_MbaRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Or_MbaRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Or_OllvmRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_Rule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Or_Rule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Or_Rule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule1", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule2", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule3", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule4", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule5", + "is_activated": true, + "config": {} + }, + { + "name": "PredFFRule1", + "is_activated": true, + "config": {} + }, + { + "name": "PredFFRule2", + "is_activated": true, + "config": {} + }, + { + "name": "PredFFRule3", + "is_activated": true, + "config": {} + }, + { + "name": "PredFFRule4", + "is_activated": true, + "config": {} + }, + { + "name": "PredOdd1", + "is_activated": true, + "config": {} + }, + { + "name": "PredOdd2", + "is_activated": true, + "config": {} + }, + { + "name": "PredOr1_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "PredOr2_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetbRule1", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule1", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule2", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule3", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule4", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule5", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule6", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule8", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetzRule1", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetzRule2", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetzRule3", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1Add_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1And1_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1And_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1Or_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Sub_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Sub_HackersDelightRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Sub_HackersDelightRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule1", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule2", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule3", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule4", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule5", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule6", + "is_activated": true, + "config": {} + }, + { + "name": "Xor1_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "XorAlmost_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_5", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_MbaRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_MbaRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_NestedStuff", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_Rule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_Rule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_SpecialConstantRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_SpecialConstantRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "AndChain", + "is_activated": true, + "config": {} + }, + { + "name": "ArithmeticChain", + "is_activated": true, + "config": {} + }, + { + "name": "OrChain", + "is_activated": true, + "config": {} + }, + { + "name": "XorChain", + "is_activated": true, + "config": {} + }, + { + "name": "Z3ConstantOptimization", + "is_activated": true, + "config": { + "min_nb_opcode": 4, + "min_nb_constant": 3 + } + }, + { + "name": "Z3SmodRuleGeneric", + "is_activated": true, + "config": {} + }, + { + "name": "Z3lnotRuleGeneric", + "is_activated": true, + "config": {} + }, + { + "name": "Z3setnzRuleGeneric", + "is_activated": true, + "config": {} + }, + { + "name": "Z3setzRuleGeneric", + "is_activated": true, + "config": {} + }, + { + "name": "ExampleGuessingRule", + "is_activated": true, + "config": { + "min_nb_var": 1, + "max_nb_var": 3, + "min_nb_diff_opcodes": 3, + "max_nb_diff_opcodes": 6 + } + } + ], + "blk_rules": [ + { + "name": "Unflattener", + "is_activated": true, + "config": {} + }, + { + "name": "JumpFixer", + "is_activated": true, + "config": { + "enabled_rules": [ + "CompareConstantRule1", + "CompareConstantRule2", + "CompareConstantRule3", + "JaeRule1", + "JbRule1", + "JnzRule1", + "JnzRule2", + "JnzRule3", + "JnzRule4", + "JnzRule5", + "JnzRule6", + "JnzRule7", + "JnzRule8" + ] + } + } + ] +} \ No newline at end of file diff --git a/d810/conf/default_unflattening_switch_case.json b/d810/conf/default_unflattening_switch_case.json new file mode 100644 index 0000000..81db15a --- /dev/null +++ b/d810/conf/default_unflattening_switch_case.json @@ -0,0 +1,926 @@ +{ + "description": "Unflattening Tigress with switch case dispatcher", + "ins_rules": [ + { + "name": "AddXor_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AddXor_Rule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_5", + "is_activated": true, + "config": {} + }, + { + "name": "Add_OllvmRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Add_OllvmRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Add_OllvmRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Add_OllvmRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Add_SpecialConstantRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Add_SpecialConstantRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Add_SpecialConstantRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "And1_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_FactorRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "AndGetUpperBits_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndOr_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndXor_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "And_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "And_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "And_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "And_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "And_HackersDelightRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "And_HackersDelightRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "And_OllvmRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "And_OllvmRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "And_OllvmRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAdd_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAnd_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAnd_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAnd_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAnd_FactorRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "BnotOr_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotXor_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotXor_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotXor_Rule_2", + "is_activated": true, + "config": {} + }, + { + "name": "BnotXor_Rule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_FactorRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_XorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule1", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule10", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule11", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule12", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule13", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule14", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule15", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule16", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule17", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule18", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule19", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule2", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule20", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule21", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule22", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule3", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule4", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule5", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule6", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule7", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule8", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule9", + "is_activated": true, + "config": {} + }, + { + "name": "GetIdentRule1", + "is_activated": true, + "config": {} + }, + { + "name": "GetIdentRule2", + "is_activated": true, + "config": {} + }, + { + "name": "GetIdentRule3", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_MbaRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_MbaRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_MbaRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "NegAdd_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "NegAdd_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "NegOr_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "NegXor_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "NegXor_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Neg_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Neg_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "OrBnot_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "OrBnot_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "OrBnot_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "OrBnot_FactorRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Or_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Or_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Or_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Or_HackersDelightRule_2_variant_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_MbaRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Or_MbaRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Or_OllvmRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_Rule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Or_Rule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Or_Rule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule1", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule2", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule3", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule4", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule5", + "is_activated": true, + "config": {} + }, + { + "name": "PredFFRule1", + "is_activated": true, + "config": {} + }, + { + "name": "PredFFRule2", + "is_activated": true, + "config": {} + }, + { + "name": "PredFFRule3", + "is_activated": true, + "config": {} + }, + { + "name": "PredFFRule4", + "is_activated": true, + "config": {} + }, + { + "name": "PredOdd1", + "is_activated": true, + "config": {} + }, + { + "name": "PredOdd2", + "is_activated": true, + "config": {} + }, + { + "name": "PredOr1_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "PredOr2_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetbRule1", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule1", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule2", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule3", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule4", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule5", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule6", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule8", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetzRule1", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetzRule2", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetzRule3", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1Add_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1And1_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1And_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1Or_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Sub_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Sub_HackersDelightRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Sub_HackersDelightRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule1", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule2", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule3", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule4", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule5", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule6", + "is_activated": true, + "config": {} + }, + { + "name": "Xor1_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "XorAlmost_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_5", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_MbaRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_MbaRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_NestedStuff", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_Rule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_Rule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_SpecialConstantRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_SpecialConstantRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "AndChain", + "is_activated": true, + "config": {} + }, + { + "name": "ArithmeticChain", + "is_activated": true, + "config": {} + }, + { + "name": "OrChain", + "is_activated": true, + "config": {} + }, + { + "name": "XorChain", + "is_activated": true, + "config": {} + }, + { + "name": "Z3ConstantOptimization", + "is_activated": true, + "config": { + "min_nb_opcode": 4, + "min_nb_constant": 3 + } + }, + { + "name": "Z3SmodRuleGeneric", + "is_activated": true, + "config": {} + }, + { + "name": "Z3lnotRuleGeneric", + "is_activated": true, + "config": {} + }, + { + "name": "Z3setnzRuleGeneric", + "is_activated": true, + "config": {} + }, + { + "name": "Z3setzRuleGeneric", + "is_activated": true, + "config": {} + }, + { + "name": "ExampleGuessingRule", + "is_activated": true, + "config": { + "min_nb_var": 1, + "max_nb_var": 3, + "min_nb_diff_opcodes": 3, + "max_nb_diff_opcodes": 6 + } + } + ], + "blk_rules": [ + { + "name": "UnflattenerSwitchCase", + "is_activated": true, + "config": {} + }, + { + "name": "JumpFixer", + "is_activated": true, + "config": { + "enabled_rules": [ + "CompareConstantRule1", + "CompareConstantRule2", + "CompareConstantRule3", + "JaeRule1", + "JbRule1", + "JnzRule1", + "JnzRule2", + "JnzRule3", + "JnzRule4", + "JnzRule5", + "JnzRule6", + "JnzRule7", + "JnzRule8" + ] + } + } + ] +} \ No newline at end of file diff --git a/d810/conf/example_anel.json b/d810/conf/example_anel.json new file mode 100644 index 0000000..33dec07 --- /dev/null +++ b/d810/conf/example_anel.json @@ -0,0 +1,942 @@ +{ + "description": "Configuration to deobfuscate ANEL malware", + "ins_rules": [ + { + "name": "AddXor_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AddXor_Rule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Add_HackersDelightRule_5", + "is_activated": true, + "config": {} + }, + { + "name": "Add_OllvmRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Add_OllvmRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Add_OllvmRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Add_OllvmRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Add_SpecialConstantRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Add_SpecialConstantRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Add_SpecialConstantRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "And1_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_FactorRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndBnot_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "AndGetUpperBits_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndOr_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "AndXor_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "And_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "And_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "And_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "And_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "And_HackersDelightRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "And_HackersDelightRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "And_OllvmRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "And_OllvmRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "And_OllvmRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAdd_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAnd_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAnd_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAnd_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "BnotAnd_FactorRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "BnotOr_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotXor_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotXor_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "BnotXor_Rule_2", + "is_activated": true, + "config": {} + }, + { + "name": "BnotXor_Rule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_FactorRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Bnot_XorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule1", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule10", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule11", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule12", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule13", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule14", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule15", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule16", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule17", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule18", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule19", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule2", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule20", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule21", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule22", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule3", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule4", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule5", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule6", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule7", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule8", + "is_activated": true, + "config": {} + }, + { + "name": "CstSimplificationRule9", + "is_activated": true, + "config": {} + }, + { + "name": "GetIdentRule1", + "is_activated": true, + "config": {} + }, + { + "name": "GetIdentRule2", + "is_activated": true, + "config": {} + }, + { + "name": "GetIdentRule3", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_MbaRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_MbaRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Mul_MbaRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "NegAdd_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "NegAdd_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "NegOr_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "NegXor_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "NegXor_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Neg_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Neg_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "OrBnot_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "OrBnot_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "OrBnot_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "OrBnot_FactorRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Or_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Or_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Or_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Or_HackersDelightRule_2_variant_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_MbaRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Or_MbaRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Or_OllvmRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Or_Rule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Or_Rule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Or_Rule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule1", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule2", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule3", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule4", + "is_activated": true, + "config": {} + }, + { + "name": "Pred0Rule5", + "is_activated": true, + "config": {} + }, + { + "name": "PredFFRule1", + "is_activated": true, + "config": {} + }, + { + "name": "PredFFRule2", + "is_activated": true, + "config": {} + }, + { + "name": "PredFFRule3", + "is_activated": true, + "config": {} + }, + { + "name": "PredFFRule4", + "is_activated": true, + "config": {} + }, + { + "name": "PredOdd1", + "is_activated": true, + "config": {} + }, + { + "name": "PredOdd2", + "is_activated": true, + "config": {} + }, + { + "name": "PredOr1_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "PredOr2_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetbRule1", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule1", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule2", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule3", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule4", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule5", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule6", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetnzRule8", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetzRule1", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetzRule2", + "is_activated": true, + "config": {} + }, + { + "name": "PredSetzRule3", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1Add_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1And1_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1And_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1Or_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub1_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Sub_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Sub_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Sub_HackersDelightRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Sub_HackersDelightRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule1", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule2", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule3", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule4", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule5", + "is_activated": true, + "config": {} + }, + { + "name": "WeirdRule6", + "is_activated": true, + "config": {} + }, + { + "name": "Xor1_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "XorAlmost_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_FactorRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_FactorRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_FactorRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_4", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_HackersDelightRule_5", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_MbaRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_MbaRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_MbaRule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_NestedStuff", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_Rule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_Rule_2", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_Rule_3", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_SpecialConstantRule_1", + "is_activated": true, + "config": {} + }, + { + "name": "Xor_SpecialConstantRule_2", + "is_activated": true, + "config": {} + }, + { + "name": "AndChain", + "is_activated": true, + "config": {} + }, + { + "name": "ArithmeticChain", + "is_activated": true, + "config": {} + }, + { + "name": "OrChain", + "is_activated": true, + "config": {} + }, + { + "name": "XorChain", + "is_activated": true, + "config": {} + }, + { + "name": "Z3ConstantOptimization", + "is_activated": true, + "config": { + "min_nb_opcode": 4, + "min_nb_constant": 3 + } + }, + { + "name": "Z3SmodRuleGeneric", + "is_activated": true, + "config": {} + }, + { + "name": "Z3lnotRuleGeneric", + "is_activated": true, + "config": {} + }, + { + "name": "Z3setnzRuleGeneric", + "is_activated": true, + "config": {} + }, + { + "name": "Z3setzRuleGeneric", + "is_activated": true, + "config": {} + }, + { + "name": "SetGlobalVariablesToZeroIfDetectedReadOnly", + "is_activated": true, + "config": {} + }, + { + "name": "ExampleGuessingRule", + "is_activated": true, + "config": { + "min_nb_var": 1, + "max_nb_var": 3, + "min_nb_diff_opcodes": 3, + "max_nb_diff_opcodes": 6 + } + } + ], + "blk_rules": [ + { + "name": "Unflattener", + "is_activated": true, + "config": { + "maturities": [ + "MMAT_CALLS", + "MMAT_GLBOPT1", + "MMAT_GLBOPT2" + ] + } + }, + { + "name": "UnflattenerFakeJump", + "is_activated": true, + "config": {} + }, + { + "name": "JumpFixer", + "is_activated": true, + "config": { + "enabled_rules": [ + "CompareConstantRule1", + "CompareConstantRule2", + "CompareConstantRule3", + "JaeRule1", + "JbRule1", + "JnzRule1", + "JnzRule2", + "JnzRule3", + "JnzRule4", + "JnzRule5", + "JnzRule6", + "JnzRule7", + "JnzRule8" + ] + } + } + ] +} \ No newline at end of file diff --git a/d810/conf/options.json b/d810/conf/options.json new file mode 100644 index 0000000..cee4a67 --- /dev/null +++ b/d810/conf/options.json @@ -0,0 +1,14 @@ +{ + "erase_logs_on_reload": true, + "generate_z3_code": true, + "dump_intermediate_microcode": true, + "log_dir": null, + "configurations": [ + "default_instruction_only.json", + "default_unflattening_ollvm.json", + "default_unflattening_switch_case.json", + "example_anel.json", + "example_unflattening_indirect.json" + ], + "last_project_index": 0 +} \ No newline at end of file diff --git a/d810/docs/source/images/gui_plugin_configuration.png b/d810/docs/source/images/gui_plugin_configuration.png new file mode 100644 index 0000000000000000000000000000000000000000..0c634d89b7dd0a5a39a4554ce79bebf6604159ae GIT binary patch literal 69428 zcmbrmby!r<_dYs+B1njUgp`Q1gmi<0bhorL3?(4lQc5EwE!`m9p-6W(NDMhNL&x2I zzMt>!-uvf$F3&vA%rmpkK4-79_FC_H-*xz^tSE)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