├── .gitattributes ├── .gitignore ├── LICENSE.md ├── README.md ├── pom.xml └── src └── main └── java └── xyz └── breversed ├── BReversed.java ├── api ├── Config.java ├── asm │ ├── JarInterface.java │ ├── detection │ │ ├── AbstractDetector.java │ │ └── Detector.java │ ├── transformer │ │ ├── Transformer.java │ │ ├── TransformerManager.java │ │ └── comparator │ │ │ ├── CompTarget.java │ │ │ └── TransformerComparator.java │ └── utils │ │ └── RenameUtil.java └── utils │ ├── CharUtil.java │ └── ConsoleUtil.java ├── comparators ├── BozarComparator.java └── ScutiComparator.java ├── detectors ├── antiskid │ ├── AntiSkidEncryption.java │ └── AntiSkidNative.java ├── bozar │ ├── BozarFlow.java │ ├── BozarNumber.java │ └── BozarString.java ├── crasher │ └── ImageCrasher.java ├── jnic │ └── JNICLoader.java ├── scuti │ ├── ScutiClassEncrypt.java │ ├── ScutiFastString.java │ ├── ScutiFlow.java │ ├── ScutiInvokeDynamic.java │ ├── ScutiNumber.java │ └── ScutiStrongString.java └── universal │ └── Renamer.java └── transformers ├── bozar ├── BozarConstantFlow.java ├── BozarCrasher.java ├── BozarHeavyFlow.java ├── BozarLightFlow.java ├── BozarNumber.java └── BozarString.java ├── crasher └── IMGCrasherRemover.java ├── generic └── ZipEntryRemapper.java ├── jnic └── JNICDecryptor.java └── scuti ├── ScutiClassEncrypt.java ├── ScutiFastString.java ├── ScutiFlow.java ├── ScutiInvokeDynamic.java ├── ScutiNumber.java └── ScutiStrongString.java /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | replay_pid* 25 | 26 | jars/** 27 | 28 | # manuel 29 | /.idea/ 30 | /target/ 31 | *.iml 32 | *.json 33 | 34 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BReversed 2 | A java bytecode deobfuscator 3 | 4 | **dependencies** 5 | - you will need to add the src path of these repos: 6 | - 7 | - JLIB: https://github.com/Exeos/jlib 8 | - ASMPlus: https://github.com/Exeos/asmplus 9 | 10 | **Config** 11 | > Creating the config: 12 | > 13 | > 1. Create a file called "config.json". 14 | > 2. Add the following template. 15 | > 16 | Template: 17 | ``` 18 | { 19 | "task": "DETECT", 20 | 21 | "path": "jars", 22 | "input": "in.jar", 23 | "output": "out.jar", 24 | 25 | "renamerString": "BReversed", 26 | 27 | "transformers": [ 28 | "crasher/IMGCrasherRemover", 29 | "bozar/", 30 | "!BozarLightFlow" 31 | ] 32 | } 33 | ``` 34 | Explanation: 35 | ``` 36 | "task": 37 | - "DETECT", use to detect obfuscators 38 | - "TRANSFORM", use to deobfuscate 39 | 40 | "path": use if jars are in a different path 41 | "input": input jar name, ".jar" is optional 42 | "output": output jar name, ".jar" is optional 43 | 44 | "renamerString": The new name renamed objects (+ the index) 45 | 46 | "transformers": list of transformers for deobfuscation: 47 | use "packagename/TransformerSimpleName" to add singular transformer, 48 | if you only use "packagename/" to add all transformers in that package. You can also user "!TransformerSimpleName" to exclude it. 49 | ``` 50 | 51 | https://user-images.githubusercontent.com/59488004/197333146-89ba82b3-da07-47c8-8b26-fd73a2094044.mp4 52 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | xyz.breversed 8 | BReversed 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 13 | jitpack.io 14 | https://jitpack.io 15 | 16 | 17 | 18 | 19 | 19 20 | 19 21 | UTF-8 22 | 23 | 24 | 25 | 26 | org.apache.maven.plugins 27 | maven-compiler-plugin 28 | 29 | 19 30 | 19 31 | --enable-preview 32 | 33 | 34 | 35 | 36 | 37 | 38 | org.ow2.asm 39 | asm 40 | 9.5 41 | 42 | 43 | org.ow2.asm 44 | asm-commons 45 | 9.5 46 | 47 | 48 | org.ow2.asm 49 | asm-util 50 | 9.5 51 | 52 | 53 | org.ow2.asm 54 | asm-tree 55 | 9.5 56 | 57 | 58 | org.ow2.asm 59 | asm-analysis 60 | 9.5 61 | 62 | 63 | org.projectlombok 64 | lombok 65 | 1.18.26 66 | compile 67 | 68 | 69 | commons-io 70 | commons-io 71 | 2.11.0 72 | 73 | 74 | com.google.code.gson 75 | gson 76 | 2.10.1 77 | 78 | 79 | org.reflections 80 | reflections 81 | 0.10.2 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/BReversed.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed; 2 | 3 | import me.exeos.asmplus.JarLoader; 4 | import me.exeos.asmplus.utils.ASMUtils; 5 | import xyz.breversed.api.Config; 6 | import xyz.breversed.api.asm.detection.Detector; 7 | import xyz.breversed.api.asm.transformer.TransformerManager; 8 | import xyz.breversed.api.utils.ConsoleUtil; 9 | 10 | import java.io.IOException; 11 | 12 | public enum BReversed { 13 | 14 | INSTANCE; 15 | 16 | private final String[] authors = new String[] { "Exeos", "$kush" }; 17 | 18 | public final Config config = new Config(); 19 | public final JarLoader jarLoader = new JarLoader(); 20 | public final TransformerManager transformerManager = new TransformerManager(); 21 | private final Detector detector = new Detector(); 22 | 23 | public static void main(String[] args) { 24 | BReversed.INSTANCE.start(); 25 | } 26 | 27 | public void start() { 28 | System.out.println(""" 29 | ____ _____ _\s 30 | | _ \\| __ \\ | | 31 | | |_) | |__) |_____ _____ _ __ ___ ___ __| | 32 | | _ <| _ // _ \\ \\ / / _ \\ '__/ __|/ _ \\/ _` | 33 | | |_) | | \\ \\ __/\\ V / __/ | \\__ \\ __/ (_| | 34 | |____/|_| \\_\\___| \\_/ \\___|_| |___/\\___|\\__,_|"""); 35 | System.out.println("by " + getAuthorsFormatted()); 36 | 37 | { 38 | System.out.println("______________________________________________________________"); 39 | ConsoleUtil.start("Loading Config"); 40 | try { 41 | config.loadConfig(); 42 | ConsoleUtil.finish(); 43 | } catch (Exception e) { 44 | System.out.println("Error loading config:"); 45 | e.printStackTrace(); 46 | return; 47 | } 48 | 49 | ConsoleUtil.start("Loading jar"); 50 | try { 51 | ASMUtils.setJar(jarLoader); 52 | jarLoader.load(config.getPath() + config.jars[0]); 53 | } catch (IOException e) { 54 | e.printStackTrace(); 55 | return; 56 | } 57 | ConsoleUtil.finish(); 58 | 59 | switch (config.task) { 60 | case DETECT -> { 61 | ConsoleUtil.start("Detecting obfuscation"); 62 | detector.detect(); 63 | } 64 | case TRANSFORM -> { 65 | ConsoleUtil.start("Deobfuscation"); 66 | transformerManager.transform(); 67 | ConsoleUtil.finish(); 68 | 69 | ConsoleUtil.start("Exporting jar"); 70 | try { 71 | jarLoader.export(config.getPath() + config.jars[1]); 72 | } catch (Exception e) { 73 | e.printStackTrace(); 74 | } 75 | } 76 | } 77 | ConsoleUtil.finishNoLine(); 78 | System.out.println("______________________________________________________________"); 79 | } 80 | 81 | System.out.println(); 82 | System.out.println("BReversed by " + getAuthorsFormatted()); 83 | } 84 | 85 | private String getAuthorsFormatted() { 86 | StringBuilder builder = new StringBuilder(); 87 | for (int i = 0; i < authors.length; i++) 88 | builder.append(authors[i]).append((i + 1 == authors.length ? "" : (i + 2 >= authors.length ? " and " : ", "))); 89 | 90 | return builder.toString(); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/api/Config.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.api; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.JsonArray; 5 | import com.google.gson.JsonObject; 6 | import com.google.gson.JsonParser; 7 | import org.reflections.Reflections; 8 | import org.reflections.scanners.SubTypesScanner; 9 | import xyz.breversed.BReversed; 10 | import xyz.breversed.api.asm.transformer.Transformer; 11 | 12 | import java.io.FileReader; 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | import java.util.stream.Collectors; 16 | 17 | public class Config { 18 | 19 | public Task task = Task.DETECT; 20 | 21 | private String path; 22 | public final String[] jars = new String[2]; 23 | 24 | public String renamerStr; 25 | 26 | 27 | public void loadConfig() throws Exception { 28 | FileReader configFile = new FileReader("config.json"); 29 | JsonObject configObject = JsonParser.parseReader(configFile).getAsJsonObject(); 30 | 31 | task = Task.valueOf(configObject.get("task").getAsString()); 32 | 33 | /* jar to target and jar export to */ 34 | 35 | path = configObject.get("path").getAsString(); 36 | jars[0] = configObject.get("input").getAsString() + (configObject.get("input").getAsString().endsWith(".jar") ? "" : ".jar"); 37 | jars[1] = configObject.get("output").getAsString() + (configObject.get("output").getAsString().endsWith(".jar") ? "" : ".jar"); 38 | 39 | 40 | renamerStr = configObject.get("renamerString").getAsString(); 41 | 42 | JsonArray transformers = configObject.get("transformers").getAsJsonArray(); 43 | ArrayList actives = new ArrayList<>(new Gson().fromJson(transformers, ArrayList.class)); 44 | 45 | /* Scrape all sub packages in xyz.breversed.transformers and add to HashMap> */ 46 | scrape(); 47 | /* Adding transformers, if input is "package/" add all transformers in that package */ 48 | List exclude = actives.stream().filter(s -> s.startsWith("!")).collect(Collectors.toList()); 49 | exclude.replaceAll(s -> s.substring(1)); 50 | for (String active : actives) { 51 | String[] split = active.replace(".", "/").split("/"); 52 | scanAndAdd(split[0], split.length == 1 ? "" : split[1], exclude); 53 | } 54 | } 55 | 56 | private void scanAndAdd(String subPackage, String className, List exclude) { 57 | Reflections reflections = new Reflections("xyz.breversed.transformers." + subPackage, new SubTypesScanner(false)); 58 | for (Class aClass : reflections.getSubTypesOf(Transformer.class)) { 59 | if ((className.isEmpty() && !exclude.contains(aClass.getSimpleName())) || className.equals(aClass.getSimpleName())) { 60 | try { 61 | /* Dupe check, might remove in future when you have to use the same transformer more than once */ 62 | if (BReversed.INSTANCE.transformerManager.transformerMap.get(subPackage).stream().filter(transformer -> transformer.getClass() == aClass).findFirst().orElse(null) == null) 63 | BReversed.INSTANCE.transformerManager.transformerMap.get(subPackage).add(aClass.newInstance()); 64 | } catch (InstantiationException | IllegalAccessException e) { 65 | throw new RuntimeException(e); 66 | } 67 | } 68 | } 69 | } 70 | 71 | private void scrape() { 72 | Reflections reflections = new Reflections("xyz.breversed.transformers", new SubTypesScanner(false)); 73 | for (Class aClass : reflections.getSubTypesOf(Transformer.class)) { 74 | if (!BReversed.INSTANCE.transformerManager.transformerMap.containsKey(getLastSubPackage(aClass))) 75 | BReversed.INSTANCE.transformerManager.transformerMap.put(getLastSubPackage(aClass), new ArrayList<>()); 76 | } 77 | } 78 | 79 | private String getLastSubPackage(Class aClass) { 80 | String[] split = aClass.getPackageName().split("\\."); 81 | return split[split.length - 1]; 82 | } 83 | 84 | public String getPath() { 85 | return path.isEmpty() ? path : path.endsWith("\\") ? path : path.contains("\\") ? path + "\\" : path + "/"; 86 | } 87 | 88 | public enum Task { 89 | DETECT, TRANSFORM 90 | } 91 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/api/asm/JarInterface.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.api.asm; 2 | 3 | import org.objectweb.asm.tree.ClassNode; 4 | import xyz.breversed.BReversed; 5 | 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | 9 | public interface JarInterface { 10 | 11 | default void removeClass(ClassNode classNode) { 12 | BReversed.INSTANCE.jarLoader.classes.remove(classNode.name); 13 | } 14 | 15 | default void removeResource(String name) { 16 | BReversed.INSTANCE.jarLoader.resources.remove(name); 17 | } 18 | 19 | default ArrayList getClasses() { 20 | return new ArrayList<>(BReversed.INSTANCE.jarLoader.classes.values()); 21 | } 22 | 23 | default HashMap getResources() { 24 | return BReversed.INSTANCE.jarLoader.resources; 25 | } 26 | 27 | default ClassNode getClass(String name) { 28 | return BReversed.INSTANCE.jarLoader.classes.get(name); 29 | } 30 | 31 | default byte[] getResource(String name) { 32 | return BReversed.INSTANCE.jarLoader.resources.get(name); 33 | } 34 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/api/asm/detection/AbstractDetector.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.api.asm.detection; 2 | 3 | import org.objectweb.asm.Opcodes; 4 | import xyz.breversed.api.asm.JarInterface; 5 | 6 | import java.util.ArrayList; 7 | 8 | public abstract class AbstractDetector implements JarInterface, Opcodes { 9 | 10 | public final ArrayList context = new ArrayList<>(); 11 | 12 | protected abstract boolean detect(); 13 | 14 | protected void addContext(String context) { 15 | if (!this.context.contains(context)) 16 | this.context.add(context); 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return getClass().getSimpleName(); 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/api/asm/detection/Detector.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.api.asm.detection; 2 | 3 | import org.reflections.Reflections; 4 | import org.reflections.scanners.SubTypesScanner; 5 | 6 | public class Detector { 7 | 8 | public void detect() { 9 | Reflections reflections = new Reflections("xyz.breversed.detectors", new SubTypesScanner(false)); 10 | reflections.getSubTypesOf(AbstractDetector.class).forEach(detectorClass -> { 11 | try { 12 | AbstractDetector detector = detectorClass.newInstance(); 13 | if (detector.detect()) { 14 | System.out.println("Detected " + detector); 15 | if (!detector.context.isEmpty()) { 16 | System.out.println("{"); 17 | for (String context : detector.context) { 18 | System.out.println("\t" + context); 19 | } 20 | System.out.println("}"); 21 | } 22 | } 23 | } catch (InstantiationException | IllegalAccessException e) { 24 | System.out.println("Error adding Detectors:"); 25 | e.printStackTrace(); 26 | } 27 | }); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/api/asm/transformer/Transformer.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.api.asm.transformer; 2 | 3 | import org.objectweb.asm.Opcodes; 4 | import xyz.breversed.api.asm.JarInterface; 5 | 6 | public abstract class Transformer implements JarInterface, Opcodes { 7 | 8 | protected abstract void transform(); 9 | 10 | @Override 11 | public String toString() { 12 | return getClass().getSimpleName() + " transformer"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/api/asm/transformer/TransformerManager.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.api.asm.transformer; 2 | 3 | import org.reflections.Reflections; 4 | import org.reflections.scanners.SubTypesScanner; 5 | import xyz.breversed.api.asm.transformer.comparator.CompTarget; 6 | import xyz.breversed.api.asm.transformer.comparator.TransformerComparator; 7 | 8 | import java.util.ArrayList; 9 | import java.util.HashMap; 10 | 11 | public class TransformerManager { 12 | 13 | public final HashMap> transformerMap = new HashMap<>(); 14 | public final ArrayList transformers = new ArrayList<>(); 15 | 16 | public void transform() { 17 | sortAndAdd(); 18 | for (Transformer transformer : transformers) { 19 | System.out.println("Running " + transformer + " "); 20 | try { 21 | transformer.transform(); 22 | System.out.println("Success!"); 23 | } catch (Exception e) { 24 | System.out.println("Error running " + transformer + " transformer:"); 25 | e.printStackTrace(); 26 | } 27 | } 28 | } 29 | 30 | private void sortAndAdd() { 31 | Reflections reflections = new Reflections("xyz.breversed.comparators", new SubTypesScanner(false)); 32 | for (Class aClass : reflections.getSubTypesOf(TransformerComparator.class)) { 33 | if (aClass.getAnnotation(CompTarget.class) == null) 34 | continue; 35 | try { 36 | String target = aClass.getAnnotation(CompTarget.class).target(); 37 | transformerMap.get(target).sort(aClass.newInstance()); 38 | } catch (InstantiationException | IllegalAccessException e) { 39 | System.out.println("Error sorting transformers"); 40 | e.printStackTrace(); 41 | } 42 | } 43 | 44 | for (String p : transformerMap.keySet()) { 45 | transformers.addAll(transformerMap.get(p)); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/api/asm/transformer/comparator/CompTarget.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.api.asm.transformer.comparator; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.TYPE) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface CompTarget { 11 | 12 | /* Package to apply the comparator to */ 13 | String target(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/api/asm/transformer/comparator/TransformerComparator.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.api.asm.transformer.comparator; 2 | 3 | import xyz.breversed.api.asm.transformer.Transformer; 4 | 5 | import java.util.Comparator; 6 | 7 | public abstract class TransformerComparator implements Comparator { 8 | 9 | protected abstract int getIndex(Transformer transformer); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/api/asm/utils/RenameUtil.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.api.asm.utils; 2 | 3 | import lombok.experimental.UtilityClass; 4 | import org.objectweb.asm.tree.ClassNode; 5 | import xyz.breversed.BReversed; 6 | import xyz.breversed.api.asm.JarInterface; 7 | 8 | @UtilityClass 9 | public class RenameUtil { 10 | 11 | private int index = 0; 12 | 13 | public String rename() { 14 | return BReversed.INSTANCE.config.renamerStr + index++; 15 | } 16 | 17 | public void rename(ClassNode classNode) { 18 | BReversed.INSTANCE.jarLoader.classes.get(classNode.name).name = rename(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/api/utils/CharUtil.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.api.utils; 2 | 3 | import lombok.experimental.UtilityClass; 4 | 5 | @UtilityClass 6 | public class CharUtil { 7 | 8 | public boolean containsUnAlphabetic(String input) { 9 | for (char c : input.toCharArray()) { 10 | if (!Character.isLetterOrDigit(c)) 11 | return true; 12 | } 13 | return false; 14 | } 15 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/api/utils/ConsoleUtil.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.api.utils; 2 | 3 | import lombok.experimental.UtilityClass; 4 | 5 | @UtilityClass 6 | public class ConsoleUtil { 7 | 8 | private String task; 9 | private int taskIndex = 1; 10 | 11 | public void start(String task) { 12 | ConsoleUtil.task = task; 13 | println("Starting task " + taskIndex + ": " + task); 14 | } 15 | 16 | public void finish() { 17 | println("Finished task " + taskIndex + ": " + task); 18 | println(); 19 | taskIndex++; 20 | } 21 | 22 | public void finishNoLine() { 23 | println("Finished task " + taskIndex + ": " + task); 24 | taskIndex++; 25 | } 26 | 27 | public void println() { 28 | println(""); 29 | } 30 | 31 | public void println(Object line) { 32 | // TODO send to gui console when connected 33 | System.out.println(line); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/comparators/BozarComparator.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.comparators; 2 | 3 | import xyz.breversed.api.asm.transformer.Transformer; 4 | import xyz.breversed.api.asm.transformer.comparator.CompTarget; 5 | import xyz.breversed.api.asm.transformer.comparator.TransformerComparator; 6 | 7 | @CompTarget(target = "bozar") 8 | public class BozarComparator extends TransformerComparator { 9 | 10 | @Override 11 | public int compare(Transformer t1, Transformer t2) { 12 | int index1 = getIndex(t1); 13 | int index2 = getIndex(t2); 14 | return Integer.compare(index1, index2); 15 | } 16 | 17 | @Override 18 | protected int getIndex(Transformer transformer) { 19 | return switch (transformer.getClass().getSimpleName()) { 20 | case "BozarCrasher" -> 0; 21 | case "BozarNumber" -> 1; 22 | case "BozarConstantFlow" -> 2; 23 | case "BozarString" -> 3; 24 | case "BozarHeavyFlow", "BozarLightFlow" -> 4; 25 | default -> Integer.MAX_VALUE; 26 | }; 27 | } 28 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/comparators/ScutiComparator.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.comparators; 2 | 3 | import xyz.breversed.api.asm.transformer.Transformer; 4 | import xyz.breversed.api.asm.transformer.comparator.CompTarget; 5 | import xyz.breversed.api.asm.transformer.comparator.TransformerComparator; 6 | 7 | @CompTarget(target = "scuti") 8 | public class ScutiComparator extends TransformerComparator { 9 | 10 | @Override 11 | public int compare(Transformer t1, Transformer t2) { 12 | int index1 = getIndex(t1); 13 | int index2 = getIndex(t2); 14 | return Integer.compare(index1, index2); 15 | } 16 | 17 | @Override 18 | protected int getIndex(Transformer transformer) { 19 | return switch (transformer.getClass().getSimpleName()) { 20 | case "ScutiNumber" -> 0; 21 | case "ScutiFlow" -> 1; 22 | case "ScutiInvokeDynamic" -> 2; 23 | case "ScutiFastString", "ScutiStrongString" -> 3; 24 | case "ScutiClassEncrypt" -> 4; 25 | default -> Integer.MAX_VALUE; 26 | }; 27 | } 28 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/detectors/antiskid/AntiSkidEncryption.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.detectors.antiskid; 2 | 3 | import org.objectweb.asm.tree.ClassNode; 4 | import xyz.breversed.api.asm.detection.AbstractDetector; 5 | 6 | public class AntiSkidEncryption extends AbstractDetector { 7 | 8 | @Override 9 | protected boolean detect() { 10 | for (ClassNode classNode : getClasses()) 11 | if (classNode.superName != null && classNode.superName.equals("java/lang/ClassLoader") && classNode.name.startsWith("club/antiskid")) 12 | return true; 13 | 14 | return false; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/detectors/antiskid/AntiSkidNative.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.detectors.antiskid; 2 | 3 | import me.exeos.asmplus.utils.ASMUtils; 4 | import org.objectweb.asm.tree.ClassNode; 5 | import xyz.breversed.api.asm.detection.AbstractDetector; 6 | 7 | public class AntiSkidNative extends AbstractDetector { 8 | 9 | @Override 10 | protected boolean detect() { 11 | for (ClassNode classNode : getClasses()) 12 | if (classNode.name.startsWith("native0") && ASMUtils.getMethod(classNode, "registerNativesForClass", "(ILjava/lang/Class;)V", "(ILjava/lang/Class<*>;)V") != null) 13 | return true; 14 | 15 | return false; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/detectors/bozar/BozarFlow.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.detectors.bozar; 2 | 3 | import me.exeos.asmplus.pattern.PatternParts; 4 | import me.exeos.asmplus.pattern.PatternScanner; 5 | import org.objectweb.asm.tree.ClassNode; 6 | import org.objectweb.asm.tree.FieldNode; 7 | import org.objectweb.asm.tree.MethodNode; 8 | import xyz.breversed.api.asm.detection.AbstractDetector; 9 | 10 | public class BozarFlow extends AbstractDetector implements PatternParts { 11 | 12 | @Override 13 | protected boolean detect() { 14 | boolean detected = false; 15 | PatternScanner patternScanner = new PatternScanner(); 16 | 17 | for (ClassNode classNode : getClasses()) { 18 | for (FieldNode field : classNode.fields) { 19 | if (field.name.equals(String.valueOf((char)5096)) && field.desc.equals("J")) { 20 | addContext("Found flow field"); 21 | detected = true; 22 | break; 23 | } 24 | } 25 | 26 | for (MethodNode methodNode : classNode.methods) { 27 | if (lightFlow0(patternScanner, methodNode) || lightFlow1(patternScanner, methodNode)) { 28 | addContext("Detected Light flow pattern"); 29 | detected = true; 30 | } 31 | if (constantFlow1(patternScanner, methodNode)) { 32 | addContext("Detected constant flow"); 33 | detected = true; 34 | } 35 | 36 | if (detected && context.size() > 1) 37 | break; 38 | } 39 | } 40 | 41 | return detected; 42 | } 43 | 44 | private boolean lightFlow0(PatternScanner patternScanner, MethodNode methodNode) { 45 | patternScanner.setPattern(new int[] { 46 | GOTO, 47 | LABEL, 48 | POP, 49 | LABEL, 50 | GETSTATIC, 51 | P_NUMBER, 52 | LCMP, 53 | DUP, 54 | IFEQ, 55 | P_NUMBER, 56 | IF_ICMPNE 57 | }); 58 | return !patternScanner.scanMethod(methodNode).isEmpty(); 59 | } 60 | 61 | private boolean lightFlow1(PatternScanner patternScanner, MethodNode methodNode) { 62 | patternScanner.setPattern(new int[] { 63 | GETSTATIC, 64 | GOTO, 65 | LABEL, 66 | P_NUMBER, 67 | LDIV, 68 | LABEL, 69 | L2I, 70 | LOOKUPSWITCH, 71 | LABEL 72 | }); 73 | return !patternScanner.scanMethod(methodNode).isEmpty(); 74 | } 75 | 76 | private boolean constantFlow1(PatternScanner patternScanner, MethodNode methodNode) { 77 | patternScanner.setPattern(new int[] { 78 | P_NUMBER, 79 | P_NUMBER, 80 | LCMP, 81 | ISTORE, 82 | ILOAD, 83 | IFNE, 84 | LABEL, 85 | P_NUMBER, 86 | GOTO, 87 | LABEL 88 | }); 89 | return !patternScanner.scanMethod(methodNode).isEmpty(); 90 | } 91 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/detectors/bozar/BozarNumber.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.detectors.bozar; 2 | 3 | import org.objectweb.asm.tree.AbstractInsnNode; 4 | import org.objectweb.asm.tree.ClassNode; 5 | import org.objectweb.asm.tree.LdcInsnNode; 6 | import org.objectweb.asm.tree.MethodNode; 7 | import xyz.breversed.api.asm.detection.AbstractDetector; 8 | 9 | public class BozarNumber extends AbstractDetector { 10 | 11 | @Override 12 | protected boolean detect() { 13 | for (ClassNode classNode : getClasses()) { 14 | for (MethodNode methodNode : classNode.methods) { 15 | for (AbstractInsnNode insnNode : methodNode.instructions) { 16 | if (insnNode instanceof LdcInsnNode ldcInsn && ldcInsn.cst instanceof String value) { 17 | if (value.replace("\0", "").isEmpty()) { 18 | addContext("Detected num to string length pattern"); 19 | return true; 20 | } 21 | } 22 | } 23 | } 24 | } 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/detectors/bozar/BozarString.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.detectors.bozar; 2 | 3 | import xyz.breversed.api.asm.detection.AbstractDetector; 4 | 5 | public class BozarString extends AbstractDetector { 6 | 7 | @Override 8 | protected boolean detect() { 9 | /* Always come together */ 10 | return new BozarNumber().detect(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/detectors/crasher/ImageCrasher.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.detectors.crasher; 2 | 3 | import org.objectweb.asm.tree.ClassNode; 4 | import xyz.breversed.api.asm.detection.AbstractDetector; 5 | 6 | public class ImageCrasher extends AbstractDetector { 7 | 8 | @Override 9 | protected boolean detect() { 10 | for (ClassNode classNode : getClasses()) { 11 | if (classNode.name.toLowerCase().contains(" methodNode.desc.equals("(Ljava/lang/String;)Ljava/lang/String;")) 37 | .findFirst().orElse(null); 38 | if (decryptMethod == null) 39 | return -1; 40 | 41 | PatternScanner patternScanner = new PatternScanner(new int[] { 42 | P_NUMBER, 43 | IXOR 44 | }); 45 | for (InsnResult result : patternScanner.scanMethod(decryptMethod)) 46 | return ASMUtils.getIntValue(result.getFirst()); 47 | 48 | return -1; 49 | } 50 | private int getFileDecryptionKey(ClassNode classNode) { 51 | MethodNode decryptMethod = classNode.methods.stream() 52 | .filter(methodNode -> methodNode.desc.equals("([B)[B")) 53 | .findFirst().orElse(null); 54 | if (decryptMethod == null) 55 | return -1; 56 | 57 | PatternScanner patternScanner = new PatternScanner(new int[] { 58 | P_NUMBER, 59 | IXOR 60 | }); 61 | for (InsnResult result : patternScanner.scanMethod(decryptMethod)) 62 | return ASMUtils.getIntValue(result.getFirst()); 63 | 64 | return -1; 65 | } 66 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/detectors/scuti/ScutiFastString.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.detectors.scuti; 2 | 3 | import me.exeos.asmplus.pattern.PatternParts; 4 | import me.exeos.asmplus.pattern.PatternScanner; 5 | import me.exeos.asmplus.pattern.result.InsnResult; 6 | import me.exeos.asmplus.utils.ASMUtils; 7 | import org.objectweb.asm.tree.ClassNode; 8 | import org.objectweb.asm.tree.LdcInsnNode; 9 | import org.objectweb.asm.tree.MethodInsnNode; 10 | import org.objectweb.asm.tree.MethodNode; 11 | import xyz.breversed.api.asm.detection.AbstractDetector; 12 | 13 | public class ScutiFastString extends AbstractDetector implements PatternParts { 14 | 15 | @Override 16 | protected boolean detect() { 17 | boolean detected = false; 18 | 19 | PatternScanner patternScanner = new PatternScanner(new int[] { 20 | LDC, 21 | INVOKESTATIC 22 | }); 23 | 24 | for (ClassNode classNode : getClasses()) { 25 | for (MethodNode methodNode : classNode.methods) { 26 | for (InsnResult result : patternScanner.scanMethod(methodNode)) { 27 | if (!(((LdcInsnNode) result.getFirst()).cst instanceof String)) 28 | continue; 29 | 30 | MethodInsnNode decryptCall = (MethodInsnNode) result.getLast(); 31 | int key = getKeyByMethod(ASMUtils.getMethod(classNode, decryptCall.name, decryptCall.desc)); 32 | if (key != -1) { 33 | addContext("Found string decryption method & key"); 34 | detected = true; 35 | } 36 | } 37 | } 38 | } 39 | 40 | return detected; 41 | } 42 | 43 | private int getKeyByMethod(MethodNode methodNode) { 44 | PatternScanner patternScanner = new PatternScanner(new int[] { 45 | INVOKEVIRTUAL, 46 | P_NUMBER 47 | }); 48 | 49 | for (InsnResult result : patternScanner.scanMethod(methodNode)) { 50 | if (ASMUtils.isIntPush(result.getLast())) 51 | return ASMUtils.getIntValue(result.getLast()); 52 | } 53 | 54 | return -1; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/detectors/scuti/ScutiFlow.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.detectors.scuti; 2 | 3 | import me.exeos.asmplus.pattern.PatternParts; 4 | import me.exeos.asmplus.pattern.PatternScanner; 5 | import org.objectweb.asm.tree.ClassNode; 6 | import org.objectweb.asm.tree.MethodNode; 7 | import xyz.breversed.api.asm.detection.AbstractDetector; 8 | 9 | public class ScutiFlow extends AbstractDetector implements PatternParts { 10 | 11 | @Override 12 | protected boolean detect() { 13 | boolean detected = false; 14 | 15 | PatternScanner patternScanner = new PatternScanner(); 16 | 17 | for (ClassNode classNode : getClasses()) { 18 | if (!classNode.name.startsWith(" ")) { 19 | for (MethodNode methodNode : classNode.methods) { 20 | if (staticInitializerPattern(patternScanner, methodNode)) { 21 | addContext("Scuti static initializer"); 22 | detected = true; 23 | } 24 | if (flowPattern(patternScanner, methodNode)) { 25 | addContext("Main flow pattern"); 26 | detected = true; 27 | } 28 | if (secondFlowPattern(patternScanner, methodNode)) { 29 | addContext("Second flow pattern"); 30 | detected = true; 31 | } 32 | if (thirdFlowPattern(patternScanner, methodNode)) { 33 | addContext("Third flow pattern"); 34 | detected = true; 35 | } 36 | } 37 | continue; 38 | } 39 | addContext("Space class name"); 40 | detected = true; 41 | } 42 | 43 | return detected; 44 | } 45 | 46 | private boolean staticInitializerPattern(PatternScanner patternScanner, MethodNode methodNode) { 47 | patternScanner.setPattern(new int[] { 48 | P_NUMBER, 49 | P_NUMBER, 50 | IXOR, 51 | PUTSTATIC, 52 | P_NUMBER, 53 | P_NUMBER, 54 | IXOR, 55 | PUTSTATIC 56 | }); 57 | return !patternScanner.scanMethod(methodNode).isEmpty(); 58 | } 59 | 60 | private boolean flowPattern(PatternScanner patternScanner, MethodNode methodNode) { 61 | patternScanner.setPattern(new int[] { 62 | GETSTATIC, 63 | GETSTATIC, 64 | JUMP_INSN, 65 | ACONST_NULL, 66 | P_ANY, 67 | ATHROW, 68 | P_ANY, 69 | ATHROW, 70 | P_ANY 71 | }); 72 | return !patternScanner.scanMethod(methodNode).isEmpty(); 73 | } 74 | 75 | private boolean secondFlowPattern(PatternScanner patternScanner, MethodNode methodNode) { 76 | patternScanner.setPattern(new int[] { 77 | GOTO, 78 | P_ANY, 79 | GOTO, 80 | P_ANY, 81 | GETSTATIC, 82 | GETSTATIC, 83 | JUMP_INSN, 84 | ACONST_NULL, 85 | ATHROW 86 | }); 87 | return !patternScanner.scanMethod(methodNode).isEmpty(); 88 | } 89 | 90 | private boolean thirdFlowPattern(PatternScanner patternScanner, MethodNode methodNode) { 91 | patternScanner.setPattern(new int[] { 92 | ATHROW, 93 | P_ANY, 94 | JUMP_INSN, 95 | P_ANY, 96 | GETSTATIC, 97 | GETSTATIC, 98 | JUMP_INSN, 99 | ACONST_NULL, 100 | ATHROW 101 | }); 102 | return !patternScanner.scanMethod(methodNode).isEmpty(); 103 | } 104 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/detectors/scuti/ScutiInvokeDynamic.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.detectors.scuti; 2 | 3 | import org.objectweb.asm.tree.ClassNode; 4 | import org.objectweb.asm.tree.MethodNode; 5 | import xyz.breversed.api.asm.detection.AbstractDetector; 6 | 7 | public class ScutiInvokeDynamic extends AbstractDetector { 8 | 9 | @Override 10 | protected boolean detect() { 11 | boolean detected = false; 12 | 13 | for (ClassNode classNode : getClasses()) { 14 | MethodNode stringDecryptMethod = classNode.methods.stream().filter(methodNode -> methodNode.name.startsWith(" ") && methodNode.access == 4170 && 15 | methodNode.desc.equals("(Ljava/lang/String;)Ljava/lang/String;")).findFirst().orElse(null); 16 | MethodNode callDecryptMethod = classNode.methods.stream().filter(methodNode -> methodNode.access == 4169 && 17 | methodNode.desc.equals("(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;)Ljava/lang/invoke/CallSite;")).findFirst().orElse(null); 18 | 19 | if (stringDecryptMethod != null) { 20 | addContext("String decryptor method found for InvokeDynamic"); 21 | detected = true; 22 | } 23 | if (callDecryptMethod != null) { 24 | addContext("Call decryptor method found for InvokeDynamic"); 25 | detected = true; 26 | } 27 | } 28 | 29 | return detected; 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/detectors/scuti/ScutiNumber.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.detectors.scuti; 2 | 3 | import me.exeos.asmplus.pattern.PatternParts; 4 | import me.exeos.asmplus.pattern.PatternScanner; 5 | import org.objectweb.asm.tree.ClassNode; 6 | import org.objectweb.asm.tree.MethodNode; 7 | import xyz.breversed.api.asm.detection.AbstractDetector; 8 | 9 | public class ScutiNumber extends AbstractDetector implements PatternParts { 10 | 11 | @Override 12 | protected boolean detect() { 13 | boolean detected = false; 14 | 15 | PatternScanner numberPattern = new PatternScanner(new int[] { 16 | P_NUMBER, 17 | P_NUMBER, 18 | IXOR, 19 | P_NUMBER, 20 | IXOR, 21 | P_NUMBER, 22 | IXOR 23 | }); 24 | 25 | for (ClassNode classNode : getClasses()) 26 | for (MethodNode methodNode : classNode.methods) 27 | if (!numberPattern.scanMethod(methodNode).isEmpty()) { 28 | addContext("Number pattern"); 29 | detected = true; 30 | } 31 | 32 | return detected; 33 | } 34 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/detectors/scuti/ScutiStrongString.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.detectors.scuti; 2 | 3 | import me.exeos.asmplus.pattern.PatternParts; 4 | import me.exeos.asmplus.pattern.PatternScanner; 5 | import me.exeos.asmplus.pattern.result.InsnResult; 6 | import me.exeos.asmplus.utils.ASMUtils; 7 | import org.objectweb.asm.tree.*; 8 | import xyz.breversed.api.asm.detection.AbstractDetector; 9 | 10 | public class ScutiStrongString extends AbstractDetector implements PatternParts { 11 | 12 | @Override 13 | protected boolean detect() { 14 | PatternScanner patternScanner = new PatternScanner(new int[] { 15 | LDC, 16 | P_NUMBER 17 | }); 18 | 19 | for (ClassNode classNode : getClasses()) { 20 | for (MethodNode methodNode : classNode.methods) { 21 | int possibility = 0; 22 | for (InsnResult result : patternScanner.scanMethod(methodNode)) { 23 | if (!(((LdcInsnNode) result.getFirst()).cst instanceof String)) 24 | continue; 25 | if (!ASMUtils.isIntPush(result.getLast())) 26 | continue; 27 | int key = ASMUtils.getIntValue(result.getLast()); 28 | 29 | AbstractInsnNode current = result.getLast(); 30 | MethodInsnNode decryptCall = null; 31 | 32 | /* we don't know how many NEG and SWAP instructions are in between the key and the decrypt call because its randomised, 33 | so we have to iterate through the instructions until we find the decrypt call 34 | TODO: find a cleaner way to do this 35 | */ 36 | while (decryptCall == null) { 37 | current = current.getNext(); 38 | if (current == null) 39 | break; 40 | possibility++; // there are probably better ways to do this, but it works for now 41 | 42 | if (current instanceof MethodInsnNode && 43 | ((MethodInsnNode) current).owner.equals(classNode.name) && 44 | ((MethodInsnNode) current).desc.equals("(Ljava/lang/String;I)Ljava/lang/String;")) { 45 | decryptCall = (MethodInsnNode) current; 46 | } 47 | } 48 | 49 | if (decryptCall != null && possibility > 0 && decryptCall.name != null && key != 0) { 50 | addContext("Found strong encrypted string, key and decryption method"); 51 | return true; 52 | } 53 | } 54 | } 55 | } 56 | return false; 57 | } 58 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/detectors/universal/Renamer.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.detectors.universal; 2 | 3 | import org.objectweb.asm.tree.ClassNode; 4 | import xyz.breversed.api.asm.detection.AbstractDetector; 5 | import xyz.breversed.api.utils.CharUtil; 6 | 7 | public class Renamer extends AbstractDetector { 8 | 9 | @Override 10 | protected boolean detect() { 11 | int bigClassNames = 0; 12 | int unAlphabeticClasses = 0; 13 | 14 | for (ClassNode classNode : getClasses()) { 15 | if (classNode.name.length() >= 20) 16 | bigClassNames++; 17 | 18 | String[] split = classNode.name.split("/"); 19 | 20 | if (CharUtil.containsUnAlphabetic(split[split.length - 1].replace("$", "").replace("_", "").replace("-", ""))) 21 | unAlphabeticClasses++; 22 | } 23 | 24 | if (bigClassNames >= getClasses().size() / 3) 25 | addContext("Big class names"); 26 | 27 | if (unAlphabeticClasses >= getClasses().size() / 3) 28 | addContext("Unalphabetical class names"); 29 | 30 | return bigClassNames + unAlphabeticClasses >= getClasses().size() / 2; 31 | } 32 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/transformers/bozar/BozarConstantFlow.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.transformers.bozar; 2 | 3 | import me.exeos.asmplus.pattern.PatternParts; 4 | import me.exeos.asmplus.pattern.PatternScanner; 5 | import me.exeos.asmplus.pattern.result.InsnResult; 6 | import me.exeos.asmplus.utils.ASMUtils; 7 | import org.objectweb.asm.tree.AbstractInsnNode; 8 | import org.objectweb.asm.tree.ClassNode; 9 | import org.objectweb.asm.tree.MethodNode; 10 | import xyz.breversed.api.asm.transformer.Transformer; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | public class BozarConstantFlow extends Transformer implements PatternParts { 16 | 17 | @Override 18 | protected void transform() { 19 | PatternScanner patternScanner = new PatternScanner(new int[] { 20 | P_NUMBER, 21 | P_NUMBER, 22 | LCMP, 23 | ISTORE, 24 | ILOAD, 25 | IFNE, 26 | LABEL, 27 | P_NUMBER, 28 | GOTO, 29 | LABEL 30 | }); 31 | 32 | for (ClassNode classNode : getClasses()) { 33 | for (MethodNode methodNode : classNode.methods) { 34 | for (InsnResult result : patternScanner.scanMethod(methodNode)) { 35 | List toRemove = new ArrayList<>(); 36 | for (int i = 0; i < 10; i++) { 37 | toRemove.add(ASMUtils.getNext(result.getFirst(), i)); 38 | } 39 | for (int i = 2; i < 11; i++) { 40 | toRemove.add(ASMUtils.getNext(result.getLast(), i)); 41 | } 42 | ASMUtils.removeInstructions(toRemove, methodNode); 43 | } 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/transformers/bozar/BozarCrasher.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.transformers.bozar; 2 | 3 | import me.exeos.asmplus.JarLoader; 4 | import org.objectweb.asm.tree.ClassNode; 5 | import org.objectweb.asm.tree.MethodNode; 6 | import xyz.breversed.BReversed; 7 | import xyz.breversed.api.asm.transformer.Transformer; 8 | 9 | public class BozarCrasher extends Transformer { 10 | @Override 11 | protected void transform() { 12 | for (ClassNode classNode : getClasses()) { 13 | if (classNode.methods.size() == 1) { 14 | MethodNode methodNode = classNode.methods.get(0); 15 | if (methodNode.name.equals("\u0001") && methodNode.desc.equals("(\u0001/)L\u0001/;") && methodNode.access <= 100) 16 | removeClass(classNode); 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/transformers/bozar/BozarHeavyFlow.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.transformers.bozar; 2 | 3 | import me.exeos.asmplus.pattern.PatternParts; 4 | import me.exeos.asmplus.pattern.PatternScanner; 5 | import me.exeos.asmplus.pattern.result.InsnResult; 6 | import me.exeos.asmplus.utils.ASMUtils; 7 | import org.objectweb.asm.tree.*; 8 | import xyz.breversed.api.asm.transformer.Transformer; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | public class BozarHeavyFlow extends Transformer implements PatternParts { 14 | 15 | @Override 16 | protected void transform() { 17 | PatternScanner patternScanner = new PatternScanner(); 18 | 19 | for (ClassNode classNode : getClasses()) { 20 | /* Bozar always adds this field */ 21 | FieldNode flowField = ASMUtils.getField(classNode.name, String.valueOf((char)5097), "J"); 22 | if (flowField == null) 23 | continue; 24 | 25 | classNode.fields.remove(flowField); 26 | for (MethodNode methodNode : classNode.methods) { 27 | removeFirstLayer(methodNode, firstLayer0(patternScanner, methodNode)); 28 | removeFirstLayer(methodNode, firstLayer1(patternScanner, methodNode)); 29 | removeSecondLayer(patternScanner, methodNode); 30 | 31 | /* removing bozar pseudo code */ 32 | } 33 | } 34 | } 35 | 36 | private void removeFirstLayer(MethodNode methodNode, List results) { 37 | for (InsnResult result : results) { 38 | if (!((FieldInsnNode) result.getFirst()).name.equals(String.valueOf((char)5097))) { 39 | continue; 40 | } 41 | 42 | List toRemove = new ArrayList<>(); 43 | AbstractInsnNode current = result.getLast(); 44 | LabelNode dltLabel = ((LookupSwitchInsnNode) current).dflt; 45 | 46 | /*if (result.getFirst().getPrevious().getType() == AbstractInsnNode.LABEL) 47 | toRemove.add(result.getFirst().getPrevious());*/ 48 | 49 | while ((current = current.getNext()) != dltLabel) { 50 | toRemove.add(current); 51 | } 52 | toRemove.add(current); /* dflt label */ 53 | while ((current = current.getNext()).getType() != AbstractInsnNode.LABEL) { 54 | toRemove.add(current); 55 | } 56 | current = current.getNext(); /* insn after end label */ 57 | int amount = switch (current.getOpcode()) { 58 | case LXOR -> 10; 59 | case LCMP -> ASMUtils.getNext(current, 6).getOpcode() == IF_ICMPNE ? 6 : 3; 60 | case LAND -> 3; 61 | default -> 0; 62 | }; 63 | /* pattern mismatch */ 64 | if (amount == 0) { 65 | // System.out.println("Pattern mismatch"); 66 | continue; 67 | } 68 | 69 | for (int i = 0; i <= amount; i++) { 70 | toRemove.add(ASMUtils.getNext(current, i)); 71 | } 72 | /* we need to remove insns after real*/ 73 | if (current.getOpcode() == LAND) { 74 | current = ASMUtils.getNext(current, 5); /* first after insn */ 75 | for (int i = 0; i <= 6; i++) { 76 | toRemove.add(ASMUtils.getNext(current, i)); 77 | } 78 | } 79 | ASMUtils.removeInstructions(result.pattern, methodNode); 80 | ASMUtils.removeInstructions(toRemove, methodNode); 81 | } 82 | } 83 | 84 | private void removeSecondLayer(PatternScanner patternScanner, MethodNode methodNode) { 85 | for (InsnResult result : secondLayer0(patternScanner, methodNode)) { 86 | List toRemove = new ArrayList<>(); 87 | 88 | for (int i = 2; i <= 8; i++) { 89 | toRemove.add(ASMUtils.getNext(result.getLast(), i)); 90 | } 91 | 92 | ASMUtils.removeInstructions(result.pattern, methodNode); 93 | ASMUtils.removeInstructions(toRemove, methodNode); 94 | } 95 | 96 | for (InsnResult result : secondLayer1(patternScanner, methodNode)) { 97 | if (!((FieldInsnNode) result.getFirst()).name.equals(String.valueOf((char)5097))) 98 | continue; 99 | 100 | List toRemove = new ArrayList<>(); 101 | AbstractInsnNode current = result.getLast(); 102 | 103 | while ((current = current.getNext()) != ((LookupSwitchInsnNode) result.getLast()).dflt) { 104 | toRemove.add(current); 105 | } 106 | // toRemove.add(current) /* dflt label */; 107 | for (int i = 0; i <= 2; i++) { 108 | toRemove.add(ASMUtils.getNext(current, i)); 109 | } 110 | 111 | ASMUtils.removeInstructions(result.pattern, methodNode); 112 | ASMUtils.removeInstructions(toRemove, methodNode); 113 | } 114 | } 115 | 116 | private List firstLayer0(PatternScanner patternScanner, MethodNode methodNode) { 117 | patternScanner.setPattern(new int[] { 118 | GETSTATIC, 119 | P_NUMBER, 120 | GOTO, 121 | LABEL, 122 | P_NUMBER, 123 | P_NUMBER, 124 | LABEL, 125 | DUP2, 126 | L2I, 127 | LOOKUPSWITCH 128 | }); 129 | return patternScanner.scanMethod(methodNode); 130 | } 131 | 132 | private List firstLayer1(PatternScanner patternScanner, MethodNode methodNode) { 133 | patternScanner.setPattern(new int[] { 134 | GETSTATIC, 135 | LABEL, 136 | P_NUMBER, 137 | GOTO, 138 | LABEL, 139 | P_NUMBER, 140 | P_NUMBER, 141 | LABEL, 142 | DUP2, 143 | L2I, 144 | LOOKUPSWITCH 145 | }); 146 | return patternScanner.scanMethod(methodNode); 147 | } 148 | 149 | 150 | private List secondLayer0(PatternScanner patternScanner, MethodNode methodNode) { 151 | patternScanner.setPattern(new int[] { 152 | P_NUMBER, 153 | P_NUMBER, 154 | LABEL, 155 | POP2, 156 | GETSTATIC, 157 | P_NUMBER, 158 | LCMP, 159 | ICONST_0, 160 | SWAP, 161 | DUP, 162 | IFEQ, 163 | IFEQ, 164 | POP 165 | }); 166 | return patternScanner.scanMethod(methodNode); 167 | } 168 | 169 | private List secondLayer1(PatternScanner patternScanner, MethodNode methodNode) { 170 | patternScanner.setPattern(new int[] { 171 | GETSTATIC, 172 | L2I, 173 | LOOKUPSWITCH 174 | }); 175 | return patternScanner.scanMethod(methodNode); 176 | } 177 | 178 | private List pseudoCode(PatternScanner patternScanner, MethodNode methodNode) { 179 | patternScanner.setPattern(new int[] { 180 | ICONST_1, 181 | GOTO, 182 | LABEL, 183 | ICONST_5, 184 | LABEL, 185 | ICONST_M1, 186 | IF_ICMPLE 187 | }); 188 | return patternScanner.scanMethod(methodNode); 189 | } 190 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/transformers/bozar/BozarLightFlow.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.transformers.bozar; 2 | 3 | import me.exeos.asmplus.pattern.PatternParts; 4 | import me.exeos.asmplus.pattern.PatternScanner; 5 | import me.exeos.asmplus.pattern.result.InsnResult; 6 | import me.exeos.asmplus.utils.ASMUtils; 7 | import org.objectweb.asm.tree.*; 8 | import xyz.breversed.api.asm.transformer.Transformer; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | public class BozarLightFlow extends Transformer implements PatternParts { 14 | 15 | @Override 16 | protected void transform() { 17 | PatternScanner patternScanner = new PatternScanner(); 18 | 19 | for (ClassNode classNode : getClasses()) { 20 | /* Bozar always adds this field */ 21 | FieldNode flowField = ASMUtils.getField(classNode.name, String.valueOf((char)5096), "J"); 22 | if (flowField == null) 23 | continue; 24 | 25 | classNode.fields.remove(flowField); 26 | for (MethodNode methodNode : classNode.methods) { 27 | for (InsnResult result : before0(patternScanner, methodNode)) { 28 | /* This is the first insn of the pattern that follows the real insn */ 29 | AbstractInsnNode firstAfter = ASMUtils.getNext(result.getLast(), 2); 30 | List toRemove = new ArrayList<>(); 31 | 32 | for (int i = 0; i < 5; i++) { 33 | toRemove.add(ASMUtils.getNext(firstAfter, i)); 34 | } 35 | ASMUtils.removeInstructions(result.pattern, methodNode); 36 | ASMUtils.removeInstructions(toRemove, methodNode); 37 | } 38 | 39 | for (InsnResult result : before1(patternScanner, methodNode)) { 40 | /* Now that the pattern is found, it will remove the random switch. The correct code is always in the dflt label */ 41 | LookupSwitchInsnNode lookupSwitch = (LookupSwitchInsnNode) result.pattern[result.pattern.length - 2]; 42 | /* This is the beginning of the lookup body */ 43 | AbstractInsnNode current = result.getLast(); 44 | List toRemove = new ArrayList<>(); 45 | 46 | while ((current = ASMUtils.getNext(current, 1)) != lookupSwitch.dflt) { 47 | toRemove.add(current); 48 | } 49 | ASMUtils.removeInstructions(result.pattern, methodNode); 50 | ASMUtils.removeInstructions(toRemove, methodNode); 51 | } 52 | } 53 | } 54 | } 55 | 56 | private List before0(PatternScanner patternScanner, MethodNode methodNode) { 57 | patternScanner.setPattern(new int[] { 58 | GOTO, 59 | LABEL, 60 | POP, 61 | LABEL, 62 | GETSTATIC, 63 | P_NUMBER, 64 | LCMP, 65 | DUP, 66 | IFEQ, 67 | P_NUMBER, 68 | IF_ICMPNE 69 | }); 70 | return patternScanner.scanMethod(methodNode); 71 | } 72 | 73 | private List before1(PatternScanner patternScanner, MethodNode methodNode) { 74 | patternScanner.setPattern(new int[] { 75 | GETSTATIC, 76 | GOTO, 77 | LABEL, 78 | P_NUMBER, 79 | LDIV, 80 | LABEL, 81 | L2I, 82 | LOOKUPSWITCH, 83 | LABEL 84 | }); 85 | return patternScanner.scanMethod(methodNode); 86 | } 87 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/transformers/bozar/BozarNumber.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.transformers.bozar; 2 | 3 | import me.exeos.asmplus.utils.ASMUtils; 4 | import org.objectweb.asm.tree.AbstractInsnNode; 5 | import org.objectweb.asm.tree.LdcInsnNode; 6 | import xyz.breversed.api.asm.transformer.Transformer; 7 | 8 | public class BozarNumber extends Transformer { 9 | 10 | @Override 11 | protected void transform() { 12 | getClasses().forEach(classNode -> classNode.methods.forEach(methodNode -> { 13 | for (AbstractInsnNode insnNode : methodNode.instructions.toArray()) { 14 | if (!ASMUtils.isPresent(insnNode, methodNode)) 15 | continue; 16 | /* removing "\0".length() */ 17 | if (insnNode instanceof LdcInsnNode ldcInsn && ldcInsn.cst instanceof String value) { 18 | if (!value.replace("\0", "").isEmpty()) 19 | continue; 20 | 21 | methodNode.instructions.remove(insnNode.getNext()); 22 | methodNode.instructions.insert(insnNode, ASMUtils.getIntPush(value.length())); 23 | methodNode.instructions.remove(insnNode); 24 | } 25 | } 26 | 27 | /* XOR & Shift to single ins */ 28 | for (AbstractInsnNode insnNode : methodNode.instructions.toArray()) { 29 | if (!ASMUtils.isPresent(insnNode, methodNode)) 30 | continue; 31 | if (ASMUtils.isNumberPush(insnNode) && ASMUtils.isNumberPush(insnNode.getNext())) { 32 | /* XOR */ 33 | if (ASMUtils.getNext(insnNode, 2).getOpcode() == IXOR || ASMUtils.getNext(insnNode, 2).getOpcode() == LXOR) { 34 | boolean isIXOR = ASMUtils.getNext(insnNode, 2).getOpcode() == IXOR; 35 | Object realValuePushInsn = (isIXOR ? ASMUtils.getIntPush(ASMUtils.getIntValue(insnNode) ^ ASMUtils.getIntValue(insnNode.getNext())) : 36 | ASMUtils.getLongPush(ASMUtils.getLongValue(insnNode) ^ ASMUtils.getLongValue(insnNode.getNext()))); 37 | methodNode.instructions.remove(insnNode.getNext()); 38 | methodNode.instructions.remove(insnNode.getNext()); 39 | if (isIXOR) 40 | methodNode.instructions.insert(insnNode, (AbstractInsnNode) realValuePushInsn); 41 | else 42 | methodNode.instructions.insert(insnNode, (AbstractInsnNode) realValuePushInsn); 43 | methodNode.instructions.remove(insnNode); 44 | } else /* Shift */ { 45 | if (ASMUtils.getNext(insnNode, 2).getOpcode() == IUSHR) { 46 | int result = ASMUtils.getIntValue(insnNode) >>> ASMUtils.getIntValue(insnNode.getNext()); 47 | 48 | methodNode.instructions.remove(insnNode.getNext()); 49 | methodNode.instructions.remove(insnNode.getNext()); 50 | methodNode.instructions.insert(insnNode, ASMUtils.getIntPush(result)); 51 | methodNode.instructions.remove(insnNode); 52 | } else if (ASMUtils.getNext(insnNode, 2).getOpcode() == LUSHR) { 53 | long result = ASMUtils.getLongValue(insnNode) >>> ASMUtils.getIntValue(insnNode.getNext()); 54 | 55 | methodNode.instructions.remove(insnNode.getNext()); 56 | methodNode.instructions.remove(insnNode.getNext()); 57 | methodNode.instructions.insert(insnNode, ASMUtils.getLongPush(result)); 58 | methodNode.instructions.remove(insnNode); 59 | } 60 | } 61 | } 62 | } 63 | })); 64 | } 65 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/transformers/bozar/BozarString.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.transformers.bozar; 2 | 3 | import me.exeos.asmplus.pattern.PatternParts; 4 | import me.exeos.asmplus.pattern.PatternScanner; 5 | import me.exeos.asmplus.pattern.result.InsnResult; 6 | import me.exeos.asmplus.utils.ASMUtils; 7 | import org.objectweb.asm.tree.*; 8 | import xyz.breversed.api.asm.transformer.Transformer; 9 | 10 | import java.util.ArrayList; 11 | import java.util.HashMap; 12 | import java.util.List; 13 | 14 | public class BozarString extends Transformer implements PatternParts { 15 | 16 | @Override 17 | protected void transform() { 18 | PatternScanner patternScanner = new PatternScanner(new int[] { 19 | P_NUMBER, 20 | NEWARRAY, 21 | ASTORE, 22 | 23 | P_SKIPTO, 24 | 25 | NEW, 26 | DUP, 27 | ALOAD, 28 | INVOKESPECIAL 29 | }); 30 | 31 | for (ClassNode classNode : getClasses()) { 32 | for (MethodNode methodNode : classNode.methods) { 33 | for (InsnResult result : patternScanner.scanMethod(methodNode)) { 34 | List toRemove = new ArrayList<>(); 35 | 36 | /* key = index in array, value = byte value*/ 37 | HashMap strMap = new HashMap<>(); 38 | byte[] strBytes; 39 | 40 | /* first time index 0 is assigned a random number*/ 41 | boolean overFake = false; 42 | 43 | 44 | for (int i = 3; i < result.pattern.length - 4; i++) { 45 | AbstractInsnNode current = result.pattern[i]; 46 | 47 | toRemove.add(current); 48 | if (current.getOpcode() == BASTORE) { 49 | if (overFake) { 50 | try { 51 | int at = ASMUtils.getIntValue(ASMUtils.getPrev(current, 2)); 52 | int value = ASMUtils.getIntValue(current.getPrevious()); 53 | 54 | strMap.put(at, (byte) value); 55 | } catch (ClassCastException e) { 56 | break; 57 | } 58 | } 59 | overFake = true; 60 | } 61 | } 62 | 63 | /* Pattern isn't string obf */ 64 | if (!overFake) 65 | continue; 66 | 67 | /* Remove current and 3 prev before */ 68 | for (int i = 0; i < 4; i++) { 69 | toRemove.add(ASMUtils.getPrev(result.getLast(), i)); 70 | } 71 | 72 | /* initializing the byte array with correct size */ 73 | strBytes = new byte[strMap.size()]; 74 | /* Assigning each offset the correct bytes */ 75 | strMap.forEach((index, value) -> strBytes[index] = value); 76 | 77 | methodNode.instructions.insert(result.getFirst(), new LdcInsnNode(new String(strBytes))); 78 | ASMUtils.removeInstructions(result.pattern, methodNode); 79 | ASMUtils.removeInstructions(toRemove, methodNode); 80 | } 81 | } 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/transformers/crasher/IMGCrasherRemover.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.transformers.crasher; 2 | 3 | import org.objectweb.asm.tree.ClassNode; 4 | import xyz.breversed.api.asm.transformer.Transformer; 5 | import xyz.breversed.api.asm.utils.RenameUtil; 6 | 7 | public class IMGCrasherRemover extends Transformer { 8 | 9 | @Override 10 | protected void transform() { 11 | for (ClassNode classNode : getClasses()) { 12 | if (classNode.name.toLowerCase().contains("") || !methodNode.desc.equals("()V")) { 38 | continue; 39 | } 40 | 41 | List tempFilePatter = cTempFilePatter(methodNode); 42 | List loadLibPatter = loadLibPatter(methodNode); 43 | 44 | if (tempFilePatter.size() != 1 || loadLibPatter.size() != 1) { 45 | System.out.println("Patterns found > or < than 1. TFP: " + tempFilePatter.size() + " LFP:" + loadLibPatter.size()); 46 | break; 47 | } 48 | 49 | InsnResult tempFileResult = tempFilePatter.get(0); 50 | InsnResult loadLibResult = loadLibPatter.get(0); 51 | 52 | /* insert new instructions */ 53 | methodNode.instructions.insertBefore( 54 | tempFileResult.getFirst(), 55 | ASMUtils.convertToIList( 56 | patchedFileCreation(((VarInsnNode) tempFileResult.pattern[4]).var /* ALOAD X */) 57 | ) 58 | ); 59 | 60 | /* remove old instructions */ 61 | ASMUtils.removeInstructions(tempFileResult.pattern, methodNode); 62 | for (int i = 0; i < loadLibResult.pattern.length - 1; i++) { 63 | methodNode.instructions.remove(loadLibResult.pattern[i]); 64 | } 65 | 66 | try { 67 | invoke(classNode); 68 | } catch (Exception e) { 69 | System.out.println("Failed to invoke patched JNIC class."); 70 | break; 71 | } 72 | } 73 | foundClassCount++; 74 | } 75 | 76 | /* give information of how the transformation went */ 77 | if (foundClassCount != 1) { 78 | System.out.println("WARNING: found > or < than 1 JNICLoader class. Amount found: " + foundClassCount); 79 | } 80 | } 81 | 82 | private void invoke(ClassNode classNode) throws Exception { 83 | Pair encBin = getEncBin(); 84 | if (encBin == null) { 85 | System.out.println("Failed to invoke, couldn't find enc bin"); 86 | return; 87 | } 88 | /* init */ 89 | ClassDefiner classDefiner = new ClassDefiner(null); 90 | classDefiner.resources.put(encBin.key, encBin.value); 91 | 92 | /* add class and resource */ 93 | String[] split = classNode.name.split("/"); 94 | String preFix = classNode.name.substring(0, classNode.name.length() - split[split.length - 1].length()); 95 | for (ClassNode node : getClasses()) { 96 | if (!node.name.startsWith(preFix)) { 97 | continue; 98 | } 99 | 100 | ClassWriter classWriter = new ClassWriter(0); 101 | node.accept(classWriter); 102 | 103 | classDefiner.classes.put(node.name.replace("/", "."), classWriter.toByteArray()); 104 | } 105 | 106 | Class.forName(classNode.name.replace("/", "."), true, classDefiner); 107 | } 108 | 109 | private Pair getEncBin() { 110 | for (String name : getResources().keySet()) { 111 | if (name.startsWith("dev/jnic/") && name.endsWith(".dat")) { 112 | return new Pair<>(name, getResources().get(name)); 113 | } 114 | } 115 | 116 | return null; 117 | } 118 | 119 | private List cTempFilePatter(MethodNode methodNode) { 120 | return new PatternScanner(new int[] { 121 | LDC, 122 | ACONST_NULL, 123 | INVOKESTATIC, 124 | ASTORE, 125 | ALOAD, 126 | INVOKEVIRTUAL 127 | }).scanMethod(methodNode); 128 | } 129 | 130 | private List patchedFileCreation(int varIndex) { 131 | ArrayList insns = new ArrayList<>(); 132 | 133 | /* File file = new File("lib") */ 134 | insns.add(new TypeInsnNode(NEW, "java/io/File")); 135 | insns.add(new InsnNode(DUP)); 136 | insns.add(new LdcInsnNode("io/decrypted.dll")); 137 | insns.add(new MethodInsnNode(INVOKESPECIAL, "java/io/File", "", "(Ljava/lang/String;)V")); 138 | insns.add(new VarInsnNode(ASTORE, varIndex)); 139 | 140 | /* file.creatNewFile(); */ 141 | insns.add(new VarInsnNode(ALOAD, varIndex)); 142 | insns.add(new MethodInsnNode(INVOKEVIRTUAL, "java/io/File", "createNewFile", "()Z")); 143 | insns.add(new InsnNode(POP)); 144 | 145 | return insns; 146 | } 147 | 148 | private List loadLibPatter(MethodNode methodNode) { 149 | return new PatternScanner(new int[] { 150 | ALOAD, 151 | INVOKEVIRTUAL, 152 | INVOKESTATIC, 153 | RETURN 154 | }).scanMethod(methodNode); 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/transformers/scuti/ScutiClassEncrypt.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.transformers.scuti; 2 | 3 | import me.exeos.asmplus.pattern.PatternParts; 4 | import me.exeos.asmplus.pattern.PatternScanner; 5 | import me.exeos.asmplus.pattern.result.InsnResult; 6 | import me.exeos.asmplus.utils.ASMUtils; 7 | import org.objectweb.asm.tree.ClassNode; 8 | import org.objectweb.asm.tree.MethodNode; 9 | import xyz.breversed.api.asm.transformer.Transformer; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | // TODO: Improve code quality 15 | public class ScutiClassEncrypt extends Transformer implements PatternParts { 16 | 17 | @Override 18 | protected void transform() { 19 | int[] keys = new int[] { -1, -1 }; // first value is the string key, the second is the file key 20 | for (ClassNode classNode : getClasses()) { 21 | keys[0] = getStringDecryptionKey(classNode); 22 | keys[1] = getFileDecryptionKey(classNode); 23 | if (keys[0] != -1) 24 | break; 25 | } 26 | if (keys[0] == -1 && keys[1] == -1) // if we didn't find the keys, return 27 | return; 28 | 29 | List toRemove = new ArrayList<>(); 30 | for (String key : new ArrayList<>(getResources().keySet())) { // iterate through all the files, decrypt them, add the decrypted file 31 | String decryptedName = decryptString(key, keys[0]); 32 | if (decryptedName.contains(".")) continue; 33 | 34 | byte[] decryptedFile = decryptFile(getResources().get(key), keys[1]); 35 | getResources().put(decryptedName + ".class", decryptedFile); 36 | toRemove.add(key); 37 | } 38 | for (String key : toRemove) // remove the encrypted files 39 | getResources().remove(key); 40 | } 41 | 42 | private String decryptString(String string, int key) { 43 | StringBuilder decrypted = new StringBuilder(); 44 | for (int i = 0; i < string.length(); i++) { 45 | decrypted.append((char)(string.charAt(i) ^ key)); 46 | } 47 | return decrypted.toString(); 48 | } 49 | private byte[] decryptFile(byte[] byArray, int key) { 50 | byte[] byArray2 = new byte[byArray.length]; 51 | int n = 0; 52 | while (n < byArray.length) { 53 | byArray2[n] = (byte)(byArray[n] ^ key); 54 | ++n; 55 | } 56 | return byArray2; 57 | } 58 | 59 | private int getStringDecryptionKey(ClassNode classNode) { 60 | MethodNode decryptMethod = classNode.methods.stream() 61 | .filter(methodNode -> methodNode.desc.equals("(Ljava/lang/String;)Ljava/lang/String;")) 62 | .findFirst().orElse(null); 63 | if (decryptMethod == null) 64 | return -1; 65 | 66 | PatternScanner patternScanner = new PatternScanner(new int[] { 67 | P_NUMBER, 68 | IXOR 69 | }); 70 | for (InsnResult result : patternScanner.scanMethod(decryptMethod)) 71 | return ASMUtils.getIntValue(result.getFirst()); 72 | 73 | return -1; 74 | } 75 | private int getFileDecryptionKey(ClassNode classNode) { 76 | MethodNode decryptMethod = classNode.methods.stream() 77 | .filter(methodNode -> methodNode.desc.equals("([B)[B")) 78 | .findFirst().orElse(null); 79 | if (decryptMethod == null) 80 | return -1; 81 | 82 | PatternScanner patternScanner = new PatternScanner(new int[] { 83 | P_NUMBER, 84 | IXOR 85 | }); 86 | for (InsnResult result : patternScanner.scanMethod(decryptMethod)) 87 | return ASMUtils.getIntValue(result.getFirst()); 88 | 89 | return -1; 90 | } 91 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/transformers/scuti/ScutiFastString.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.transformers.scuti; 2 | 3 | import me.exeos.asmplus.pattern.PatternParts; 4 | import me.exeos.asmplus.pattern.PatternScanner; 5 | import me.exeos.asmplus.pattern.result.InsnResult; 6 | import me.exeos.asmplus.utils.ASMUtils; 7 | import org.objectweb.asm.tree.*; 8 | import xyz.breversed.api.asm.transformer.Transformer; 9 | 10 | public class ScutiFastString extends Transformer implements PatternParts { 11 | 12 | @Override 13 | protected void transform() { 14 | PatternScanner patternScanner = new PatternScanner(new int[] { 15 | LDC, 16 | INVOKESTATIC 17 | }); 18 | 19 | for (ClassNode classNode : getClasses()) { 20 | MethodNode decryptMethod = null; 21 | 22 | for (MethodNode methodNode : classNode.methods) { 23 | for (InsnResult result : patternScanner.scanMethod(methodNode)) { 24 | if (!(((LdcInsnNode) result.getFirst()).cst instanceof String encrypted)) 25 | continue; 26 | 27 | MethodInsnNode decryptCall = (MethodInsnNode) result.getLast(); 28 | decryptMethod = ASMUtils.getMethod(classNode, decryptCall.name, decryptCall.desc); 29 | 30 | int key = getKeyByMethod(decryptMethod); 31 | 32 | ((LdcInsnNode) result.getFirst()).cst = decrypt(encrypted, key); 33 | methodNode.instructions.remove(decryptCall); 34 | } 35 | } 36 | 37 | if (decryptMethod != null) 38 | classNode.methods.remove(decryptMethod); 39 | } 40 | } 41 | 42 | private int getKeyByMethod(MethodNode methodNode) { 43 | PatternScanner patternScanner = new PatternScanner(new int[] { 44 | INVOKEVIRTUAL, 45 | P_NUMBER 46 | }); 47 | 48 | for (InsnResult result : patternScanner.scanMethod(methodNode)) { 49 | if (!ASMUtils.isIntPush(result.getLast())) 50 | continue; 51 | return ASMUtils.getIntValue(result.getLast()); 52 | } 53 | 54 | return -1; 55 | } 56 | 57 | private String decrypt(String string, int key) { 58 | StringBuilder decrypted = new StringBuilder(); 59 | for (int i = 0; i < string.length(); i++) { 60 | decrypted.append((char)(string.charAt(i) ^ key)); 61 | } 62 | return decrypted.toString(); 63 | } 64 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/transformers/scuti/ScutiFlow.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.transformers.scuti; 2 | 3 | import me.exeos.asmplus.JarLoader; 4 | import me.exeos.asmplus.pattern.PatternParts; 5 | import me.exeos.asmplus.pattern.PatternScanner; 6 | import me.exeos.asmplus.pattern.result.InsnResult; 7 | import me.exeos.asmplus.utils.ASMUtils; 8 | import org.objectweb.asm.tree.AbstractInsnNode; 9 | import org.objectweb.asm.tree.ClassNode; 10 | import org.objectweb.asm.tree.LabelNode; 11 | import org.objectweb.asm.tree.MethodNode; 12 | import xyz.breversed.api.asm.transformer.Transformer; 13 | 14 | import java.util.ArrayList; 15 | import java.util.Arrays; 16 | import java.util.List; 17 | 18 | public class ScutiFlow extends Transformer implements PatternParts { 19 | 20 | @Override 21 | protected void transform() { 22 | PatternScanner flowPattern = new PatternScanner(new int[] { 23 | GETSTATIC, 24 | GETSTATIC, 25 | JUMP_INSN, 26 | ACONST_NULL, 27 | P_ANY, 28 | ATHROW, 29 | P_ANY, 30 | ATHROW, 31 | P_ANY 32 | }); 33 | PatternScanner secondFlowPattern = getSecondFlowPattern(); 34 | PatternScanner thirdFlowPattern = getThirdFlowPattern(); 35 | PatternScanner staticInitializerPattern = getStaticInitializerPattern(); 36 | 37 | for (ClassNode classNode : getClasses()) { 38 | if (classNode.name.startsWith(" ")) { 39 | removeClass(classNode); 40 | continue; 41 | } 42 | 43 | for (MethodNode methodNode : classNode.methods) { 44 | if (methodNode.name.equals("")) 45 | for (InsnResult result : staticInitializerPattern.scanMethod(methodNode)) 46 | ASMUtils.removeInstructions(result.pattern, methodNode); 47 | 48 | for (InsnResult result : flowPattern.scanMethod(methodNode)) { 49 | 50 | // Remove trashy instructions 51 | List toRemove = new ArrayList<>(Arrays.asList(result.pattern)); 52 | toRemove.removeIf(node -> node instanceof LabelNode); 53 | ASMUtils.removeInstructions(toRemove, methodNode); 54 | 55 | // Remove try catch blocks 56 | methodNode.tryCatchBlocks.removeIf(tryCatchBlockNode -> tryCatchBlockNode.type.startsWith(" ")); 57 | } 58 | 59 | for (InsnResult result : secondFlowPattern.scanMethod(methodNode)) { 60 | 61 | // Remove trashy instructions 62 | List toRemove = new ArrayList<>(Arrays.asList(result.pattern)); 63 | toRemove.removeIf(node -> node instanceof LabelNode); 64 | ASMUtils.removeInstructions(toRemove, methodNode); 65 | } 66 | 67 | for (InsnResult result : thirdFlowPattern.scanMethod(methodNode)) { 68 | 69 | // Remove trashy instructions 70 | List toRemove = new ArrayList<>(Arrays.asList(result.pattern)); 71 | toRemove.removeIf(node -> node instanceof LabelNode); 72 | ASMUtils.removeInstructions(toRemove, methodNode); 73 | } 74 | 75 | // Remove fields 76 | classNode.fields.removeIf(fieldNode -> fieldNode.name.startsWith(" ")); 77 | } 78 | } 79 | } 80 | 81 | private PatternScanner getStaticInitializerPattern() { 82 | return new PatternScanner(new int[] { 83 | P_NUMBER, 84 | P_NUMBER, 85 | IXOR, 86 | PUTSTATIC, 87 | P_NUMBER, 88 | P_NUMBER, 89 | IXOR, 90 | PUTSTATIC 91 | }); 92 | } 93 | 94 | private PatternScanner getSecondFlowPattern() { 95 | return new PatternScanner(new int[] { 96 | GOTO, 97 | P_ANY, 98 | GOTO, 99 | P_ANY, 100 | GETSTATIC, 101 | GETSTATIC, 102 | JUMP_INSN, 103 | ACONST_NULL, 104 | ATHROW 105 | }); 106 | } 107 | 108 | private PatternScanner getThirdFlowPattern() { 109 | return new PatternScanner(new int[] { 110 | ATHROW, 111 | P_ANY, 112 | JUMP_INSN, 113 | P_ANY, 114 | GETSTATIC, 115 | GETSTATIC, 116 | JUMP_INSN, 117 | ACONST_NULL, 118 | ATHROW 119 | }); 120 | } 121 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/transformers/scuti/ScutiInvokeDynamic.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.transformers.scuti; 2 | 3 | import me.exeos.asmplus.pattern.PatternParts; 4 | import me.exeos.asmplus.pattern.PatternScanner; 5 | import me.exeos.asmplus.pattern.result.InsnResult; 6 | import me.exeos.asmplus.utils.ASMUtils; 7 | import org.objectweb.asm.tree.*; 8 | import xyz.breversed.api.asm.transformer.Transformer; 9 | 10 | public class ScutiInvokeDynamic extends Transformer implements PatternParts { 11 | 12 | @Override 13 | protected void transform() { 14 | PatternScanner patternScanner = new PatternScanner(new int[] { 15 | INVOKEDYNAMIC 16 | }); 17 | 18 | for (ClassNode classNode : getClasses()) { 19 | MethodNode stringDecryptMethod = classNode.methods.stream().filter(methodNode -> methodNode.access == 4170 && 20 | methodNode.desc.equals("(Ljava/lang/String;)Ljava/lang/String;")).findFirst().orElse(null); 21 | MethodNode callDecryptMethod = classNode.methods.stream().filter(methodNode -> methodNode.access == 4169 && 22 | methodNode.desc.equals("(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;)Ljava/lang/invoke/CallSite;")).findFirst().orElse(null); 23 | 24 | if (stringDecryptMethod == null || callDecryptMethod == null) 25 | continue; 26 | 27 | int key = getKeyByMethod(stringDecryptMethod); 28 | 29 | for (MethodNode methodNode : classNode.methods) { 30 | for (InsnResult result : patternScanner.scanMethod(methodNode)) { 31 | InvokeDynamicInsnNode invokeDynamicCall = (InvokeDynamicInsnNode) result.getFirst(); 32 | 33 | Object[] decryptedArgs = new Object[invokeDynamicCall.bsmArgs.length]; 34 | 35 | for (int i = 0; i < invokeDynamicCall.bsmArgs.length; i++) { 36 | Object bsmArgs = invokeDynamicCall.bsmArgs[i]; 37 | 38 | if (bsmArgs instanceof Integer) { 39 | decryptedArgs[i] = bsmArgs; 40 | continue; 41 | } 42 | 43 | if (!(bsmArgs instanceof String string)) 44 | continue; 45 | 46 | decryptedArgs[i] = decrypt(string, key); 47 | } 48 | 49 | MethodInsnNode decryptedCall = new MethodInsnNode((int) decryptedArgs[3] == 0 ? INVOKESTATIC : INVOKEVIRTUAL, 50 | ((String) (decryptedArgs[0])).replace(".", "/"), (String) decryptedArgs[1], (String) decryptedArgs[2]); 51 | methodNode.instructions.set(invokeDynamicCall, decryptedCall); 52 | } 53 | } 54 | 55 | classNode.methods.remove(stringDecryptMethod); 56 | classNode.methods.remove(callDecryptMethod); 57 | } 58 | } 59 | 60 | private int getKeyByMethod(MethodNode methodNode) { 61 | PatternScanner patternScanner = new PatternScanner(new int[] { 62 | INVOKEVIRTUAL, 63 | P_NUMBER 64 | }); 65 | 66 | for (InsnResult result : patternScanner.scanMethod(methodNode)) { 67 | if (ASMUtils.isIntPush(result.getLast())) 68 | return ASMUtils.getIntValue(result.getLast()); 69 | } 70 | 71 | return -1; 72 | } 73 | 74 | private String decrypt(String string, int key) { 75 | StringBuilder decrypted = new StringBuilder(); 76 | for (int i = 0; i < string.length(); i++) { 77 | decrypted.append((char)(string.charAt(i) ^ key)); 78 | } 79 | return decrypted.toString(); 80 | } 81 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/transformers/scuti/ScutiNumber.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.transformers.scuti; 2 | 3 | import me.exeos.asmplus.pattern.PatternParts; 4 | import me.exeos.asmplus.pattern.PatternScanner; 5 | import me.exeos.asmplus.pattern.result.InsnResult; 6 | import me.exeos.asmplus.utils.ASMUtils; 7 | import org.objectweb.asm.tree.*; 8 | import xyz.breversed.api.asm.transformer.Transformer; 9 | 10 | import java.util.List; 11 | 12 | public class ScutiNumber extends Transformer implements PatternParts { 13 | 14 | @Override 15 | protected void transform() { 16 | PatternScanner patternScanner = new PatternScanner(new int[] { 17 | P_NUMBER, 18 | P_NUMBER, 19 | IXOR, 20 | P_NUMBER, 21 | IXOR, 22 | P_NUMBER, 23 | IXOR 24 | }); 25 | 26 | for (ClassNode classNode : getClasses()) { 27 | for (MethodNode methodNode : classNode.methods) { 28 | List results = patternScanner.scanMethod(methodNode); 29 | 30 | while (!results.isEmpty()) { 31 | for (InsnResult result : results) { 32 | // put all the xor numbers into an array 33 | int[] values = new int[] { ASMUtils.getIntValue(result.pattern[0]), ASMUtils.getIntValue(result.pattern[1]), 34 | ASMUtils.getIntValue(result.pattern[3]), ASMUtils.getIntValue(result.pattern[5]) }; 35 | 36 | int value = values[0] ^ values[1] ^ values[2] ^ values[3]; 37 | methodNode.instructions.insertBefore(result.getFirst(), ASMUtils.getIntPush(value)); 38 | 39 | for (AbstractInsnNode node : result.pattern) 40 | methodNode.instructions.remove(node); 41 | } 42 | results = patternScanner.scanMethod(methodNode); 43 | } 44 | } 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/java/xyz/breversed/transformers/scuti/ScutiStrongString.java: -------------------------------------------------------------------------------- 1 | package xyz.breversed.transformers.scuti; 2 | 3 | import me.exeos.asmplus.pattern.PatternParts; 4 | import me.exeos.asmplus.pattern.PatternScanner; 5 | import me.exeos.asmplus.pattern.result.InsnResult; 6 | import me.exeos.asmplus.utils.ASMUtils; 7 | import org.objectweb.asm.tree.*; 8 | import xyz.breversed.api.asm.transformer.Transformer; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | public class ScutiStrongString extends Transformer implements PatternParts { 14 | 15 | @Override 16 | protected void transform() { 17 | PatternScanner patternScanner = new PatternScanner(new int[] { 18 | LDC, 19 | P_NUMBER 20 | }); 21 | 22 | for (ClassNode classNode : getClasses()) { 23 | MethodNode decryptMethod = null; 24 | 25 | for (MethodNode methodNode : classNode.methods) { 26 | for (InsnResult result : patternScanner.scanMethod(methodNode)) { 27 | if (!(((LdcInsnNode) result.getFirst()).cst instanceof String encrypted)) 28 | continue; 29 | if (!ASMUtils.isIntPush(result.getLast())) 30 | continue; 31 | int key = ASMUtils.getIntValue(result.getLast()); 32 | 33 | List toRemove = new ArrayList<>(); 34 | AbstractInsnNode current = result.getLast(); 35 | MethodInsnNode decryptCall = null; 36 | 37 | /* we don't know how many NEG and SWAP instructions are in between the key and the decrypt call because its randomised, 38 | so we have to iterate through the instructions until we find the decrypt call 39 | TODO: find a cleaner way to do this 40 | */ 41 | while (decryptCall == null) { 42 | current = current.getNext(); 43 | 44 | toRemove.add(current); 45 | 46 | if (current instanceof MethodInsnNode && 47 | ((MethodInsnNode) current).owner.equals(classNode.name) && 48 | ((MethodInsnNode) current).desc.equals("(Ljava/lang/String;I)Ljava/lang/String;")) { 49 | decryptCall = (MethodInsnNode) current; 50 | } 51 | } 52 | 53 | decryptMethod = ASMUtils.getMethod(classNode, decryptCall.name, decryptCall.desc); 54 | 55 | for (AbstractInsnNode abstractInsnNode : toRemove) 56 | methodNode.instructions.remove(abstractInsnNode); 57 | methodNode.instructions.remove(result.getLast()); 58 | 59 | ((LdcInsnNode) result.getFirst()).cst = decrypt(decryptCall.name, encrypted, key); 60 | } 61 | } 62 | 63 | if (decryptMethod != null) 64 | classNode.methods.remove(decryptMethod); 65 | } 66 | } 67 | 68 | private String decrypt(String methodName, String string, int key) { 69 | int methodHash = methodName.hashCode(); 70 | char[] strArray = new char[string.length()]; 71 | for (int i = 0; i < string.length(); i++) { 72 | strArray[i] = (char)(string.charAt(i) ^ (key ^ methodHash)); 73 | } 74 | return new String(strArray); 75 | } 76 | } --------------------------------------------------------------------------------