├── .idea ├── $PRODUCT_WORKSPACE_FILE$ ├── .gitignore ├── .name ├── compiler.xml ├── discord.xml ├── encodings.xml ├── inspectionProfiles │ └── Project_Default.xml ├── libraries │ ├── Maven__club_minnced_discord_rpc_release_v3_4_0.xml │ ├── Maven__club_minnced_java_discord_rpc_2_0_2.xml │ ├── Maven__com_fifesoft_rsyntaxtextarea_2_6_1.xml │ ├── Maven__com_google_code_findbugs_jsr305_3_0_2.xml │ ├── Maven__com_google_code_gson_gson_2_8_5.xml │ ├── Maven__com_google_errorprone_error_prone_annotations_2_3_2.xml │ ├── Maven__com_google_guava_failureaccess_1_0_1.xml │ ├── Maven__com_google_guava_guava_28_1_jre.xml │ ├── Maven__com_google_guava_listenablefuture_9999_0_empty_to_avoid_conflict_with_guava.xml │ ├── Maven__com_google_j2objc_j2objc_annotations_1_3.xml │ ├── Maven__com_sun_attach_1_7.xml │ ├── Maven__com_weblaf_weblaf_1_2_9.xml │ ├── Maven__commons_cli_commons_cli_1_4.xml │ ├── Maven__commons_io_commons_io_2_4.xml │ ├── Maven__net_java_dev_jna_jna_4_4_0.xml │ ├── Maven__org_apache_ant_ant_1_10_5.xml │ ├── Maven__org_apache_ant_ant_launcher_1_10_5.xml │ ├── Maven__org_benf_cfr_0_146.xml │ ├── Maven__org_bitbucket_mstrobel_procyon_compilertools_0_5_36.xml │ ├── Maven__org_bitbucket_mstrobel_procyon_core_0_5_36.xml │ ├── Maven__org_bitbucket_mstrobel_procyon_expressions_0_5_36.xml │ ├── Maven__org_bitbucket_mstrobel_procyon_reflection_0_5_36.xml │ ├── Maven__org_checkerframework_checker_qual_2_8_1.xml │ ├── Maven__org_codehaus_mojo_animal_sniffer_annotations_1_18.xml │ ├── Maven__org_jetbrains_annotations_13_0.xml │ ├── Maven__org_jetbrains_kotlin_kotlin_stdlib_1_3_50.xml │ ├── Maven__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_50.xml │ ├── Maven__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_3_50.xml │ ├── Maven__org_jetbrains_kotlin_kotlin_stdlib_jdk8_1_3_50.xml │ ├── Maven__org_jetbrains_kotlin_kotlin_test_1_3_50.xml │ ├── Maven__org_jetbrains_kotlin_kotlin_test_common_1_3_50.xml │ ├── Maven__org_jfree_jfreechart_1_5_0.xml │ └── Maven__org_tinyjee_jgraphx_jgraphx_3_4_1_3.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── JByteMod Reborn.iml ├── README.md ├── jbytemod.cfg ├── lib ├── attach-1.7.jar ├── cfr_0_146.jar ├── procyon-0.5.36.jar └── weblaf-complete-1.29-fixed.jar ├── pom.xml └── src └── main ├── java ├── android │ └── util │ │ └── Patterns.java ├── codes │ └── som │ │ └── anthony │ │ └── koffee │ │ ├── ClassAssembly.kt │ │ ├── ClassAssemblyContext.kt │ │ ├── InstructionAssembly.kt │ │ ├── InstructionBlockAssembly.kt │ │ ├── LabelRegistry.kt │ │ ├── MethodAssembly.kt │ │ ├── MethodAssemblyContext.kt │ │ ├── ModifiersAccess.kt │ │ ├── TypesAccess.kt │ │ ├── disassembler │ │ ├── ClassDisassembly.kt │ │ ├── FieldDisassembly.kt │ │ ├── MethodDisassembly.kt │ │ ├── ValueDisassembly.kt │ │ ├── data │ │ │ ├── AccessFlagNameMap.kt │ │ │ └── OpcodeNameMap.kt │ │ └── util │ │ │ ├── DisassemblyContext.kt │ │ │ └── SourceCodeGenerator.kt │ │ └── insnsyntax │ │ ├── jvm │ │ ├── Arithmetic.kt │ │ ├── Arrays.kt │ │ ├── Constants.kt │ │ ├── ControlFlow.kt │ │ ├── Fields.kt │ │ ├── InvokeDynamic.kt │ │ ├── JVMSyntax.kt │ │ ├── LocalVariables.kt │ │ ├── Methods.kt │ │ ├── ObjectManagement.kt │ │ ├── StackManipulation.kt │ │ ├── SwitchConstruct.kt │ │ ├── Synchronization.kt │ │ └── TryCatchBlocks.kt │ │ └── sugar │ │ ├── IntegerLiterals.kt │ │ └── LocalVariables.kt ├── com │ └── javadeobfuscator │ │ └── deobfuscator │ │ ├── analyzer │ │ ├── AnalyzerResult.java │ │ ├── ArgsAnalyzer.java │ │ ├── MethodAnalyzer.java │ │ ├── Value.java │ │ ├── ValueType.java │ │ └── frame │ │ │ ├── ArgumentFrame.java │ │ │ ├── ArrayLengthFrame.java │ │ │ ├── ArrayLoadFrame.java │ │ │ ├── ArrayStoreFrame.java │ │ │ ├── CheckCastFrame.java │ │ │ ├── DupFrame.java │ │ │ ├── FieldFrame.java │ │ │ ├── Frame.java │ │ │ ├── InstanceofFrame.java │ │ │ ├── JumpFrame.java │ │ │ ├── LdcFrame.java │ │ │ ├── LocalFrame.java │ │ │ ├── MathFrame.java │ │ │ ├── MethodFrame.java │ │ │ ├── MonitorFrame.java │ │ │ ├── MultiANewArrayFrame.java │ │ │ ├── NewArrayFrame.java │ │ │ ├── NewFrame.java │ │ │ ├── PopFrame.java │ │ │ ├── ReturnFrame.java │ │ │ ├── SwapFrame.java │ │ │ ├── SwitchFrame.java │ │ │ └── ThrowFrame.java │ │ └── utils │ │ ├── ClassTree.java │ │ ├── InstructionModifier.java │ │ ├── PrimitiveUtils.java │ │ ├── RuntimeTypeAdapterFactory.java │ │ ├── TransformerHelper.java │ │ └── Utils.java ├── hakery │ └── club │ │ └── raccscanner │ │ ├── Raccoon.java │ │ ├── logger │ │ └── RaccoonLogger.java │ │ ├── results │ │ ├── Result.java │ │ └── util │ │ │ ├── Obfuscator.java │ │ │ └── result │ │ │ ├── ObfuscatorResult.java │ │ │ └── impl │ │ │ ├── AllatoriResult.java │ │ │ ├── DashOResult.java │ │ │ ├── ParamorphismResult.java │ │ │ └── StringerResult.java │ │ ├── scanner │ │ ├── Scanner.java │ │ ├── Scanners.java │ │ └── impl │ │ │ ├── classes │ │ │ ├── ClassCountScanner.java │ │ │ └── DebugInfoScanner.java │ │ │ ├── debugging │ │ │ └── DebugScanner.java │ │ │ ├── jar │ │ │ └── JarSizeScanner.java │ │ │ └── obfuscators │ │ │ ├── allatori │ │ │ └── AllatoriStringEncryptionScanner.java │ │ │ ├── dasho │ │ │ └── DashOStringEncryptionScanner.java │ │ │ ├── paramorphism │ │ │ ├── ParamorphismClassloaderScanner.java │ │ │ ├── ParamorphismDecrypterScanner.java │ │ │ └── ParamorphismManifestScanner.java │ │ │ └── stringer │ │ │ ├── StringerHideAccessScanner.java │ │ │ ├── StringerIntegrityControlScanner.java │ │ │ ├── StringerManifestScanner.java │ │ │ └── StringerStringEncryptionScanner.java │ │ └── util │ │ ├── DataUtils.java │ │ ├── OpcodeUtils.java │ │ ├── SourceFileData.java │ │ └── opcodes │ │ └── InstructionList.java ├── me │ ├── grax │ │ └── jbytemod │ │ │ ├── JByteMod.java │ │ │ ├── JarArchive.java │ │ │ ├── analysis │ │ │ ├── block │ │ │ │ └── Block.java │ │ │ ├── converter │ │ │ │ └── Converter.java │ │ │ ├── decompiler │ │ │ │ ├── ClassDefinition.java │ │ │ │ ├── code │ │ │ │ │ ├── TabbedStringBuffer.java │ │ │ │ │ └── ast │ │ │ │ │ │ ├── AstColors.java │ │ │ │ │ │ ├── Comparison.java │ │ │ │ │ │ ├── EndBlock.java │ │ │ │ │ │ ├── Expression.java │ │ │ │ │ │ ├── Operation.java │ │ │ │ │ │ ├── VarType.java │ │ │ │ │ │ └── expressions │ │ │ │ │ │ ├── ArrayIndexExpression.java │ │ │ │ │ │ ├── ArrayStoreExpression.java │ │ │ │ │ │ ├── CastExpression.java │ │ │ │ │ │ ├── ClassTypeExpression.java │ │ │ │ │ │ ├── ComparisonExpression.java │ │ │ │ │ │ ├── DebugStackAssignExpression.java │ │ │ │ │ │ ├── DebugStackExpression.java │ │ │ │ │ │ ├── DebugStackUnknownExpression.java │ │ │ │ │ │ ├── FieldAssignExpression.java │ │ │ │ │ │ ├── FieldExpression.java │ │ │ │ │ │ ├── IncrementExpression.java │ │ │ │ │ │ ├── InstanceofExpression.java │ │ │ │ │ │ ├── InvokeDynamicExpression.java │ │ │ │ │ │ ├── LookupSwitchExpression.java │ │ │ │ │ │ ├── MethodExpression.java │ │ │ │ │ │ ├── NewArrayExpression.java │ │ │ │ │ │ ├── NewPrimArrayExpression.java │ │ │ │ │ │ ├── NewTypeExpression.java │ │ │ │ │ │ ├── NotExpression.java │ │ │ │ │ │ ├── NullExpression.java │ │ │ │ │ │ ├── OpExpression.java │ │ │ │ │ │ ├── ReturnExpression.java │ │ │ │ │ │ ├── SingleOpExpression.java │ │ │ │ │ │ ├── StringExpression.java │ │ │ │ │ │ ├── TableSwitchExpression.java │ │ │ │ │ │ ├── TextExpression.java │ │ │ │ │ │ ├── ThrowExpression.java │ │ │ │ │ │ ├── ValueExpression.java │ │ │ │ │ │ ├── VarAssignExpression.java │ │ │ │ │ │ ├── VarLoadExpression.java │ │ │ │ │ │ └── VarSpecialExpression.java │ │ │ │ ├── defs │ │ │ │ │ └── Keywords.java │ │ │ │ ├── struct │ │ │ │ │ ├── Conversion.java │ │ │ │ │ ├── JVMStack.java │ │ │ │ │ ├── exception │ │ │ │ │ │ ├── StackException.java │ │ │ │ │ │ └── UnknownOPException.java │ │ │ │ │ └── utils │ │ │ │ │ │ └── DescUtils.java │ │ │ │ └── syntax │ │ │ │ │ └── nodes │ │ │ │ │ └── NodeList.java │ │ │ ├── errors │ │ │ │ ├── EmptyMistake.java │ │ │ │ ├── ErrorAnalyzer.java │ │ │ │ ├── InsnError.java │ │ │ │ ├── InsnWarning.java │ │ │ │ └── Mistake.java │ │ │ ├── obfuscation │ │ │ │ ├── ObfuscationAnalyzer.java │ │ │ │ ├── enums │ │ │ │ │ ├── MethodObfType.java │ │ │ │ │ └── NameObfType.java │ │ │ │ └── result │ │ │ │ │ ├── MethodResult.java │ │ │ │ │ └── NamesResult.java │ │ │ └── utils │ │ │ │ └── BlockUtils.java │ │ │ ├── decompiler │ │ │ ├── CFRDecompiler.java │ │ │ ├── Decompiler.java │ │ │ ├── Decompilers.java │ │ │ ├── FernflowerDecompiler.java │ │ │ ├── KoffeeDecompiler.java │ │ │ ├── KrakatauDecompiler.java │ │ │ └── ProcyonDecompiler.java │ │ │ ├── discord │ │ │ └── Discord.java │ │ │ ├── logging │ │ │ └── Logging.java │ │ │ ├── plugin │ │ │ ├── Plugin.java │ │ │ └── PluginManager.java │ │ │ ├── res │ │ │ ├── LanguageRes.java │ │ │ ├── Option.java │ │ │ └── Options.java │ │ │ ├── scanner │ │ │ └── ScannerThread.java │ │ │ ├── ui │ │ │ ├── ClassTree.java │ │ │ ├── DecompilerPanel.java │ │ │ ├── DecompilerTab.java │ │ │ ├── InfoPanel.java │ │ │ ├── JAboutFrame.java │ │ │ ├── JAccessHelper.java │ │ │ ├── JAccessSelectorPanel.java │ │ │ ├── JAnnotationEditor.java │ │ │ ├── JFrameList.java │ │ │ ├── JLDCEditor.java │ │ │ ├── JListEditor.java │ │ │ ├── JMethodObfAnalysis.java │ │ │ ├── JNameObfAnalysis.java │ │ │ ├── JObfAnalysis.java │ │ │ ├── JProcessSelection.java │ │ │ ├── JSearch.java │ │ │ ├── MyCodeEditor.java │ │ │ ├── MyEditorTab.java │ │ │ ├── MyMenuBar.java │ │ │ ├── MySplitPane.java │ │ │ ├── MyTabbedPane.java │ │ │ ├── MyToolBar.java │ │ │ ├── NoBorderSP.java │ │ │ ├── OpcodeTable.java │ │ │ ├── PageEndPanel.java │ │ │ ├── TreeCellRenderer.java │ │ │ ├── dialogue │ │ │ │ ├── ClassDialogue.java │ │ │ │ ├── InsnEditDialogue.java │ │ │ │ ├── JChooseString.java │ │ │ │ └── testing │ │ │ │ │ └── TestValues.java │ │ │ ├── graph │ │ │ │ ├── BlockVertex.java │ │ │ │ ├── CFGraph.java │ │ │ │ ├── ControlFlowPanel.java │ │ │ │ ├── PatchedCoordinateAssignment.java │ │ │ │ └── PatchedHierarchicalLayout.java │ │ │ ├── ifs │ │ │ │ ├── CNSettings.java │ │ │ │ ├── LVPFrame.java │ │ │ │ ├── MNSettings.java │ │ │ │ ├── MyInternalFrame.java │ │ │ │ └── TCBFrame.java │ │ │ ├── lists │ │ │ │ ├── AdressList.java │ │ │ │ ├── ErrorList.java │ │ │ │ ├── LVPList.java │ │ │ │ ├── MyCodeList.java │ │ │ │ ├── SearchList.java │ │ │ │ ├── TCBList.java │ │ │ │ └── entries │ │ │ │ │ ├── FieldEntry.java │ │ │ │ │ ├── InstrEntry.java │ │ │ │ │ ├── LVPEntry.java │ │ │ │ │ ├── PrototypeEntry.java │ │ │ │ │ ├── SearchEntry.java │ │ │ │ │ └── TCBEntry.java │ │ │ └── tree │ │ │ │ └── SortedTreeNode.java │ │ │ └── utils │ │ │ ├── DeobfusacteUtils.java │ │ │ ├── ErrorDisplay.java │ │ │ ├── FileUtils.java │ │ │ ├── HtmlSelection.java │ │ │ ├── ImageUtils.java │ │ │ ├── InstrUtils.java │ │ │ ├── MethodUtils.java │ │ │ ├── TextUtils.java │ │ │ ├── ThemeChanges.java │ │ │ ├── asm │ │ │ ├── FrameGen.java │ │ │ ├── Hints.java │ │ │ ├── LibClassWriter.java │ │ │ ├── Loader.java │ │ │ └── ParentUtils.java │ │ │ ├── attach │ │ │ ├── AttachUtils.java │ │ │ ├── InjectUtils.java │ │ │ └── RuntimeJarArchive.java │ │ │ ├── gui │ │ │ ├── LookUtils.java │ │ │ └── SwingUtils.java │ │ │ ├── list │ │ │ └── LazyListModel.java │ │ │ └── task │ │ │ ├── AttachTask.java │ │ │ ├── LoadTask.java │ │ │ ├── RetransformTask.java │ │ │ ├── SaveTask.java │ │ │ └── search │ │ │ ├── LdcTask.java │ │ │ ├── ReferenceTask.java │ │ │ └── SFTask.java │ └── lpk │ │ └── util │ │ ├── ASMUtils.java │ │ ├── AccessHelper.java │ │ ├── JarUtils.java │ │ ├── OpUtils.java │ │ ├── StringUtils.java │ │ └── drop │ │ ├── IDropUser.java │ │ └── JarDropHandler.java └── org │ ├── jetbrains │ └── java │ │ └── decompiler │ │ ├── code │ │ ├── CodeConstants.java │ │ ├── ExceptionHandler.java │ │ ├── ExceptionTable.java │ │ ├── FullInstructionSequence.java │ │ ├── Instruction.java │ │ ├── InstructionSequence.java │ │ ├── JumpInstruction.java │ │ ├── SimpleInstructionSequence.java │ │ ├── SwitchInstruction.java │ │ ├── cfg │ │ │ ├── BasicBlock.java │ │ │ ├── ControlFlowGraph.java │ │ │ └── ExceptionRangeCFG.java │ │ └── interpreter │ │ │ └── InstructionImpact.java │ │ ├── main │ │ ├── AssertProcessor.java │ │ ├── ClassReference14Processor.java │ │ ├── ClassWriter.java │ │ ├── ClassesProcessor.java │ │ ├── DecompilerContext.java │ │ ├── EnumProcessor.java │ │ ├── Fernflower.java │ │ ├── InitializerProcessor.java │ │ ├── collectors │ │ │ ├── BytecodeMappingTracer.java │ │ │ ├── BytecodeSourceMapper.java │ │ │ ├── CounterContainer.java │ │ │ ├── ImportCollector.java │ │ │ └── VarNamesCollector.java │ │ ├── decompiler │ │ │ ├── BaseDecompiler.java │ │ │ ├── ConsoleDecompiler.java │ │ │ └── PrintStreamLogger.java │ │ ├── extern │ │ │ ├── IBytecodeProvider.java │ │ │ ├── IFernflowerLogger.java │ │ │ ├── IFernflowerPreferences.java │ │ │ ├── IIdentifierRenamer.java │ │ │ └── IResultSaver.java │ │ └── rels │ │ │ ├── ClassWrapper.java │ │ │ ├── LambdaProcessor.java │ │ │ ├── MethodProcessorRunnable.java │ │ │ ├── MethodWrapper.java │ │ │ ├── NestedClassProcessor.java │ │ │ └── NestedMemberAccess.java │ │ ├── modules │ │ ├── code │ │ │ └── DeadCodeHelper.java │ │ ├── decompiler │ │ │ ├── ClearStructHelper.java │ │ │ ├── ConcatenationHelper.java │ │ │ ├── DecHelper.java │ │ │ ├── DomHelper.java │ │ │ ├── ExitHelper.java │ │ │ ├── ExprProcessor.java │ │ │ ├── ExprentStack.java │ │ │ ├── FinallyProcessor.java │ │ │ ├── IdeaNotNullHelper.java │ │ │ ├── IfHelper.java │ │ │ ├── InlineSingleBlockHelper.java │ │ │ ├── LabelHelper.java │ │ │ ├── LoopExtractHelper.java │ │ │ ├── MergeHelper.java │ │ │ ├── PPandMMHelper.java │ │ │ ├── PrimitiveExprsList.java │ │ │ ├── SecondaryFunctionsHelper.java │ │ │ ├── SequenceHelper.java │ │ │ ├── SimplifyExprentsHelper.java │ │ │ ├── StackVarsProcessor.java │ │ │ ├── StatEdge.java │ │ │ ├── StrongConnectivityHelper.java │ │ │ ├── decompose │ │ │ │ ├── DominatorEngine.java │ │ │ │ ├── DominatorTreeExceptionFilter.java │ │ │ │ ├── FastExtendedPostdominanceHelper.java │ │ │ │ ├── GenericDominatorEngine.java │ │ │ │ ├── IGraph.java │ │ │ │ └── IGraphNode.java │ │ │ ├── deobfuscator │ │ │ │ ├── ExceptionDeobfuscator.java │ │ │ │ └── IrreducibleCFGDeobfuscator.java │ │ │ ├── exps │ │ │ │ ├── AnnotationExprent.java │ │ │ │ ├── ArrayExprent.java │ │ │ │ ├── AssertExprent.java │ │ │ │ ├── AssignmentExprent.java │ │ │ │ ├── ConstExprent.java │ │ │ │ ├── ExitExprent.java │ │ │ │ ├── Exprent.java │ │ │ │ ├── FieldExprent.java │ │ │ │ ├── FunctionExprent.java │ │ │ │ ├── IfExprent.java │ │ │ │ ├── InvocationExprent.java │ │ │ │ ├── MonitorExprent.java │ │ │ │ ├── NewExprent.java │ │ │ │ ├── SwitchExprent.java │ │ │ │ ├── TypeAnnotation.java │ │ │ │ └── VarExprent.java │ │ │ ├── sforms │ │ │ │ ├── DirectGraph.java │ │ │ │ ├── DirectNode.java │ │ │ │ ├── FlattenStatementsHelper.java │ │ │ │ ├── SSAConstructorSparseEx.java │ │ │ │ └── SSAUConstructorSparseEx.java │ │ │ ├── stats │ │ │ │ ├── BasicBlockStatement.java │ │ │ │ ├── CatchAllStatement.java │ │ │ │ ├── CatchStatement.java │ │ │ │ ├── DoStatement.java │ │ │ │ ├── DummyExitStatement.java │ │ │ │ ├── GeneralStatement.java │ │ │ │ ├── IfStatement.java │ │ │ │ ├── RootStatement.java │ │ │ │ ├── SequenceStatement.java │ │ │ │ ├── Statement.java │ │ │ │ ├── Statements.java │ │ │ │ ├── SwitchStatement.java │ │ │ │ └── SynchronizedStatement.java │ │ │ └── vars │ │ │ │ ├── CheckTypesResult.java │ │ │ │ ├── VarDefinitionHelper.java │ │ │ │ ├── VarProcessor.java │ │ │ │ ├── VarTypeProcessor.java │ │ │ │ ├── VarVersionEdge.java │ │ │ │ ├── VarVersionNode.java │ │ │ │ ├── VarVersionPair.java │ │ │ │ ├── VarVersionsGraph.java │ │ │ │ └── VarVersionsProcessor.java │ │ └── renamer │ │ │ ├── ClassWrapperNode.java │ │ │ ├── ConverterHelper.java │ │ │ ├── IdentifierConverter.java │ │ │ └── PoolInterceptor.java │ │ ├── struct │ │ ├── ContextUnit.java │ │ ├── IDecompiledData.java │ │ ├── StructClass.java │ │ ├── StructContext.java │ │ ├── StructField.java │ │ ├── StructMember.java │ │ ├── StructMethod.java │ │ ├── attr │ │ │ ├── StructAnnDefaultAttribute.java │ │ │ ├── StructAnnotationAttribute.java │ │ │ ├── StructAnnotationParameterAttribute.java │ │ │ ├── StructBootstrapMethodsAttribute.java │ │ │ ├── StructConstantValueAttribute.java │ │ │ ├── StructEnclosingMethodAttribute.java │ │ │ ├── StructExceptionsAttribute.java │ │ │ ├── StructGeneralAttribute.java │ │ │ ├── StructGenericSignatureAttribute.java │ │ │ ├── StructInnerClassesAttribute.java │ │ │ ├── StructLineNumberTableAttribute.java │ │ │ ├── StructLocalVariableTableAttribute.java │ │ │ └── StructTypeAnnotationAttribute.java │ │ ├── consts │ │ │ ├── ConstantPool.java │ │ │ ├── LinkConstant.java │ │ │ ├── PooledConstant.java │ │ │ └── PrimitiveConstant.java │ │ ├── gen │ │ │ ├── DataPoint.java │ │ │ ├── FieldDescriptor.java │ │ │ ├── MethodDescriptor.java │ │ │ ├── NewClassNameBuilder.java │ │ │ ├── VarType.java │ │ │ └── generics │ │ │ │ ├── GenericClassDescriptor.java │ │ │ │ ├── GenericFieldDescriptor.java │ │ │ │ ├── GenericMain.java │ │ │ │ ├── GenericMethodDescriptor.java │ │ │ │ └── GenericType.java │ │ ├── lazy │ │ │ └── LazyLoader.java │ │ └── match │ │ │ ├── IMatchable.java │ │ │ ├── MatchEngine.java │ │ │ └── MatchNode.java │ │ └── util │ │ ├── DataInputFullStream.java │ │ ├── FastFixedSetFactory.java │ │ ├── FastSparseSetFactory.java │ │ ├── InterpreterUtil.java │ │ ├── ListStack.java │ │ ├── SFormsFastMapDirect.java │ │ ├── TextUtil.java │ │ └── VBStyleCollection.java │ └── objectweb │ └── asm │ ├── AnnotationVisitor.java │ ├── AnnotationWriter.java │ ├── Attribute.java │ ├── ByteVector.java │ ├── ClassReader.java │ ├── ClassTooLargeException.java │ ├── ClassVisitor.java │ ├── ClassWriter.java │ ├── ConstantDynamic.java │ ├── Constants.java │ ├── Context.java │ ├── CurrentFrame.java │ ├── Edge.java │ ├── FieldVisitor.java │ ├── FieldWriter.java │ ├── Frame.java │ ├── Handle.java │ ├── Handler.java │ ├── Label.java │ ├── MethodTooLargeException.java │ ├── MethodVisitor.java │ ├── MethodWriter.java │ ├── ModuleVisitor.java │ ├── ModuleWriter.java │ ├── Opcodes.java │ ├── Symbol.java │ ├── SymbolTable.java │ ├── Type.java │ ├── TypePath.java │ ├── TypeReference.java │ ├── commons │ ├── AdviceAdapter.java │ ├── AnalyzerAdapter.java │ ├── AnnotationRemapper.java │ ├── ClassRemapper.java │ ├── CodeSizeEvaluator.java │ ├── FieldRemapper.java │ ├── GeneratorAdapter.java │ ├── InstructionAdapter.java │ ├── JSRInlinerAdapter.java │ ├── LocalVariablesSorter.java │ ├── Method.java │ ├── MethodRemapper.java │ ├── ModuleHashesAttribute.java │ ├── ModuleRemapper.java │ ├── ModuleResolutionAttribute.java │ ├── ModuleTargetAttribute.java │ ├── Remapper.java │ ├── SerialVersionUIDAdder.java │ ├── SignatureRemapper.java │ ├── SimpleRemapper.java │ ├── StaticInitMerger.java │ ├── TableSwitchGenerator.java │ ├── TryCatchBlockSorter.java │ └── package.html │ ├── package.html │ ├── signature │ ├── SignatureReader.java │ ├── SignatureVisitor.java │ ├── SignatureWriter.java │ └── package.html │ ├── tree │ ├── AbstractInsnNode.java │ ├── AnnotationNode.java │ ├── ClassNode.java │ ├── FieldInsnNode.java │ ├── FieldNode.java │ ├── FrameNode.java │ ├── IincInsnNode.java │ ├── InnerClassNode.java │ ├── InsnList.java │ ├── InsnNode.java │ ├── IntInsnNode.java │ ├── InvokeDynamicInsnNode.java │ ├── JumpInsnNode.java │ ├── LabelNode.java │ ├── LdcInsnNode.java │ ├── LineNumberNode.java │ ├── LocalVariableAnnotationNode.java │ ├── LocalVariableNode.java │ ├── LookupSwitchInsnNode.java │ ├── MethodInsnNode.java │ ├── MethodNode.java │ ├── ModuleExportNode.java │ ├── ModuleNode.java │ ├── ModuleOpenNode.java │ ├── ModuleProvideNode.java │ ├── ModuleRequireNode.java │ ├── MultiANewArrayInsnNode.java │ ├── ParameterNode.java │ ├── TableSwitchInsnNode.java │ ├── TryCatchBlockNode.java │ ├── TypeAnnotationNode.java │ ├── TypeInsnNode.java │ ├── VarInsnNode.java │ ├── analysis │ │ ├── Analyzer.java │ │ ├── AnalyzerException.java │ │ ├── BasicInterpreter.java │ │ ├── BasicValue.java │ │ ├── BasicVerifier.java │ │ ├── Frame.java │ │ ├── Interpreter.java │ │ ├── SimpleVerifier.java │ │ ├── SmallSet.java │ │ ├── SourceInterpreter.java │ │ ├── SourceValue.java │ │ ├── Subroutine.java │ │ ├── Value.java │ │ └── package.html │ └── package.html │ └── util │ ├── ASMifier.java │ ├── ASMifierSupport.java │ ├── CheckAnnotationAdapter.java │ ├── CheckClassAdapter.java │ ├── CheckFieldAdapter.java │ ├── CheckMethodAdapter.java │ ├── CheckModuleAdapter.java │ ├── CheckSignatureAdapter.java │ ├── Printer.java │ ├── Textifier.java │ ├── TextifierSupport.java │ ├── TraceAnnotationVisitor.java │ ├── TraceClassVisitor.java │ ├── TraceFieldVisitor.java │ ├── TraceMethodVisitor.java │ ├── TraceModuleVisitor.java │ ├── TraceSignatureVisitor.java │ └── package.html └── resources ├── locale ├── de.xml ├── en.xml ├── es.xml ├── pt-br.xml ├── ru.xml ├── zh-cn.xml ├── zh-tr.xml └── zh.xml └── resources ├── LICENSES ├── access ├── abstract.png ├── final.png ├── native.png ├── static.png └── synthetic.png ├── classtype ├── enum.png └── interface.png ├── file.png ├── html └── optable.html ├── icon_close.png ├── jar.png ├── java.png ├── krakatau.zip ├── method ├── methdef.png ├── methpri.png ├── methpro.png └── methpub.png ├── package.png ├── search.png ├── toolbar ├── load.png ├── plug.png ├── refresh.png ├── save.png ├── search.png └── table.png ├── txt.png └── warning.png /.idea/$PRODUCT_WORKSPACE_FILE$: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 1.8 8 | 9 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /workspace.xml -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | JByteMod -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/discord.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__club_minnced_discord_rpc_release_v3_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__club_minnced_java_discord_rpc_2_0_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fifesoft_rsyntaxtextarea_2_6_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_google_code_gson_gson_2_8_5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_google_errorprone_error_prone_annotations_2_3_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_google_guava_failureaccess_1_0_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_google_guava_guava_28_1_jre.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_google_guava_listenablefuture_9999_0_empty_to_avoid_conflict_with_guava.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_google_j2objc_j2objc_annotations_1_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_sun_attach_1_7.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_weblaf_weblaf_1_2_9.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__commons_cli_commons_cli_1_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__commons_io_commons_io_2_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__net_java_dev_jna_jna_4_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_ant_ant_1_10_5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_ant_ant_launcher_1_10_5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_benf_cfr_0_146.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_bitbucket_mstrobel_procyon_compilertools_0_5_36.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_bitbucket_mstrobel_procyon_core_0_5_36.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_bitbucket_mstrobel_procyon_expressions_0_5_36.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_bitbucket_mstrobel_procyon_reflection_0_5_36.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_checkerframework_checker_qual_2_8_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_codehaus_mojo_animal_sniffer_annotations_1_18.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_jetbrains_annotations_13_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_stdlib_1_3_50.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_50.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_3_50.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_stdlib_jdk8_1_3_50.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_test_1_3_50.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_jetbrains_kotlin_kotlin_test_common_1_3_50.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_jfree_jfreechart_1_5_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_tinyjee_jgraphx_jgraphx_3_4_1_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | 14 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JByteMod-Reborn 2 | A fork of JByteMod, but makes it reborn. 3 | 4 | # Contributors 5 | GraxCode, UltraPanda, Ho3 6 | -------------------------------------------------------------------------------- /lib/attach-1.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/lib/attach-1.7.jar -------------------------------------------------------------------------------- /lib/cfr_0_146.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/lib/cfr_0_146.jar -------------------------------------------------------------------------------- /lib/procyon-0.5.36.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/lib/procyon-0.5.36.jar -------------------------------------------------------------------------------- /lib/weblaf-complete-1.29-fixed.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/lib/weblaf-complete-1.29-fixed.jar -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/ClassAssembly.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee 2 | 3 | import codes.som.anthony.koffee.insnsyntax.jvm.aload_0 4 | import codes.som.anthony.koffee.insnsyntax.jvm.invokespecial 5 | import codes.som.anthony.koffee.insnsyntax.jvm.return_void 6 | import org.objectweb.asm.ClassWriter 7 | import org.objectweb.asm.ClassWriter.COMPUTE_FRAMES 8 | import org.objectweb.asm.tree.ClassNode 9 | 10 | fun assemble(routine: ClassAssemblyContext.() -> Unit): ClassNode { 11 | val assemblyContext = ClassAssemblyContext() 12 | routine(assemblyContext) 13 | 14 | return assemblyContext.node 15 | } 16 | 17 | fun assemble(node: ClassNode): ByteArray { 18 | val writer = ClassWriter(COMPUTE_FRAMES) 19 | node.accept(writer) 20 | return writer.toByteArray() 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/InstructionAssembly.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee 2 | 3 | import org.objectweb.asm.tree.InsnList 4 | import org.objectweb.asm.tree.TryCatchBlockNode 5 | 6 | interface InsnASM : TypesAccess, ModifiersAccess { val instructions: InsnList } 7 | interface LabelScope { val L: LabelRegistry } 8 | 9 | interface LabelledASM : InsnASM, LabelScope 10 | 11 | interface TryCatchContainer { val tryCatchBlocks: MutableList } 12 | 13 | interface ASM : LabelledASM, TryCatchContainer 14 | 15 | fun ASM.scope(routine: LabelScope.() -> Unit) { 16 | val self = this 17 | 18 | routine(object : LabelScope { 19 | override val L = self.L.scope(instructions) 20 | }) 21 | } 22 | 23 | fun ASM.mergeFrom(asm: ASM, label: LabelWrapper) { 24 | instructions.insert(label.labelNode, asm.instructions) 25 | tryCatchBlocks.addAll(asm.tryCatchBlocks) 26 | } 27 | 28 | abstract class AbstractASMImpl(override val instructions: InsnList, 29 | override val tryCatchBlocks: MutableList) : ASM 30 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/InstructionBlockAssembly.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee 2 | 3 | import org.objectweb.asm.tree.InsnList 4 | import org.objectweb.asm.tree.TryCatchBlockNode 5 | 6 | fun assembleBlock(routine: ASM.() -> Unit): Pair> { 7 | val instructions = InsnList() 8 | val labelRegistry = LabelRegistry(instructions) 9 | val tryCatchBlocks = mutableListOf() 10 | 11 | val asm = object : ASM { 12 | override val tryCatchBlocks = tryCatchBlocks 13 | override val instructions = instructions 14 | override val L = labelRegistry 15 | } 16 | 17 | routine(asm) 18 | 19 | return Pair(instructions, tryCatchBlocks) 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/LabelRegistry.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee 2 | 3 | import org.objectweb.asm.tree.InsnList 4 | import org.objectweb.asm.tree.LabelNode 5 | 6 | class LabelRegistry(private val instructions: InsnList) { 7 | private var labels = mutableMapOf() 8 | 9 | fun copy(instructions: InsnList): LabelRegistry { 10 | return LabelRegistry(instructions) 11 | .also { it.labels = this.labels } 12 | } 13 | 14 | fun scope(instructions: InsnList): LabelRegistry { 15 | return LabelRegistry(instructions) 16 | .also { it.labels.putAll(this.labels) } 17 | } 18 | 19 | operator fun get(index: Int) = this["label_$index"] 20 | operator fun get(name: String): KoffeeLabel { 21 | return KoffeeLabel(instructions, labels.getOrPut(name, ::LabelNode)) 22 | } 23 | } 24 | 25 | class KoffeeLabel(private val instructions: InsnList, override val labelNode: LabelNode) : LabelWrapper { 26 | operator fun unaryPlus() { 27 | instructions.add(labelNode) 28 | } 29 | } 30 | 31 | interface LabelWrapper { 32 | val labelNode: LabelNode 33 | } 34 | 35 | fun LabelNode.wrap(): LabelWrapper { 36 | val labelNode = this 37 | return object : LabelWrapper { 38 | override val labelNode = labelNode 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/MethodAssembly.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee 2 | 3 | import org.objectweb.asm.Opcodes 4 | import org.objectweb.asm.Type 5 | import org.objectweb.asm.tree.MethodNode 6 | 7 | fun assembleMethod(access: Modifiers, name: String, 8 | returnType: Type, vararg parameterTypes: Type, 9 | signature: String? = null, exceptions: Array? = null, 10 | routine: MethodAssemblyContext.() -> Unit): MethodNode { 11 | val descriptor = Type.getMethodDescriptor(returnType, *parameterTypes) 12 | 13 | val methodNode = MethodNode(Opcodes.ASM7, access.access, name, descriptor, signature, exceptions?.map { it.internalName }?.toTypedArray()) 14 | val methodAssemblyContext = MethodAssemblyContext(methodNode) 15 | routine(methodAssemblyContext) 16 | 17 | return methodNode 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/MethodAssemblyContext.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee 2 | 3 | import org.objectweb.asm.tree.InsnList 4 | import org.objectweb.asm.tree.MethodNode 5 | import org.objectweb.asm.tree.TryCatchBlockNode 6 | 7 | class MethodAssemblyContext(node: MethodNode) : AbstractASMImpl(node.instructions, node.tryCatchBlocks) { 8 | override val L = LabelRegistry(instructions) 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/TypesAccess.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee 2 | 3 | import org.objectweb.asm.Type 4 | import kotlin.reflect.KClass 5 | 6 | interface TypesAccess { 7 | val void get() = Type.VOID_TYPE 8 | val char get() = Type.CHAR_TYPE 9 | val byte get() = Type.BYTE_TYPE 10 | val short get() = Type.SHORT_TYPE 11 | val int get() = Type.INT_TYPE 12 | val float get() = Type.FLOAT_TYPE 13 | val long get() = Type.LONG_TYPE 14 | val double get() = Type.DOUBLE_TYPE 15 | val boolean get() = Type.BOOLEAN_TYPE 16 | 17 | fun type(kType: KClass<*>): Type { 18 | return Type.getType(kType.java) 19 | } 20 | 21 | fun type(descriptor: String): Type { 22 | return Type.getObjectType(descriptor) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/disassembler/ClassDisassembly.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee.disassembler 2 | 3 | import codes.som.anthony.koffee.disassembler.util.DisassemblyContext 4 | import codes.som.anthony.koffee.disassembler.util.SourceCodeGenerator 5 | import org.objectweb.asm.tree.ClassNode 6 | 7 | private fun classPrologue(codegen: SourceCodeGenerator) { 8 | with (codegen) { 9 | appendLine("import codes.som.anthony.koffee.assemble") 10 | appendLine("import codes.som.anthony.koffee.insnsyntax.jvm.*") 11 | append("\n") 12 | 13 | appendLine("assemble {") 14 | indent() 15 | } 16 | } 17 | 18 | public fun classEpilogue(codegen: SourceCodeGenerator) { 19 | with (codegen) { 20 | dedent() 21 | appendLine("}") 22 | } 23 | } 24 | 25 | fun disassemble(node: ClassNode): String { 26 | val codegen = SourceCodeGenerator() 27 | val context = DisassemblyContext(node.name) 28 | 29 | with (codegen) { 30 | classPrologue(codegen) 31 | appendLine("name = ${disassembleValue(node.name, context)}") 32 | appendLine("access = ${disassembleAccess(node.access)}") 33 | appendLine("version = ${disassembleValue(node.version, context)}") 34 | 35 | disassembleFields(node, codegen, context) 36 | disassembleMethods(node, codegen, context) 37 | 38 | classEpilogue(codegen) 39 | } 40 | 41 | return codegen.toString() 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/disassembler/FieldDisassembly.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee.disassembler 2 | 3 | import codes.som.anthony.koffee.disassembler.util.DisassemblyContext 4 | import codes.som.anthony.koffee.disassembler.util.SourceCodeGenerator 5 | import org.objectweb.asm.Type 6 | import org.objectweb.asm.tree.ClassNode 7 | import org.objectweb.asm.tree.FieldNode 8 | 9 | fun disassembleFields(node: ClassNode, codegen: SourceCodeGenerator, context: DisassemblyContext) { 10 | if (node.fields.size != 0) { 11 | codegen.append("\n") 12 | for (field in node.fields) { 13 | codegen.appendLine(disassembleField(field, context)) 14 | } 15 | } 16 | } 17 | 18 | fun disassembleField(field: FieldNode, context: DisassemblyContext) = 19 | "field(" + disassembleAccess(field.access) + ", " + 20 | disassembleType(Type.getType(field.desc), context) + ", " + 21 | disassembleValue(field.name, context) + 22 | if (field.signature != null || field.value != null) ", " + 23 | disassembleValue(field.signature, context) + ", " + 24 | disassembleValue(field.value, context) + ")" 25 | else ")" 26 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/disassembler/data/AccessFlagNameMap.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee.disassembler.data 2 | 3 | import org.objectweb.asm.Opcodes.* 4 | 5 | val accessFlagNameMap = mapOf( 6 | "public" to ACC_PUBLIC, "private" to ACC_PRIVATE, "protected" to ACC_PROTECTED, 7 | "static" to ACC_STATIC, "final" to ACC_FINAL, "_super" to ACC_SUPER, 8 | "synchronized" to ACC_SYNCHRONIZED, "open" to ACC_OPEN, "transitive" to ACC_TRANSITIVE, 9 | "volatile" to ACC_VOLATILE, "bridge" to ACC_BRIDGE, "static_phase" to ACC_STATIC_PHASE, 10 | "varargs" to ACC_VARARGS, "transient" to ACC_TRANSIENT, "native" to ACC_NATIVE, 11 | "_interface" to ACC_INTERFACE, "abstract" to ACC_ABSTRACT, "strict" to ACC_STRICT, 12 | "synthetic" to ACC_SYNTHETIC, "annotation" to ACC_ANNOTATION, "enum" to ACC_ENUM, 13 | "mandated" to ACC_MANDATED, "module" to ACC_MODULE 14 | ) 15 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/disassembler/util/DisassemblyContext.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee.disassembler.util 2 | 3 | class DisassemblyContext(val currentType: String?) 4 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/disassembler/util/SourceCodeGenerator.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee.disassembler.util 2 | 3 | import java.lang.StringBuilder 4 | 5 | class SourceCodeGenerator { 6 | private var currentIndentation: Int = 0 7 | private val builder = StringBuilder() 8 | 9 | fun indent() { 10 | currentIndentation += 1 11 | } 12 | 13 | fun dedent() { 14 | currentIndentation -= 1 15 | } 16 | 17 | fun append(data: String) { 18 | builder.append(data) 19 | } 20 | 21 | fun appendIndentation() { 22 | builder.append(" ".repeat(currentIndentation)) 23 | } 24 | 25 | fun appendLine(line: String) { 26 | appendIndentation() 27 | builder.append(line) 28 | builder.append("\n") 29 | } 30 | 31 | override fun toString(): String { 32 | return builder.toString() 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/insnsyntax/jvm/Fields.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee.insnsyntax.jvm 2 | 3 | import codes.som.anthony.koffee.InsnASM 4 | import org.objectweb.asm.Opcodes.* 5 | import org.objectweb.asm.Type 6 | import org.objectweb.asm.tree.FieldInsnNode 7 | 8 | fun InsnASM.getstatic(owner: Type, name: String, type: Type) { 9 | instructions.add(FieldInsnNode(GETSTATIC, owner.internalName, name, type.descriptor)) 10 | } 11 | fun InsnASM.getfield(owner: Type, name: String, type: Type) { 12 | instructions.add(FieldInsnNode(GETFIELD, owner.internalName, name, type.descriptor)) 13 | } 14 | fun InsnASM.putstatic(owner: Type, name: String, type: Type) { 15 | instructions.add(FieldInsnNode(PUTSTATIC, owner.internalName, name, type.descriptor)) 16 | } 17 | fun InsnASM.putfield(owner: Type, name: String, type: Type) { 18 | instructions.add(FieldInsnNode(PUTFIELD, owner.internalName, name, type.descriptor)) 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/insnsyntax/jvm/InvokeDynamic.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee.insnsyntax.jvm 2 | 3 | import codes.som.anthony.koffee.InsnASM 4 | import org.objectweb.asm.Handle 5 | import org.objectweb.asm.Opcodes.* 6 | import org.objectweb.asm.Type 7 | import org.objectweb.asm.tree.InvokeDynamicInsnNode 8 | 9 | fun InsnASM.invokedynamic(name: String, returnType: Type, vararg parameterTypes: Type, handle: Handle, args: Array) { 10 | val descriptor = Type.getMethodDescriptor(returnType, *parameterTypes) 11 | instructions.add(InvokeDynamicInsnNode(name, descriptor, handle, *args)) 12 | } 13 | fun InsnASM.h_invokestatic(owner: Type, name: String, returnType: Type, vararg parameterTypes: Type): Handle { 14 | val descriptor = Type.getMethodDescriptor(returnType, *parameterTypes) 15 | return Handle(H_INVOKESTATIC, owner.internalName, name, descriptor, false) 16 | } 17 | fun InsnASM.h_invokevirtual(owner: Type, name: String, returnType: Type, vararg parameterTypes: Type): Handle { 18 | val descriptor = Type.getMethodDescriptor(returnType, *parameterTypes) 19 | return Handle(H_INVOKEVIRTUAL, owner.internalName, name, descriptor, false) 20 | } 21 | fun InsnASM.h_invokespecial(owner: Type, name: String, returnType: Type, vararg parameterTypes: Type): Handle { 22 | val descriptor = Type.getMethodDescriptor(returnType, *parameterTypes) 23 | return Handle(H_INVOKESPECIAL, owner.internalName, name, descriptor, false) 24 | } 25 | fun InsnASM.h_invokeinterface(owner: Type, name: String, returnType: Type, vararg parameterTypes: Type): Handle { 26 | val descriptor = Type.getMethodDescriptor(returnType, *parameterTypes) 27 | return Handle(H_INVOKEINTERFACE, owner.internalName, name, descriptor, true) 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/insnsyntax/jvm/JVMSyntax.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee.insnsyntax.jvm 2 | 3 | import codes.som.anthony.koffee.InsnASM 4 | import org.objectweb.asm.Opcodes.NOP 5 | import org.objectweb.asm.tree.InsnNode 6 | 7 | internal typealias U = Unit 8 | 9 | val InsnASM.nop: U get() { 10 | instructions.add(InsnNode(NOP)) 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/insnsyntax/jvm/Methods.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee.insnsyntax.jvm 2 | 3 | import codes.som.anthony.koffee.InsnASM 4 | import org.objectweb.asm.Opcodes.* 5 | import org.objectweb.asm.Type 6 | import org.objectweb.asm.tree.MethodInsnNode 7 | 8 | fun InsnASM.invokevirtual(owner: Type, name: String, returnType: Type, vararg parameterTypes: Type) { 9 | val descriptor = Type.getMethodDescriptor(returnType, *parameterTypes) 10 | instructions.add(MethodInsnNode(INVOKEVIRTUAL, owner.internalName, name, descriptor)) 11 | } 12 | fun InsnASM.invokespecial(owner: Type, name: String, returnType: Type, vararg parameterTypes: Type) { 13 | val descriptor = Type.getMethodDescriptor(returnType, *parameterTypes) 14 | instructions.add(MethodInsnNode(INVOKESPECIAL, owner.internalName, name, descriptor)) 15 | } 16 | fun InsnASM.invokestatic(owner: Type, name: String, returnType: Type, vararg parameterTypes: Type) { 17 | val descriptor = Type.getMethodDescriptor(returnType, *parameterTypes) 18 | instructions.add(MethodInsnNode(INVOKESTATIC, owner.internalName, name, descriptor)) 19 | } 20 | fun InsnASM.invokeinterface(owner: Type, name: String, returnType: Type, vararg parameterTypes: Type) { 21 | val descriptor = Type.getMethodDescriptor(returnType, *parameterTypes) 22 | instructions.add(MethodInsnNode(INVOKEINTERFACE, owner.internalName, name, descriptor)) 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/insnsyntax/jvm/ObjectManagement.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee.insnsyntax.jvm 2 | 3 | import codes.som.anthony.koffee.InsnASM 4 | import org.objectweb.asm.Opcodes.* 5 | import org.objectweb.asm.Type 6 | import org.objectweb.asm.tree.TypeInsnNode 7 | 8 | fun InsnASM.new(type: Type) { 9 | instructions.add(TypeInsnNode(NEW, type.internalName)) 10 | } 11 | fun InsnASM.checkcast(type: Type) { 12 | instructions.add(TypeInsnNode(CHECKCAST, type.internalName)) 13 | } 14 | fun InsnASM.instanceof(type: Type) { 15 | instructions.add(TypeInsnNode(INSTANCEOF, type.internalName)) 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/insnsyntax/jvm/StackManipulation.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee.insnsyntax.jvm 2 | 3 | import codes.som.anthony.koffee.InsnASM 4 | import org.objectweb.asm.Opcodes.* 5 | import org.objectweb.asm.tree.InsnNode 6 | 7 | val InsnASM.pop: U get() { 8 | instructions.add(InsnNode(POP)) 9 | } 10 | val InsnASM.pop2: U get() { 11 | instructions.add(InsnNode(POP2)) 12 | } 13 | val InsnASM.dup: U get() { 14 | instructions.add(InsnNode(DUP)) 15 | } 16 | val InsnASM.dup_x1: U get() { 17 | instructions.add(InsnNode(DUP_X1)) 18 | } 19 | val InsnASM.dup_x2: U get() { 20 | instructions.add(InsnNode(DUP_X2)) 21 | } 22 | val InsnASM.dup2: U get() { 23 | instructions.add(InsnNode(DUP2)) 24 | } 25 | val InsnASM.dup2_x1: U get() { 26 | instructions.add(InsnNode(DUP2_X1)) 27 | } 28 | val InsnASM.dup2_x2: U get() { 29 | instructions.add(InsnNode(DUP2_X2)) 30 | } 31 | val InsnASM.swap: U get() { 32 | instructions.add(InsnNode(SWAP)) 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/insnsyntax/jvm/SwitchConstruct.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee.insnsyntax.jvm 2 | 3 | import codes.som.anthony.koffee.InsnASM 4 | import codes.som.anthony.koffee.LabelWrapper 5 | import org.objectweb.asm.tree.LookupSwitchInsnNode 6 | import org.objectweb.asm.tree.TableSwitchInsnNode 7 | 8 | fun InsnASM.tableswitch(min: Int, max: Int, defaultLabel: LabelWrapper, vararg labels: LabelWrapper) { 9 | val labelNodes = Array(labels.size, { labels[it].labelNode }) 10 | instructions.add(TableSwitchInsnNode(min, max, defaultLabel.labelNode, *labelNodes)) 11 | } 12 | fun InsnASM.lookupswitch(defaultLabel: LabelWrapper, vararg branches: Pair) { 13 | val keys = IntArray(branches.size, { branches[it].first }) 14 | val labels = Array(branches.size, { branches[it].second.labelNode }) 15 | 16 | instructions.add(LookupSwitchInsnNode(defaultLabel.labelNode, keys, labels)) 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/insnsyntax/jvm/Synchronization.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee.insnsyntax.jvm 2 | 3 | import codes.som.anthony.koffee.InsnASM 4 | import org.objectweb.asm.Opcodes.* 5 | import org.objectweb.asm.tree.InsnNode 6 | 7 | val InsnASM.monitorenter: U get() { 8 | instructions.add(InsnNode(MONITORENTER)) 9 | } 10 | val InsnASM.monitorexit: U get() { 11 | instructions.add(InsnNode(MONITOREXIT)) 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/insnsyntax/sugar/IntegerLiterals.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee.insnsyntax.sugar 2 | 3 | import codes.som.anthony.koffee.InsnASM 4 | import codes.som.anthony.koffee.insnsyntax.jvm.* 5 | 6 | fun InsnASM.load_int(i: Int) { 7 | when (i) { 8 | -1 -> iconst_m1 9 | 0 -> iconst_0 10 | 1 -> iconst_1 11 | 2 -> iconst_2 12 | 3 -> iconst_3 13 | 4 -> iconst_4 14 | 5 -> iconst_5 15 | 16 | in Byte.MIN_VALUE .. Byte.MAX_VALUE -> bipush(i) 17 | in Short.MIN_VALUE .. Short.MAX_VALUE -> sipush(i) 18 | 19 | else -> ldc(i) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/codes/som/anthony/koffee/insnsyntax/sugar/LocalVariables.kt: -------------------------------------------------------------------------------- 1 | package codes.som.anthony.koffee.insnsyntax.sugar 2 | 3 | import codes.som.anthony.koffee.InsnASM 4 | import org.objectweb.asm.Opcodes.* 5 | import org.objectweb.asm.Type 6 | import org.objectweb.asm.tree.InsnNode 7 | import org.objectweb.asm.tree.VarInsnNode 8 | 9 | fun InsnASM.load(slot: Int, type: Type) { 10 | instructions.add(VarInsnNode(type.getOpcode(ILOAD), slot)) 11 | } 12 | 13 | fun InsnASM.store(slot: Int, type: Type) { 14 | instructions.add(VarInsnNode(type.getOpcode(ISTORE), slot)) 15 | } 16 | 17 | fun InsnASM.aload(type: Type) { 18 | instructions.add(InsnNode(type.getOpcode(IALOAD))) 19 | } 20 | 21 | fun InsnASM.astore(type: Type) { 22 | instructions.add(InsnNode(type.getOpcode(IASTORE))) 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/Value.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Sam Sun 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.javadeobfuscator.deobfuscator.analyzer; 18 | 19 | public class Value { 20 | public ValueType type; 21 | public String desc; 22 | 23 | public Value(ValueType type) { 24 | this(type, null); 25 | } 26 | 27 | public Value(ValueType type, String desc) { 28 | this.type = type; 29 | this.desc = desc; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/ValueType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Sam Sun 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.javadeobfuscator.deobfuscator.analyzer; 18 | 19 | import org.objectweb.asm.Type; 20 | 21 | public enum ValueType { 22 | TOP(null), 23 | INTEGER(Type.INT_TYPE), 24 | FLOAT(Type.FLOAT_TYPE), 25 | LONG(Type.LONG_TYPE), 26 | DOUBLE(Type.DOUBLE_TYPE), 27 | NULL(null), 28 | UNINITIALIZED_THIS(null), 29 | OBJECT(null), 30 | UNINITIALIZED(null); 31 | 32 | ValueType(Type type) { 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/ArgumentFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Sam Sun 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 18 | 19 | public class ArgumentFrame extends Frame { 20 | private int opcode; 21 | private int local; 22 | 23 | public ArgumentFrame(int opcode, int local) { 24 | super(-1); 25 | this.opcode = opcode; 26 | this.local = local; 27 | } 28 | 29 | public int getLocal() { 30 | return local; 31 | } 32 | 33 | public int getStoreOpcode() { 34 | return opcode; 35 | } 36 | 37 | // fixme how to determine? 38 | @Override 39 | public boolean isConstant() { 40 | return false; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/ArrayLengthFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Sam Sun 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 18 | 19 | import org.objectweb.asm.Opcodes; 20 | 21 | public class ArrayLengthFrame extends Frame { 22 | private Frame array; 23 | 24 | public ArrayLengthFrame(Frame array) { 25 | super(Opcodes.ARRAYLENGTH); 26 | this.array = array; 27 | this.array.children.add(this); 28 | this.parents.add(array); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/ArrayLoadFrame.java: -------------------------------------------------------------------------------- 1 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 2 | 3 | public class ArrayLoadFrame extends Frame { 4 | private Frame index; 5 | private Frame array; 6 | 7 | public ArrayLoadFrame(int opcode, Frame index, Frame array) { 8 | super(opcode); 9 | this.index = index; 10 | this.array = array; 11 | this.index.children.add(this); 12 | this.array.children.add(this); 13 | this.parents.add(this.index); 14 | this.parents.add(this.array); 15 | } 16 | 17 | public Frame getIndex() { 18 | return this.index; 19 | } 20 | 21 | public Frame getArray() { 22 | return this.array; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/ArrayStoreFrame.java: -------------------------------------------------------------------------------- 1 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 2 | 3 | public class ArrayStoreFrame extends Frame { 4 | 5 | private Frame object; 6 | private Frame index; 7 | private Frame array; 8 | 9 | public ArrayStoreFrame(int opcode, Frame object, Frame index, Frame array) { 10 | super(opcode); 11 | this.object = object; 12 | this.index = index; 13 | this.array = array; 14 | this.object.children.add(this); 15 | this.index.children.add(this); 16 | this.array.children.add(this); 17 | this.parents.add(this.object); 18 | this.parents.add(this.index); 19 | this.parents.add(this.array); 20 | } 21 | 22 | public Frame getObject(){ 23 | return this.object; 24 | } 25 | 26 | public Frame getIndex() { 27 | return this.index; 28 | } 29 | 30 | public Frame getArray() { 31 | return this.array; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/CheckCastFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Sam Sun 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 18 | 19 | import org.objectweb.asm.Opcodes; 20 | 21 | public class CheckCastFrame extends Frame { 22 | private Frame check; 23 | 24 | public CheckCastFrame(Frame check) { 25 | super(Opcodes.CHECKCAST); 26 | this.check = check; 27 | this.check.children.add(this); 28 | this.parents.add(this.check); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/DupFrame.java: -------------------------------------------------------------------------------- 1 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | public class DupFrame extends Frame { 7 | private List targets; 8 | 9 | public DupFrame(int opcode, Frame... targets) { 10 | super(opcode); 11 | this.targets = Arrays.asList(targets); 12 | for (Frame target : this.targets) { 13 | target.getChildren().add(this); 14 | } 15 | this.parents.addAll(this.targets); 16 | } 17 | 18 | public List getTargets() { 19 | return targets; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/InstanceofFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Sam Sun 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 18 | 19 | import org.objectweb.asm.Opcodes; 20 | 21 | public class InstanceofFrame extends Frame { 22 | private Frame check; 23 | 24 | public InstanceofFrame(Frame check) { 25 | super(Opcodes.INSTANCEOF); 26 | this.check = check; 27 | this.check.children.add(this); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/LdcFrame.java: -------------------------------------------------------------------------------- 1 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 2 | 3 | public class LdcFrame extends Frame { 4 | private Object cst; 5 | 6 | public LdcFrame(int opcode, Object cst) { 7 | super(opcode); 8 | this.cst = cst; 9 | } 10 | 11 | public Object getConstant() { 12 | return cst; 13 | } 14 | 15 | @Override 16 | public boolean isConstant() { 17 | return true; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/LocalFrame.java: -------------------------------------------------------------------------------- 1 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 2 | 3 | public class LocalFrame extends Frame { 4 | private int local; 5 | private Frame value; 6 | 7 | public LocalFrame(int opcode, int local, Frame value) { 8 | super(opcode); 9 | this.local = local; 10 | this.value = value; 11 | if (this.value != null) 12 | this.value.children.add(this); 13 | } 14 | 15 | public int getLocal() { 16 | return local; 17 | } 18 | 19 | public Frame getValue() { 20 | return value; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/MathFrame.java: -------------------------------------------------------------------------------- 1 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collection; 5 | import java.util.Collections; 6 | import java.util.List; 7 | 8 | public class MathFrame extends Frame { 9 | 10 | private List targets; 11 | 12 | public MathFrame(int opcode, Frame... targets) { 13 | super(opcode); 14 | this.targets = Arrays.asList(targets); 15 | for (Frame target : this.targets) { 16 | target.children.add(this); 17 | } 18 | } 19 | 20 | public List getTargets() { 21 | return Collections.unmodifiableList(targets); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/MonitorFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Sam Sun 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 18 | 19 | public class MonitorFrame extends Frame { 20 | private Frame target; 21 | 22 | public MonitorFrame(int opcode, Frame target) { 23 | super(opcode); 24 | this.target = target; 25 | this.target.children.add(this); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/MultiANewArrayFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Sam Sun 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 18 | 19 | import org.objectweb.asm.Opcodes; 20 | 21 | import java.util.List; 22 | 23 | public class MultiANewArrayFrame extends Frame { 24 | private List dims; 25 | 26 | public MultiANewArrayFrame(List dims) { 27 | super(Opcodes.MULTIANEWARRAY); 28 | this.dims = dims; 29 | for (Frame dim : this.dims) { 30 | dim.children.add(this); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/NewArrayFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Sam Sun 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 18 | 19 | public class NewArrayFrame extends Frame { 20 | private Frame length; 21 | private String ntype; 22 | 23 | public NewArrayFrame(int opcode, String type, Frame length) { 24 | super(opcode); 25 | this.length = length; 26 | this.ntype = type; 27 | 28 | this.length.children.add(this); 29 | } 30 | 31 | public Frame getLength() { 32 | return length; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/NewFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Sam Sun 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 18 | 19 | import org.objectweb.asm.Opcodes; 20 | 21 | public class NewFrame extends Frame { 22 | private String ntype; 23 | 24 | public NewFrame(String type) { 25 | super(Opcodes.NEW); 26 | this.ntype = type; 27 | } 28 | 29 | public String getType() { 30 | return this.ntype; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/PopFrame.java: -------------------------------------------------------------------------------- 1 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | 7 | public class PopFrame extends Frame { 8 | public List getRemoved() { 9 | return removed; 10 | } 11 | 12 | private List removed; 13 | 14 | public PopFrame(int opcode, Frame... removed) { 15 | super(opcode); 16 | this.removed = Arrays.asList(removed); 17 | this.removed.forEach(frame -> frame.children.add(this)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/ReturnFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Sam Sun 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 18 | 19 | public class ReturnFrame extends Frame { 20 | private Frame obj; 21 | 22 | public ReturnFrame(int opcode, Frame obj) { 23 | super(opcode); 24 | this.obj = obj; 25 | if (this.obj != null) { 26 | this.obj.children.add(this); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/SwapFrame.java: -------------------------------------------------------------------------------- 1 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 2 | 3 | import org.objectweb.asm.Opcodes; 4 | 5 | public class SwapFrame extends Frame { 6 | private Frame top; 7 | private Frame bottom; 8 | public SwapFrame(Frame top, Frame bottom) { 9 | super (Opcodes.SWAP); 10 | this.top = top; 11 | this.bottom = bottom; 12 | this.top.children.add(this); 13 | this.bottom.children.add(this); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/SwitchFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Sam Sun 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 18 | 19 | import org.objectweb.asm.tree.LabelNode; 20 | 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | public class SwitchFrame extends Frame { 25 | private Frame switchTarget; 26 | private List nodes = new ArrayList<>(); 27 | 28 | public SwitchFrame(int opcode, Frame switchTarget, List nodes, LabelNode dflt) { 29 | super(opcode); 30 | this.switchTarget = switchTarget; 31 | this.nodes.addAll(nodes); 32 | this.nodes.add(dflt); 33 | 34 | this.switchTarget.children.add(this); 35 | } 36 | 37 | public Frame getSwitchTarget() { 38 | return this.switchTarget; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/analyzer/frame/ThrowFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Sam Sun 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.javadeobfuscator.deobfuscator.analyzer.frame; 18 | 19 | import org.objectweb.asm.Opcodes; 20 | 21 | public class ThrowFrame extends Frame { 22 | 23 | private Frame throwable; 24 | 25 | public ThrowFrame(Frame throwable) { 26 | super(Opcodes.ATHROW); 27 | this.throwable = throwable; 28 | this.throwable.children.add(this); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/javadeobfuscator/deobfuscator/utils/ClassTree.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Sam Sun 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.javadeobfuscator.deobfuscator.utils; 18 | 19 | import java.util.ArrayList; 20 | import java.util.HashSet; 21 | import java.util.List; 22 | import java.util.Set; 23 | 24 | public class ClassTree { 25 | public String thisClass; 26 | 27 | public Set subClasses = new HashSet<>(); 28 | public Set parentClasses = new HashSet<>(); 29 | 30 | public ClassTree(String thisClass) { 31 | this.thisClass = thisClass; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/hakery/club/raccscanner/logger/RaccoonLogger.java: -------------------------------------------------------------------------------- 1 | package hakery.club.raccscanner.logger; 2 | 3 | import java.io.OutputStream; 4 | import java.util.Formatter; 5 | 6 | public class RaccoonLogger { 7 | 8 | private OutputStream targetOutputStream; 9 | 10 | public RaccoonLogger(OutputStream targetOutputStream) { 11 | this.targetOutputStream = targetOutputStream; 12 | } 13 | 14 | public RaccoonLogger() { 15 | this.targetOutputStream = System.out; 16 | } 17 | 18 | public void newLine() { 19 | try { 20 | this.targetOutputStream.write("\n".getBytes()); 21 | this.targetOutputStream.flush(); 22 | } catch (Exception e) { 23 | e.printStackTrace(); 24 | } 25 | } 26 | 27 | public void log(String format, Object... formatting) { 28 | String message = new Formatter().format(format, formatting).toString(); 29 | this.log(message); 30 | } 31 | 32 | public void log(String message) { 33 | try { 34 | String msg = "[Raccoon] " + message; 35 | this.targetOutputStream.write(msg.getBytes()); 36 | this.newLine(); 37 | this.targetOutputStream.flush(); 38 | } catch (Exception e) { 39 | e.printStackTrace(); 40 | } 41 | } 42 | 43 | public void setTargetOutputStream(OutputStream targetOutputStream) { 44 | this.targetOutputStream = targetOutputStream; 45 | } 46 | 47 | public void error(String message) { 48 | try { 49 | String msg = "[Error] " + message; 50 | this.log(msg); 51 | } catch (Exception e) { 52 | e.printStackTrace(); 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/hakery/club/raccscanner/results/util/Obfuscator.java: -------------------------------------------------------------------------------- 1 | package hakery.club.raccscanner.results.util; 2 | 3 | public enum Obfuscator { 4 | PARAMORPHISM, 5 | ALLATORI, 6 | STRINGER, 7 | DASHO, 8 | OTHER 9 | } -------------------------------------------------------------------------------- /src/main/java/hakery/club/raccscanner/results/util/result/impl/AllatoriResult.java: -------------------------------------------------------------------------------- 1 | package hakery.club.raccscanner.results.util.result.impl; 2 | 3 | import hakery.club.raccscanner.Raccoon; 4 | import hakery.club.raccscanner.results.util.Obfuscator; 5 | import hakery.club.raccscanner.results.util.result.ObfuscatorResult; 6 | import hakery.club.raccscanner.scanner.impl.obfuscators.allatori.AllatoriStringEncryptionScanner; 7 | import org.objectweb.asm.tree.ClassNode; 8 | 9 | import java.util.ArrayList; 10 | 11 | public class AllatoriResult extends ObfuscatorResult { 12 | 13 | private AllatoriStringEncryptionScanner stringEncryptionScanner; 14 | 15 | public AllatoriResult(Raccoon raccoon) { 16 | super(Obfuscator.ALLATORI, raccoon); 17 | } 18 | 19 | @Override 20 | public void parse() { 21 | this.stringEncryptionScanner = (AllatoriStringEncryptionScanner) getScanner(AllatoriStringEncryptionScanner.class); 22 | 23 | if (stringEncryptionScanner.getResult().size() > 2) 24 | this.increasePercentage(50); 25 | } 26 | 27 | public ArrayList getStringEncryptionResult() { 28 | return this.stringEncryptionScanner.getResult(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/hakery/club/raccscanner/results/util/result/impl/DashOResult.java: -------------------------------------------------------------------------------- 1 | package hakery.club.raccscanner.results.util.result.impl; 2 | 3 | import hakery.club.raccscanner.Raccoon; 4 | import hakery.club.raccscanner.results.util.Obfuscator; 5 | import hakery.club.raccscanner.results.util.result.ObfuscatorResult; 6 | import hakery.club.raccscanner.scanner.impl.obfuscators.dasho.DashOStringEncryptionScanner; 7 | import org.objectweb.asm.tree.ClassNode; 8 | 9 | import java.util.ArrayList; 10 | 11 | public class DashOResult extends ObfuscatorResult { 12 | 13 | DashOStringEncryptionScanner dashOStringEncryptionScanner; 14 | 15 | public DashOResult(Raccoon raccoon) { 16 | super(Obfuscator.DASHO, raccoon); 17 | } 18 | 19 | @Override 20 | public void parse() { 21 | this.dashOStringEncryptionScanner = (DashOStringEncryptionScanner) this.getScanner(DashOStringEncryptionScanner.class); 22 | 23 | if (this.dashOStringEncryptionScanner.getResult().size() >= 2) 24 | increasePercentage(50); 25 | } 26 | 27 | public ArrayList getStringEncryptionResult() { 28 | return this.dashOStringEncryptionScanner.getResult(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/hakery/club/raccscanner/scanner/Scanner.java: -------------------------------------------------------------------------------- 1 | package hakery.club.raccscanner.scanner; 2 | 3 | import hakery.club.raccscanner.Raccoon; 4 | 5 | public abstract class Scanner { 6 | 7 | protected Raccoon raccoon; 8 | private T result; 9 | 10 | private int flagsReached; 11 | 12 | public Scanner() { 13 | } 14 | 15 | public abstract boolean scan(); 16 | 17 | public T getResult() { 18 | return this.result; 19 | } 20 | 21 | protected void setResult(T result) { 22 | this.result = result; 23 | } 24 | 25 | public int getFlagsReached() { 26 | return flagsReached; 27 | } 28 | 29 | public void incrementFlagsReached() { 30 | this.flagsReached++; 31 | } 32 | 33 | public void incrementFlagsReached(int inc) { 34 | this.flagsReached += inc; 35 | } 36 | 37 | public void reset() { 38 | this.flagsReached = 0; 39 | } 40 | 41 | public String getResultAsString() { 42 | return null; 43 | } 44 | 45 | public void log(String format, Object... formatting) { 46 | this.raccoon.getLogger().log("[" + this.getClass().getName().substring(this.getClass().getName().lastIndexOf('.') + 1) + "] " + format, formatting); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/hakery/club/raccscanner/scanner/impl/classes/ClassCountScanner.java: -------------------------------------------------------------------------------- 1 | package hakery.club.raccscanner.scanner.impl.classes; 2 | 3 | import hakery.club.raccscanner.scanner.Scanner; 4 | 5 | public class ClassCountScanner extends Scanner { 6 | 7 | @Override 8 | public boolean scan() { 9 | //TODO: Filter out invalid classes 10 | this.setResult(raccoon.getClasses().size()); 11 | 12 | if (raccoon.isDebugging()) 13 | log("Found %d classes", this.getResult()); 14 | 15 | return true; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/hakery/club/raccscanner/scanner/impl/classes/DebugInfoScanner.java: -------------------------------------------------------------------------------- 1 | package hakery.club.raccscanner.scanner.impl.classes; 2 | 3 | import hakery.club.raccscanner.scanner.Scanner; 4 | import hakery.club.raccscanner.util.SourceFileData; 5 | 6 | import java.util.ArrayList; 7 | 8 | /*** 9 | * Shoutout to myself for knowing it was the SourceFileAttribute but thinking 10 | * it would be sourceDebug 11 | */ 12 | public class DebugInfoScanner extends Scanner> { 13 | 14 | @Override 15 | public boolean scan() { 16 | ArrayList tmp = new ArrayList<>(); 17 | raccoon.getClasses().forEach((name, node) -> { 18 | if (node.sourceFile != null 19 | && node.sourceFile.length() > 0 20 | && node.sourceFile.endsWith(".java") 21 | && !name.contains(node.sourceFile.replace(".java", ""))) { 22 | raccoon.setDebugInfoFound(true); 23 | 24 | tmp.add(new SourceFileData(node, node.sourceFile)); 25 | 26 | if (raccoon.isDebugging()) { 27 | log("Found debug info %s -> %s", name, node.sourceFile); 28 | } 29 | } 30 | }); 31 | 32 | this.setResult(tmp); 33 | 34 | return true; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/hakery/club/raccscanner/scanner/impl/debugging/DebugScanner.java: -------------------------------------------------------------------------------- 1 | package hakery.club.raccscanner.scanner.impl.debugging; 2 | 3 | import com.sun.org.apache.xpath.internal.operations.String; 4 | import hakery.club.raccscanner.scanner.Scanner; 5 | import me.lpk.util.ASMUtils; 6 | import org.objectweb.asm.ClassWriter; 7 | 8 | public class DebugScanner extends Scanner { 9 | 10 | @Override 11 | public boolean scan() { 12 | raccoon.getClasses().forEach((name, node) -> { 13 | System.out.println(name); 14 | node.methods.forEach(methodNode -> System.out.println(methodNode.name)); 15 | }); 16 | 17 | return true; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/hakery/club/raccscanner/scanner/impl/jar/JarSizeScanner.java: -------------------------------------------------------------------------------- 1 | package hakery.club.raccscanner.scanner.impl.jar; 2 | 3 | import hakery.club.raccscanner.scanner.Scanner; 4 | 5 | public class JarSizeScanner extends Scanner { 6 | 7 | @Override 8 | public boolean scan() { 9 | this.setResult(raccoon.getTargetFile().length()); 10 | 11 | if (raccoon.isDebugging()) 12 | log("Jar is %o bytes", this.getResult()); 13 | 14 | return true; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/hakery/club/raccscanner/scanner/impl/obfuscators/paramorphism/ParamorphismManifestScanner.java: -------------------------------------------------------------------------------- 1 | package hakery.club.raccscanner.scanner.impl.obfuscators.paramorphism; 2 | 3 | import hakery.club.raccscanner.scanner.Scanner; 4 | import hakery.club.raccscanner.util.DataUtils; 5 | 6 | /** 7 | * Paramorphism leaves 8 | * "Obfuscated by: Paramorphism" in the manifest, can be removed 9 | */ 10 | public class ParamorphismManifestScanner extends Scanner { 11 | @Override 12 | public boolean scan() { 13 | setResult(false); 14 | if (raccoon.getJarManifest() != null) { 15 | byte[] paramorphismByteArray = "Paramorphism".getBytes(); 16 | if (DataUtils.INSTANCE.findInByteArray(paramorphismByteArray, raccoon.getJarManifest())) { 17 | log("Paramorphism was found in Manifest file."); 18 | setResult(true); 19 | } 20 | } 21 | 22 | return raccoon.getJarManifest() != null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/hakery/club/raccscanner/scanner/impl/obfuscators/stringer/StringerManifestScanner.java: -------------------------------------------------------------------------------- 1 | package hakery.club.raccscanner.scanner.impl.obfuscators.stringer; 2 | 3 | import hakery.club.raccscanner.scanner.Scanner; 4 | import hakery.club.raccscanner.util.DataUtils; 5 | 6 | public class StringerManifestScanner extends Scanner { 7 | @Override 8 | public boolean scan() { 9 | setResult(false); 10 | 11 | if (raccoon.getJarManifest() != null) { 12 | byte[] email = "AV contact email".getBytes(); 13 | byte[] stringer = "Stringer".getBytes(); 14 | if (DataUtils.INSTANCE.findInByteArray(email, raccoon.getJarManifest()) 15 | || DataUtils.INSTANCE.findInByteArray(stringer, raccoon.getJarManifest())) { 16 | log("Stringer was found in Manifest file."); 17 | setResult(true); 18 | } 19 | } 20 | 21 | return raccoon.getJarManifest() != null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/hakery/club/raccscanner/util/DataUtils.java: -------------------------------------------------------------------------------- 1 | package hakery.club.raccscanner.util; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.InputStream; 5 | 6 | public enum DataUtils { 7 | INSTANCE; 8 | 9 | public byte[] toByteArray(InputStream is) { 10 | try { 11 | ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 12 | int nRead; 13 | 14 | byte[] data = new byte[1024 * 4 * 4]; 15 | while ((nRead = is.read(data, 0, data.length)) != -1) { 16 | buffer.write(data, 0, nRead); 17 | } 18 | 19 | return buffer.toByteArray(); 20 | } catch (Exception e) { 21 | e.printStackTrace(); 22 | } 23 | return null; 24 | } 25 | 26 | public boolean compareSectionOfByteArray(byte[] toFind, byte[] src, int offset) { 27 | int searchLen = toFind.length; 28 | 29 | for (int i = 0; i < searchLen; i++) { 30 | byte from = toFind[i]; 31 | byte original = src[i + offset]; 32 | 33 | if (from != original) 34 | return false; 35 | } 36 | return true; 37 | } 38 | 39 | public boolean findInByteArray(byte[] toFind, byte[] src) { 40 | if (toFind.length > src.length) 41 | return false; 42 | 43 | /* loop over every instruction in the source */ 44 | for (int i = 0; i < src.length; i++) { 45 | if (compareSectionOfByteArray(toFind, src, i)) 46 | return true; 47 | } 48 | 49 | return false; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/hakery/club/raccscanner/util/SourceFileData.java: -------------------------------------------------------------------------------- 1 | package hakery.club.raccscanner.util; 2 | 3 | import org.objectweb.asm.tree.ClassNode; 4 | 5 | public class SourceFileData { 6 | 7 | private final String name; 8 | private final ClassNode node; 9 | 10 | public SourceFileData(ClassNode classNode, String name) { 11 | this.name = name; 12 | this.node = classNode; 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public ClassNode getNode() { 20 | return node; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/hakery/club/raccscanner/util/opcodes/InstructionList.java: -------------------------------------------------------------------------------- 1 | package hakery.club.raccscanner.util.opcodes; 2 | 3 | import org.objectweb.asm.tree.InsnList; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Arrays; 7 | import java.util.List; 8 | 9 | public class InstructionList { 10 | 11 | private final ArrayList opcodes = new ArrayList<>(); 12 | 13 | public InstructionList(InsnList insnList) { 14 | /* fill the opcodes */ 15 | Arrays.stream(insnList.toArray()).forEach(abstractInsnNode -> opcodes.add(abstractInsnNode.getOpcode())); 16 | } 17 | 18 | public InstructionList(List list) { 19 | list.stream().forEach(integer -> opcodes.add(integer)); 20 | } 21 | 22 | public InstructionList(int[] opcodes) { 23 | for (int opcode : opcodes) 24 | this.opcodes.add(opcode); 25 | } 26 | 27 | public int size() { 28 | return this.opcodes.size(); 29 | } 30 | 31 | public int get(int idx) { 32 | return this.opcodes.get(idx); 33 | } 34 | 35 | public boolean isReplaceable(int idx) { 36 | return this.opcodes.get(idx) == 0xFF; 37 | } 38 | 39 | public ArrayList getOpcodes() { 40 | return opcodes; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/ClassDefinition.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler; 2 | 3 | public class ClassDefinition { 4 | private String name; 5 | 6 | public ClassDefinition(String name) { 7 | super(); 8 | if (name.startsWith("L") && name.endsWith(";")) { 9 | this.name = name.substring(1, name.length() - 1); 10 | } else { 11 | this.name = name; 12 | } 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | 23 | public String getShortName() { 24 | if (!name.contains("/")) { 25 | return name; 26 | } 27 | return name.substring(name.lastIndexOf("/") + 1); 28 | } 29 | 30 | public String getSourceName() { 31 | return name.replace('/', '.'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/TabbedStringBuffer.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code; 2 | 3 | public class TabbedStringBuffer { 4 | public int tabs; 5 | private StringBuilder sb = new StringBuilder(); 6 | 7 | public void append(String s) { 8 | sb.append(s); 9 | } 10 | 11 | public void indent() { 12 | for (int i = 0; i < tabs; i++) { 13 | sb.append(" "); 14 | } 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return sb.toString(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/AstColors.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast; 2 | 3 | public class AstColors { 4 | public static final String edgeColor = "#111111"; 5 | public static final String jumpColor = "#39698a"; 6 | 7 | public static final String jumpColorGreen = "#388a47"; 8 | public static final String jumpColorRed = "#8a3e38"; 9 | public static final String jumpColorPurple = "#71388a"; 10 | public static final String jumpColorPink = "#ba057a"; //8a386d 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/Comparison.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast; 2 | 3 | public enum Comparison { 4 | IS("=="), ISNOT("!="), LOWER("<"), LOWEREQUALS("<="), GREATER(">"), GREATEREQUALS(">="); 5 | 6 | private String symbol; 7 | 8 | private Comparison(String symbol) { 9 | this.symbol = symbol; 10 | } 11 | 12 | public String getSymbol() { 13 | return symbol; 14 | } 15 | 16 | public void setSymbol(String symbol) { 17 | this.symbol = symbol; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/EndBlock.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast; 2 | 3 | public enum EndBlock { 4 | CONTINUE, BREAK; 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/Expression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast; 2 | 3 | public abstract class Expression { 4 | public abstract String toString(); 5 | 6 | public abstract int size(); 7 | 8 | public abstract Expression clone(); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/VarType.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast; 2 | 3 | public enum VarType { 4 | INT("int"), FLOAT("float"), LONG("long"), DOUBLE("double"), OBJECT("Object"), VOID("void"), BOOLEAN("boolean"), CHAR("char"), BYTE("byte"), SHORT( 5 | "short"); 6 | private String type; 7 | 8 | VarType(String type) { 9 | this.type = type; 10 | } 11 | 12 | public static VarType ofDesc(String desc) { 13 | if (desc.contains(")")) { 14 | desc = desc.substring(desc.lastIndexOf(')') + 1); 15 | } 16 | if (desc.endsWith(";") || desc.contains("[")) 17 | return OBJECT; 18 | if (desc.endsWith("V")) 19 | return VOID; 20 | if (desc.endsWith("F")) 21 | return FLOAT; 22 | if (desc.endsWith("J")) 23 | return LONG; 24 | if (desc.endsWith("D")) 25 | return DOUBLE; 26 | if (desc.endsWith("Z")) 27 | return BOOLEAN; 28 | if (desc.endsWith("C")) 29 | return CHAR; 30 | if (desc.endsWith("B")) 31 | return BYTE; 32 | if (desc.endsWith("S")) 33 | return SHORT; 34 | return INT; 35 | } 36 | 37 | public String getType() { 38 | return type; 39 | } 40 | 41 | public void setType(String type) { 42 | this.type = type; 43 | } 44 | 45 | public int size() { 46 | return (this == VarType.LONG || this == VarType.DOUBLE) ? 2 : 1; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/ArrayIndexExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.utils.InstrUtils; 5 | import me.grax.jbytemod.utils.TextUtils; 6 | 7 | public class ArrayIndexExpression extends Expression { 8 | 9 | private Expression array; 10 | private Expression index; 11 | private boolean twoword; 12 | 13 | public ArrayIndexExpression(Expression array, Expression index, boolean twoword) { 14 | super(); 15 | this.array = array; 16 | this.index = index; 17 | this.twoword = twoword; 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return TextUtils.addTag(array.toString(), "font color=" + InstrUtils.primColor.getString()) + "[" + index + "]"; 23 | } 24 | 25 | @Override 26 | public int size() { 27 | return twoword ? 2 : 1; 28 | } 29 | 30 | @Override 31 | public Expression clone() { 32 | return new ArrayIndexExpression(array.clone(), index.clone(), twoword); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/ArrayStoreExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.utils.InstrUtils; 5 | import me.grax.jbytemod.utils.TextUtils; 6 | 7 | public class ArrayStoreExpression extends Expression { 8 | private Expression array; 9 | private Expression index; 10 | private Expression value; 11 | 12 | public ArrayStoreExpression(Expression array, Expression index, Expression value) { 13 | super(); 14 | this.array = array; 15 | this.index = index; 16 | this.value = value; 17 | 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return TextUtils.addTag(array.toString(), "font color=" + InstrUtils.primColor.getString()) + "[" + index + "]" + " = " + value; 23 | } 24 | 25 | @Override 26 | public int size() { 27 | return 0; 28 | } 29 | 30 | @Override 31 | public Expression clone() { 32 | return new ArrayStoreExpression(array.clone(), index.clone(), value.clone()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/ClassTypeExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | 5 | public class ClassTypeExpression extends Expression { 6 | 7 | private String object; 8 | 9 | public ClassTypeExpression(String object) { 10 | this.object = object; 11 | } 12 | 13 | @Override 14 | public String toString() { 15 | return object + ".class"; 16 | } 17 | 18 | @Override 19 | public int size() { 20 | return 1; 21 | } 22 | 23 | @Override 24 | public Expression clone() { 25 | return new ClassTypeExpression(object); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/DebugStackAssignExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.utils.TextUtils; 5 | 6 | public class DebugStackAssignExpression extends Expression { 7 | 8 | private int var; 9 | private Expression value; 10 | private String prefix; 11 | 12 | public DebugStackAssignExpression(int var, Expression value) { 13 | this(var, value, "stack"); 14 | } 15 | 16 | public DebugStackAssignExpression(int var, Expression value, String prefix) { 17 | this.var = var; 18 | this.value = value; 19 | this.prefix = prefix; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return TextUtils.addTag("" + prefix + var + "", "font color=#909011") + " = " + value; 25 | } 26 | 27 | @Override 28 | public int size() { 29 | return 0; 30 | } 31 | 32 | public String getPrefix() { 33 | return prefix; 34 | } 35 | 36 | public void setPrefix(String prefix) { 37 | this.prefix = prefix; 38 | } 39 | 40 | @Override 41 | public Expression clone() { 42 | return new DebugStackAssignExpression(var, value.clone(), prefix); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/DebugStackUnknownExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.VarType; 5 | import me.grax.jbytemod.utils.TextUtils; 6 | 7 | public class DebugStackUnknownExpression extends Expression { 8 | 9 | private int var; 10 | private int size; 11 | private VarType type; 12 | 13 | public DebugStackUnknownExpression(int var, int size, VarType type) { 14 | this.var = var; 15 | this.size = size; 16 | this.type = type; 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return TextUtils.addTag("unkn_stack_" + var + "", "font color=#997755"); 22 | } 23 | 24 | @Override 25 | public int size() { 26 | return size; 27 | } 28 | 29 | @Override 30 | public Expression clone() { 31 | return new DebugStackUnknownExpression(var, size, type); 32 | } 33 | 34 | public int getVar() { 35 | return var; 36 | } 37 | 38 | public void setVar(int var) { 39 | this.var = var; 40 | } 41 | 42 | public int getSize() { 43 | return size; 44 | } 45 | 46 | public void setSize(int size) { 47 | this.size = size; 48 | } 49 | 50 | public VarType getType() { 51 | return type; 52 | } 53 | 54 | public void setType(VarType type) { 55 | this.type = type; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/IncrementExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.utils.InstrUtils; 5 | import me.grax.jbytemod.utils.TextUtils; 6 | 7 | public class IncrementExpression extends Expression { 8 | private Expression object; 9 | private int increment; 10 | 11 | public IncrementExpression(Expression object, int increment) { 12 | super(); 13 | this.object = object; 14 | this.increment = increment; 15 | } 16 | 17 | public Expression getObject() { 18 | return object; 19 | } 20 | 21 | public void setObject(Expression object) { 22 | this.object = object; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return TextUtils.addTag(object.toString(), "font color=" + InstrUtils.primColor.getString()) + " += " + increment; 28 | } 29 | 30 | @Override 31 | public int size() { 32 | return 0; 33 | } 34 | 35 | @Override 36 | public Expression clone() { 37 | return new IncrementExpression(object.clone(), increment); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/InstanceofExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.ClassDefinition; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 5 | 6 | public class InstanceofExpression extends Expression { 7 | 8 | private Expression object; 9 | private ClassDefinition classDef; 10 | 11 | public InstanceofExpression(Expression object, ClassDefinition classDef) { 12 | super(); 13 | this.object = object; 14 | this.classDef = classDef; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return object.toString() + " instanceof " + classDef.getName(); 20 | } 21 | 22 | @Override 23 | public int size() { 24 | return 1; 25 | } 26 | 27 | @Override 28 | public Expression clone() { 29 | return new InstanceofExpression(object.clone(), classDef); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/LookupSwitchExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | 5 | public class LookupSwitchExpression extends Expression { 6 | 7 | private Expression toSwitch; 8 | private int size; 9 | 10 | public LookupSwitchExpression(Expression toSwitch, int size) { 11 | this.toSwitch = toSwitch; 12 | this.size = size; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return "switch(" + toSwitch + ") " + size + " cases"; 18 | } 19 | 20 | @Override 21 | public int size() { 22 | return 1; 23 | } 24 | 25 | @Override 26 | public Expression clone() { 27 | return new LookupSwitchExpression(toSwitch.clone(), size); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/NewArrayExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.ClassDefinition; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 5 | import me.grax.jbytemod.utils.InstrUtils; 6 | import me.grax.jbytemod.utils.TextUtils; 7 | 8 | public class NewArrayExpression extends Expression { 9 | private Expression count; 10 | private ClassDefinition object; 11 | 12 | public NewArrayExpression(Expression count, ClassDefinition object) { 13 | super(); 14 | this.count = count; 15 | this.object = object; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return "new " + TextUtils.addTag(object.getName(), "font color=" + InstrUtils.secColor.getString()) + "[" + count + "]"; 21 | } 22 | 23 | @Override 24 | public int size() { 25 | return 1; 26 | } 27 | 28 | @Override 29 | public Expression clone() { 30 | return new NewArrayExpression(count.clone(), object); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/NewPrimArrayExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.VarType; 5 | import me.grax.jbytemod.utils.InstrUtils; 6 | import me.grax.jbytemod.utils.TextUtils; 7 | 8 | public class NewPrimArrayExpression extends Expression { 9 | private Expression count; 10 | private VarType type; 11 | 12 | public NewPrimArrayExpression(Expression count, VarType type) { 13 | super(); 14 | this.count = count; 15 | this.type = type; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return "new " + TextUtils.addTag(type.getType(), "font color=" + InstrUtils.secColor.getString()) + "[" + count + "]"; 21 | } 22 | 23 | @Override 24 | public int size() { 25 | return 1; 26 | } 27 | 28 | @Override 29 | public Expression clone() { 30 | return new NewPrimArrayExpression(count.clone(), type); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/NotExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | 5 | public class NotExpression extends Expression { 6 | private Expression toNegate; 7 | 8 | public NotExpression(Expression toNegate) { 9 | super(); 10 | this.toNegate = toNegate; 11 | } 12 | 13 | public Expression getToNegate() { 14 | return toNegate; 15 | } 16 | 17 | public void setToNegate(Expression toNegate) { 18 | this.toNegate = toNegate; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "!(" + toNegate.toString() + ")"; 24 | } 25 | 26 | @Override 27 | public int size() { 28 | return toNegate.size(); 29 | } 30 | 31 | @Override 32 | public Expression clone() { 33 | return new NotExpression(toNegate.clone()); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/NullExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.defs.Keywords; 5 | 6 | public class NullExpression extends Expression { 7 | 8 | @Override 9 | public String toString() { 10 | return "" + Keywords.NULL + ""; 11 | } 12 | 13 | @Override 14 | public int size() { 15 | return 1; 16 | } 17 | 18 | @Override 19 | public Expression clone() { 20 | return new NullExpression(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/ReturnExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.defs.Keywords; 5 | 6 | public class ReturnExpression extends Expression { 7 | 8 | private Expression returnValue; 9 | 10 | public ReturnExpression(Expression returnValue) { 11 | super(); 12 | this.returnValue = returnValue; 13 | } 14 | 15 | public ReturnExpression() { 16 | super(); 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | StringBuilder sb = new StringBuilder(); 22 | sb.append("" + Keywords.RETURN + ""); 23 | if (returnValue != null) { 24 | sb.append(" "); 25 | sb.append(returnValue); 26 | } 27 | return sb.toString(); 28 | } 29 | 30 | @Override 31 | public int size() { 32 | return 0; 33 | } 34 | 35 | @Override 36 | public Expression clone() { 37 | return new ReturnExpression(returnValue); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/SingleOpExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.Operation; 5 | import me.grax.jbytemod.analysis.decompiler.code.ast.VarType; 6 | 7 | public class SingleOpExpression extends OpExpression { 8 | 9 | public SingleOpExpression(Expression ref, Operation op, VarType returnType) { 10 | super(ref, null, op, returnType); 11 | } 12 | 13 | @Override 14 | public Expression getRight() { 15 | throw new IllegalArgumentException("called getRight on single exp reference"); 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return op.getSymbol() + "(" + left.toString() + ")"; 21 | } 22 | 23 | @Override 24 | public Expression clone() { 25 | return new SingleOpExpression(left.clone(), op, returnType); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/StringExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.utils.TextUtils; 5 | 6 | public class StringExpression extends Expression { 7 | 8 | private String value; 9 | 10 | public StringExpression(String value) { 11 | super(); 12 | this.value = value; 13 | } 14 | 15 | public String getValue() { 16 | return value; 17 | } 18 | 19 | public void setValue(String value) { 20 | this.value = value; 21 | } 22 | 23 | @Override 24 | public String toString() { 25 | return TextUtils.addTag("\"" + value + "\"", "font color=#559955"); //TODO escape 26 | } 27 | 28 | @Override 29 | public int size() { 30 | return 1; 31 | } 32 | 33 | @Override 34 | public Expression clone() { 35 | return new StringExpression(value); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/TableSwitchExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | 5 | public class TableSwitchExpression extends Expression { 6 | 7 | private Expression toSwitch; 8 | private int min; 9 | private int max; 10 | 11 | public TableSwitchExpression(Expression toSwitch, int min, int max) { 12 | this.toSwitch = toSwitch; 13 | this.min = min; 14 | this.max = max; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return "switch(" + toSwitch + ") " + min + " - " + max + ""; 20 | } 21 | 22 | @Override 23 | public int size() { 24 | return 1; 25 | } 26 | 27 | @Override 28 | public Expression clone() { 29 | return new TableSwitchExpression(toSwitch.clone(), min, max); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/TextExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.utils.TextUtils; 5 | 6 | public class TextExpression extends Expression { 7 | 8 | private String text; 9 | 10 | public TextExpression(String var) { 11 | this.text = var; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return "" + TextUtils.escape(text) + ""; 17 | } 18 | 19 | @Override 20 | public int size() { 21 | return 0; 22 | } 23 | 24 | @Override 25 | public Expression clone() { 26 | return new TextExpression(text); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/ThrowExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.defs.Keywords; 5 | 6 | public class ThrowExpression extends Expression { 7 | 8 | private Expression throwable; 9 | 10 | public ThrowExpression(Expression throwable) { 11 | super(); 12 | this.throwable = throwable; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | StringBuilder sb = new StringBuilder(); 18 | sb.append("" + Keywords.THROW + ""); 19 | if (throwable != null) { 20 | sb.append(" "); 21 | sb.append(throwable); 22 | } 23 | return sb.toString(); 24 | } 25 | 26 | @Override 27 | public int size() { 28 | return 0; 29 | } 30 | 31 | @Override 32 | public Expression clone() { 33 | return new ThrowExpression(throwable); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/ValueExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.VarType; 5 | 6 | public class ValueExpression extends Expression { 7 | private VarType type; 8 | private Object value; 9 | 10 | public ValueExpression(VarType type, Object value) { 11 | super(); 12 | this.type = type; 13 | this.value = value; 14 | } 15 | 16 | private String getSub() { 17 | switch (type) { 18 | case OBJECT: 19 | case INT: 20 | return ""; 21 | case DOUBLE: 22 | return "d"; 23 | case FLOAT: 24 | return "f"; 25 | case LONG: 26 | return "L"; 27 | default: 28 | return ""; 29 | } 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return value.toString() + getSub(); 35 | } 36 | 37 | @Override 38 | public int size() { 39 | return type.size(); 40 | } 41 | 42 | @Override 43 | public Expression clone() { 44 | return new ValueExpression(type, value); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/VarLoadExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.analysis.decompiler.code.ast.VarType; 5 | import me.grax.jbytemod.utils.InstrUtils; 6 | import me.grax.jbytemod.utils.TextUtils; 7 | 8 | public class VarLoadExpression extends Expression { 9 | private int index; 10 | private VarType type; 11 | 12 | public VarLoadExpression(int index, VarType type) { 13 | super(); 14 | this.index = index; 15 | this.type = type; 16 | } 17 | 18 | public int getIndex() { 19 | return index; 20 | } 21 | 22 | public void setIndex(int index) { 23 | this.index = index; 24 | } 25 | 26 | public VarType getType() { 27 | return type; 28 | } 29 | 30 | public void setType(VarType type) { 31 | this.type = type; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return TextUtils.addTag("var" + index, "font color=" + InstrUtils.primColor.getString()); //TODO use localvartable 37 | } 38 | 39 | @Override 40 | public int size() { 41 | return type.size(); 42 | } 43 | 44 | @Override 45 | public Expression clone() { 46 | return new VarLoadExpression(index, type); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/code/ast/expressions/VarSpecialExpression.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.code.ast.expressions; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | import me.grax.jbytemod.utils.TextUtils; 5 | 6 | public class VarSpecialExpression extends Expression { 7 | 8 | private String var; 9 | 10 | public VarSpecialExpression(String var) { 11 | this.var = var; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return TextUtils.addTag(var, "font color=#669966"); 17 | } 18 | 19 | @Override 20 | public int size() { 21 | return 1; 22 | } 23 | 24 | @Override 25 | public Expression clone() { 26 | return new VarSpecialExpression(var); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/defs/Keywords.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.defs; 2 | 3 | public class Keywords { 4 | public static final String RETURN = "return"; 5 | public static final String THROW = "throw"; 6 | public static final String NULL = "null"; 7 | //TODO add other keywords 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/struct/exception/StackException.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.struct.exception; 2 | 3 | public class StackException extends RuntimeException { 4 | private static final long serialVersionUID = 1L; 5 | 6 | public StackException(String string) { 7 | super(string); 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/struct/exception/UnknownOPException.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.struct.exception; 2 | 3 | import me.lpk.util.OpUtils; 4 | 5 | public class UnknownOPException extends RuntimeException { 6 | private static final long serialVersionUID = 1L; 7 | 8 | public UnknownOPException(int opc) { 9 | super("Unresolved opcode: " + OpUtils.getOpcodeText(opc) + " (" + opc + ")"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/struct/utils/DescUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.struct.utils; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class DescUtils { 6 | public static ArrayList getDescSizes(String desc) { 7 | ArrayList descSizes = new ArrayList<>(); 8 | int dims = 0; 9 | boolean inObject = false; 10 | for (char c : desc.toCharArray()) { 11 | if (inObject) { 12 | if (c == ';') { 13 | inObject = false; 14 | descSizes.add(1); 15 | dims = 0; 16 | } 17 | continue; 18 | } 19 | if (c == 'L') { 20 | inObject = true; 21 | } else if (c == '[') { 22 | dims++; 23 | } else { 24 | if (dims == 0 && (c == 'J' || c == 'D')) { 25 | descSizes.add(2); 26 | } else { 27 | descSizes.add(1); 28 | } 29 | dims = 0; 30 | } 31 | } 32 | return descSizes; 33 | } 34 | 35 | public static ArrayList getInnerDescSizes(String desc) { 36 | if (desc.startsWith("()")) { 37 | return new ArrayList<>(); 38 | } 39 | return getDescSizes(desc.substring(1, desc.lastIndexOf(')'))); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/decompiler/syntax/nodes/NodeList.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.decompiler.syntax.nodes; 2 | 3 | import me.grax.jbytemod.analysis.decompiler.code.ast.Expression; 4 | 5 | import java.util.ArrayList; 6 | 7 | public class NodeList extends ArrayList { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/errors/EmptyMistake.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.errors; 2 | 3 | public class EmptyMistake extends Mistake { 4 | public EmptyMistake() { 5 | super(" "); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/errors/InsnError.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.errors; 2 | 3 | public class InsnError extends Mistake { 4 | 5 | public InsnError(String desc) { 6 | super(desc); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/errors/InsnWarning.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.errors; 2 | 3 | public class InsnWarning extends Mistake { 4 | 5 | public InsnWarning(String desc) { 6 | super(desc); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/errors/Mistake.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.errors; 2 | 3 | public abstract class Mistake { 4 | private String desc; 5 | 6 | public Mistake(String desc) { 7 | this.desc = desc; 8 | } 9 | 10 | public String getDesc() { 11 | return desc; 12 | } 13 | 14 | public void setDesc(String desc) { 15 | this.desc = desc; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/obfuscation/enums/MethodObfType.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.obfuscation.enums; 2 | 3 | public enum MethodObfType { 4 | NONE("None"), TCBO("Unneccesary TCBs"), POP2( 5 | "POP2 Exploit")/* , LOCAL_VAR("Local Var Obf") */, STRING("String Obfuscation"), INVOKEDYNAMIC("Invokedynamic"); 6 | 7 | private final String type; 8 | 9 | private MethodObfType(String type) { 10 | this.type = type; 11 | } 12 | 13 | public String getType() { 14 | return type; 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/obfuscation/enums/NameObfType.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.obfuscation.enums; 2 | 3 | public enum NameObfType { 4 | NONE("None"), LONG_LETTERS("Long Letters"), SHORT_LETTERS("Short Letters"), HIGH_CHAR("High UTF8 Values"), JAVA_KEYWORD( 5 | "Java Keywords"), INVALID_WINDIR("Invalid Dir Names"); 6 | 7 | private final String type; 8 | 9 | private NameObfType(String type) { 10 | this.type = type; 11 | } 12 | 13 | public String getType() { 14 | return type; 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/obfuscation/result/MethodResult.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.obfuscation.result; 2 | 3 | import me.grax.jbytemod.analysis.obfuscation.enums.MethodObfType; 4 | 5 | import java.util.ArrayList; 6 | 7 | public class MethodResult { 8 | public ArrayList mobf; 9 | 10 | public MethodResult(ArrayList mobf) { 11 | super(); 12 | this.mobf = mobf; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/obfuscation/result/NamesResult.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.obfuscation.result; 2 | 3 | import me.grax.jbytemod.analysis.obfuscation.enums.NameObfType; 4 | 5 | import java.util.ArrayList; 6 | 7 | public class NamesResult { 8 | public ArrayList cnames; 9 | public ArrayList mnames; 10 | public ArrayList fnames; 11 | 12 | public NamesResult(ArrayList cnames, ArrayList mnames, ArrayList fnames) { 13 | super(); 14 | this.cnames = cnames; 15 | this.mnames = mnames; 16 | this.fnames = fnames; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/analysis/utils/BlockUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.analysis.utils; 2 | 3 | import me.grax.jbytemod.analysis.block.Block; 4 | 5 | import java.util.ArrayList; 6 | 7 | public class BlockUtils { 8 | public static boolean doesMerge(Block block, Block into) { 9 | return doesMerge(new ArrayList<>(), block, into); 10 | } 11 | 12 | private static boolean doesMerge(ArrayList visited, Block block, Block into) { 13 | if (visited.contains(block)) { 14 | return false; 15 | } 16 | visited.add(block); 17 | if (block == into) { 18 | return true; 19 | } 20 | for (Block output : block.getOutput()) { 21 | if (doesMerge(visited, output, into)) { 22 | return true; 23 | } 24 | } 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/decompiler/Decompilers.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.decompiler; 2 | 3 | public enum Decompilers { 4 | CFR("CFR", "1.46"), PROCYON("Procyon", "0.5.36"), FERNFLOWER("Fernflower", ""), KRAKATAU("Krakatau", "502"), KOFFEE("Koffee", ""); 5 | private String version; 6 | private String name; 7 | 8 | Decompilers(String name, String version) { 9 | this.name = name; 10 | this.version = version; 11 | } 12 | 13 | public String getVersion() { 14 | return version; 15 | } 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return name + " " + version; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/decompiler/KoffeeDecompiler.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.decompiler; 2 | 3 | import codes.som.anthony.koffee.disassembler.ClassDisassemblyKt; 4 | import codes.som.anthony.koffee.disassembler.MethodDisassemblyKt; 5 | import codes.som.anthony.koffee.disassembler.util.DisassemblyContext; 6 | import codes.som.anthony.koffee.disassembler.util.SourceCodeGenerator; 7 | import me.grax.jbytemod.JByteMod; 8 | import me.grax.jbytemod.ui.DecompilerPanel; 9 | import org.objectweb.asm.tree.MethodNode; 10 | 11 | public class KoffeeDecompiler extends Decompiler { 12 | public KoffeeDecompiler(JByteMod jbm, DecompilerPanel dp) { 13 | super(jbm, dp); 14 | } 15 | 16 | @Override 17 | public String decompile(byte[] b, MethodNode mn) { 18 | SourceCodeGenerator sourceCodeGenerator = new SourceCodeGenerator(); 19 | DisassemblyContext context = new DisassemblyContext(cn.name); 20 | if (mn == null) { 21 | return ClassDisassemblyKt.disassemble(cn); 22 | } else { 23 | MethodDisassemblyKt.disassembleMethod(mn, sourceCodeGenerator, context); 24 | } 25 | 26 | return sourceCodeGenerator.toString(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/discord/Discord.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.discord; 2 | 3 | import club.minnced.discord.rpc.DiscordEventHandlers; 4 | import club.minnced.discord.rpc.DiscordRPC; 5 | import club.minnced.discord.rpc.DiscordRichPresence; 6 | import me.grax.jbytemod.JByteMod; 7 | 8 | public class Discord { 9 | public static DiscordRPC discordRPC; 10 | public static long startTimestamp; 11 | 12 | public static void init() { 13 | discordRPC = DiscordRPC.INSTANCE; 14 | String applicationId = "610647709694558231"; 15 | DiscordEventHandlers handlers = new DiscordEventHandlers(); 16 | handlers.ready = (user) -> JByteMod.LOGGER.log("Discord is now ready."); 17 | 18 | discordRPC.Discord_Initialize(applicationId, handlers, true, ""); 19 | 20 | startTimestamp = System.currentTimeMillis(); 21 | updatePresence("Idle ...", ""); 22 | 23 | new Thread(() -> { 24 | while (!Thread.currentThread().isInterrupted()) { 25 | discordRPC.Discord_RunCallbacks(); 26 | try { 27 | Thread.sleep(2000); 28 | } catch (InterruptedException ignored) { 29 | } 30 | } 31 | }, "RPC-Callback-Handler").start(); 32 | } 33 | 34 | public static void updatePresence(String details, String state) { 35 | DiscordRichPresence presence = new DiscordRichPresence(); 36 | presence.details = details; 37 | presence.startTimestamp = startTimestamp; 38 | if (!state.equals("") && JByteMod.ops.get("discord_state").getBoolean()) { 39 | presence.state = state; 40 | } 41 | 42 | discordRPC.Discord_UpdatePresence(presence); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/scanner/ScannerThread.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.scanner; 2 | 3 | import hakery.club.raccscanner.Raccoon; 4 | import hakery.club.raccscanner.results.Result; 5 | import me.grax.jbytemod.JByteMod; 6 | import me.grax.jbytemod.utils.DeobfusacteUtils; 7 | import org.objectweb.asm.tree.ClassNode; 8 | 9 | import javax.swing.*; 10 | import java.util.Map; 11 | 12 | public class ScannerThread extends Thread { 13 | private Map input; 14 | private Result result; 15 | private Raccoon scanner; 16 | private byte[] jarManifest = null; 17 | 18 | public ScannerThread(Map input) { 19 | this.input = input; 20 | } 21 | 22 | @Override 23 | public void run() { 24 | scanner = new Raccoon(input, jarManifest); 25 | scanner.initialize(null); 26 | scanner.scan(); 27 | System.out.println("[Raccoon] Finished scanning the file."); 28 | result = scanner.getResult(); 29 | 30 | result.printResults(); 31 | 32 | JOptionPane.showMessageDialog(null, String.join("\n", result.getResults()) + "\n\nPowered by Raccoon Scanner.", 33 | JByteMod.res.getResource("raccoon"), JOptionPane.INFORMATION_MESSAGE); 34 | } 35 | 36 | public void cleanCache() { 37 | this.input = null; 38 | } 39 | 40 | public void setJarManifest(byte[] jarManifest){ 41 | this.jarManifest = jarManifest; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/DecompilerPanel.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui; 2 | 3 | import me.grax.jbytemod.utils.ErrorDisplay; 4 | import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; 5 | import org.fife.ui.rsyntaxtextarea.Theme; 6 | 7 | import java.awt.*; 8 | import java.io.IOException; 9 | 10 | public class DecompilerPanel extends RSyntaxTextArea { 11 | 12 | public DecompilerPanel() { 13 | this.setSyntaxEditingStyle("text/java"); 14 | this.setCodeFoldingEnabled(true); 15 | this.setAntiAliasingEnabled(true); 16 | this.setFont(new Font("Monospaced", Font.PLAIN, 12)); 17 | this.setEditable(false); 18 | //change theme to java 19 | try { 20 | Theme theme = Theme.load(getClass().getResourceAsStream("/org/fife/ui/rsyntaxtextarea/themes/idea.xml")); 21 | theme.apply(this); 22 | } catch (IOException e1) { 23 | new ErrorDisplay(e1); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/JMethodObfAnalysis.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui; 2 | 3 | import me.grax.jbytemod.analysis.obfuscation.enums.MethodObfType; 4 | import me.grax.jbytemod.analysis.obfuscation.result.MethodResult; 5 | import org.jfree.data.category.CategoryDataset; 6 | import org.jfree.data.category.DefaultCategoryDataset; 7 | import org.objectweb.asm.tree.ClassNode; 8 | 9 | import java.util.Map; 10 | 11 | public class JMethodObfAnalysis extends JObfAnalysis { 12 | 13 | public JMethodObfAnalysis(Map nodes) { 14 | super(nodes); 15 | } 16 | 17 | protected CategoryDataset analyze(Map nodes) { 18 | MethodResult mr = analyzer.analyzeMethod(); 19 | final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); 20 | for (MethodObfType t : MethodObfType.values()) { 21 | if (t == MethodObfType.NONE) 22 | continue; 23 | int i = 0; 24 | for (MethodObfType not : mr.mobf) { 25 | if (not == t) { 26 | i++; 27 | } 28 | } 29 | dataset.addValue((double) (i / (double) mr.mobf.size()) * 100d, "", t.getType()); 30 | } 31 | return dataset; 32 | } 33 | 34 | @Override 35 | protected String[] getDescriptors() { 36 | return new String[]{"Method Obfuscation", "Categories", "Percent"}; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/JObfAnalysis.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui; 2 | 3 | import me.grax.jbytemod.analysis.obfuscation.ObfuscationAnalyzer; 4 | import org.jfree.chart.ChartFactory; 5 | import org.jfree.chart.ChartPanel; 6 | import org.jfree.chart.JFreeChart; 7 | import org.jfree.data.category.CategoryDataset; 8 | import org.objectweb.asm.tree.ClassNode; 9 | 10 | import javax.swing.*; 11 | import java.awt.*; 12 | import java.util.Map; 13 | 14 | public abstract class JObfAnalysis extends JFrame { 15 | protected ObfuscationAnalyzer analyzer; 16 | 17 | public JObfAnalysis(Map nodes) { 18 | setBounds(100, 100, 800, 800); 19 | setResizable(false); 20 | setTitle("Obfuscation Analysis"); 21 | JPanel cp = new JPanel(); 22 | cp.setLayout(new BorderLayout()); 23 | this.analyzer = new ObfuscationAnalyzer(nodes); 24 | cp.add(new ChartPanel(createChart(analyze(nodes))), BorderLayout.CENTER); 25 | this.add(cp); 26 | 27 | } 28 | 29 | protected abstract CategoryDataset analyze(Map nodes); 30 | 31 | protected abstract String[] getDescriptors(); 32 | 33 | private JFreeChart createChart(CategoryDataset categoryDataset) { 34 | String[] desc = getDescriptors(); 35 | JFreeChart chart = ChartFactory.createBarChart(desc[0], desc[1], desc[2], categoryDataset); 36 | return chart; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/MyCodeEditor.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui; 2 | 3 | import me.grax.jbytemod.JByteMod; 4 | import me.grax.jbytemod.ui.lists.AdressList; 5 | import me.grax.jbytemod.ui.lists.ErrorList; 6 | import me.grax.jbytemod.ui.lists.MyCodeList; 7 | 8 | import javax.swing.*; 9 | import java.awt.*; 10 | 11 | public class MyCodeEditor extends JPanel { 12 | private MyCodeList cl; 13 | 14 | public MyCodeEditor(JByteMod jbm, JLabel editor) { 15 | this.setLayout(new BorderLayout()); 16 | cl = new MyCodeList(jbm, editor); 17 | this.add(cl, BorderLayout.CENTER); 18 | JPanel p = new JPanel(); 19 | p.setLayout(new BorderLayout()); 20 | p.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, JByteMod.border)); 21 | p.add(new AdressList(cl), BorderLayout.CENTER); 22 | this.add(p, BorderLayout.WEST); 23 | this.add(new ErrorList(jbm, cl), BorderLayout.EAST); 24 | 25 | } 26 | 27 | public MyCodeList getEditor() { 28 | return cl; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/MySplitPane.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui; 2 | 3 | import me.grax.jbytemod.JByteMod; 4 | 5 | import javax.swing.*; 6 | import java.awt.*; 7 | 8 | public class MySplitPane extends JSplitPane { 9 | private JTabbedPane rightSide; 10 | private JPanel leftSide; 11 | 12 | public MySplitPane(JByteMod jbm, ClassTree classTree) { 13 | rightSide = new MyTabbedPane(jbm); 14 | leftSide = new JPanel(); 15 | leftSide.setLayout(new BorderLayout(0, 0)); 16 | leftSide.add(new JLabel(" " + JByteMod.res.getResource("java_archive")), BorderLayout.NORTH); 17 | leftSide.add(new JScrollPane(classTree), BorderLayout.CENTER); 18 | this.setLeftComponent(leftSide); 19 | this.setRightComponent(rightSide); 20 | this.setDividerLocation(150); 21 | this.setContinuousLayout(true); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/NoBorderSP.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui; 2 | 3 | import javax.swing.*; 4 | import java.awt.*; 5 | 6 | public class NoBorderSP extends JScrollPane { 7 | public NoBorderSP(Component c) { 8 | super(c); 9 | this.setBorder(BorderFactory.createEmptyBorder()); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/OpcodeTable.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui; 2 | 3 | import me.grax.jbytemod.utils.ErrorDisplay; 4 | import org.apache.commons.io.IOUtils; 5 | 6 | import javax.swing.*; 7 | import java.awt.*; 8 | 9 | public class OpcodeTable extends JEditorPane { 10 | public OpcodeTable() { 11 | this.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 13)); 12 | this.setEditable(false); 13 | this.setContentType("text/html"); 14 | this.setText(loadTable()); 15 | } 16 | 17 | private String loadTable() { 18 | try { 19 | return IOUtils.toString(this.getClass().getResourceAsStream("/resources/html/optable.html")); 20 | } catch (Exception e) { 21 | new ErrorDisplay(e); 22 | return ""; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/dialogue/testing/TestValues.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.dialogue.testing; 2 | 3 | import me.grax.jbytemod.JByteMod; 4 | import me.grax.jbytemod.ui.dialogue.InsnEditDialogue; 5 | 6 | import java.lang.reflect.Field; 7 | import java.util.Arrays; 8 | import java.util.List; 9 | 10 | public class TestValues { 11 | public int integer = 0; 12 | public float floatval = 0; 13 | public double doubleval = 0; 14 | public long longval = 0; 15 | public byte byteval = 0; 16 | public char charval = 'c'; 17 | public short shortval = 0; 18 | public Integer integer2 = 0; 19 | public Float floatval2 = 0f; 20 | public Double doubleval2 = 0d; 21 | public Long longval2 = 0L; 22 | public Byte byteval2 = 0; 23 | public Character charval2 = 0; 24 | public Short shortval2 = 0; 25 | public String test = "Test"; 26 | /* public String stringNull = null; */ 27 | public List list = Arrays.asList("1", "2", "3"); 28 | 29 | public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException { 30 | JByteMod.initialize(); 31 | TestValues tv = new TestValues(); 32 | new InsnEditDialogue(null, tv).open(); 33 | for (Field f : tv.getClass().getDeclaredFields()) { 34 | System.out.println(f.getName() + " " + f.get(tv)); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/graph/PatchedHierarchicalLayout.java: -------------------------------------------------------------------------------- 1 | // Copyright GFI 2017 - Data Systemizer 2 | package me.grax.jbytemod.ui.graph; 3 | 4 | import com.mxgraph.layout.hierarchical.mxHierarchicalLayout; 5 | import com.mxgraph.layout.hierarchical.stage.mxCoordinateAssignment; 6 | import com.mxgraph.view.mxGraph; 7 | 8 | /** 9 | * Patched hierarchical layout to route directly cross-group edges 10 | * 11 | * @author Loison 12 | */ 13 | public class PatchedHierarchicalLayout extends mxHierarchicalLayout { 14 | 15 | public PatchedHierarchicalLayout(mxGraph graph) { 16 | super(graph); 17 | } 18 | 19 | public PatchedHierarchicalLayout(mxGraph graph, int orientation) { 20 | super(graph, orientation); 21 | } 22 | 23 | /** 24 | * Executes the placement stage using mxCoordinateAssignment. 25 | *

26 | * Use a patched mxCoordinateAssignment class 27 | */ 28 | @Override 29 | public double placementStage(double initialX, Object parent) { 30 | mxCoordinateAssignment placementStage = new PatchedCoordinateAssignment(this, intraCellSpacing, interRankCellSpacing, orientation, initialX, 31 | parallelEdgeSpacing); 32 | placementStage.setFineTuning(fineTuning); 33 | placementStage.execute(parent); 34 | 35 | return placementStage.getLimitX() + interHierarchySpacing; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/ifs/LVPFrame.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.ifs; 2 | 3 | import me.grax.jbytemod.ui.NoBorderSP; 4 | import me.grax.jbytemod.ui.lists.LVPList; 5 | 6 | import java.awt.*; 7 | 8 | public class LVPFrame extends MyInternalFrame { 9 | /** 10 | * Save position 11 | */ 12 | private static Rectangle bounds = new Rectangle(10, 10, 1280 / 4, 720 / 4); 13 | 14 | public LVPFrame(LVPList lvp) { 15 | super("Local Variables"); 16 | this.add(new NoBorderSP(lvp)); 17 | this.setBounds(bounds); 18 | this.show(); 19 | } 20 | 21 | @Override 22 | public void setVisible(boolean aFlag) { 23 | if (!aFlag && !(getLocation().getY() == 0 && getLocation().getX() == 0)) { 24 | bounds = getBounds(); 25 | } 26 | super.setVisible(aFlag); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/ifs/MyInternalFrame.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.ifs; 2 | 3 | import javax.swing.*; 4 | 5 | public class MyInternalFrame extends JInternalFrame { 6 | 7 | public MyInternalFrame(String title) { 8 | this.setTitle(title); 9 | this.setMaximizable(true); 10 | this.setResizable(true); 11 | this.setClosable(false); 12 | this.setIconifiable(true); 13 | getDesktopIcon().updateUI(); 14 | updateUI(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/ifs/TCBFrame.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.ifs; 2 | 3 | import me.grax.jbytemod.ui.NoBorderSP; 4 | import me.grax.jbytemod.ui.lists.TCBList; 5 | 6 | import java.awt.*; 7 | 8 | public class TCBFrame extends MyInternalFrame { 9 | /** 10 | * Save position 11 | */ 12 | private static Rectangle bounds = new Rectangle(340, 10, 1280 / 4, 720 / 4); 13 | 14 | public TCBFrame(TCBList tcb) { 15 | super("Try Catch Blocks"); 16 | this.add(new NoBorderSP(tcb)); 17 | this.setBounds(bounds); 18 | this.show(); 19 | } 20 | 21 | @Override 22 | public void setVisible(boolean aFlag) { 23 | if (!aFlag && !(getLocation().getY() == 0 && getLocation().getX() == 0)) { 24 | bounds = getBounds(); 25 | } 26 | super.setVisible(aFlag); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/lists/entries/InstrEntry.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.lists.entries; 2 | 3 | import me.grax.jbytemod.utils.InstrUtils; 4 | import me.grax.jbytemod.utils.TextUtils; 5 | import me.grax.jbytemod.utils.asm.Hints; 6 | import org.objectweb.asm.tree.AbstractInsnNode; 7 | import org.objectweb.asm.tree.MethodNode; 8 | 9 | public class InstrEntry { 10 | private MethodNode m; 11 | private AbstractInsnNode i; 12 | 13 | public InstrEntry(MethodNode m, AbstractInsnNode i) { 14 | this.m = m; 15 | this.i = (AbstractInsnNode) i; 16 | } 17 | 18 | public MethodNode getMethod() { 19 | return m; 20 | } 21 | 22 | public void setM(MethodNode m) { 23 | this.m = m; 24 | } 25 | 26 | public AbstractInsnNode getInstr() { 27 | return i; 28 | } 29 | 30 | public void setI(AbstractInsnNode i) { 31 | this.i = i; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return TextUtils.toHtml(InstrUtils.toString(i)); 37 | } 38 | 39 | public String toEasyString() { 40 | return InstrUtils.toEasyString(i); 41 | } 42 | 43 | public String getHint() { 44 | if (i != null && i.getOpcode() >= 0) { 45 | return Hints.hints[i.getOpcode()]; 46 | } 47 | return null; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/lists/entries/LVPEntry.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.lists.entries; 2 | 3 | import me.grax.jbytemod.utils.InstrUtils; 4 | import me.grax.jbytemod.utils.TextUtils; 5 | import org.objectweb.asm.tree.ClassNode; 6 | import org.objectweb.asm.tree.LocalVariableNode; 7 | import org.objectweb.asm.tree.MethodNode; 8 | 9 | public class LVPEntry { 10 | private ClassNode cn; 11 | private MethodNode mn; 12 | private LocalVariableNode lvn; 13 | private String text; 14 | 15 | public LVPEntry(ClassNode cn, MethodNode mn, LocalVariableNode lvn) { 16 | this.cn = cn; 17 | this.mn = mn; 18 | this.lvn = lvn; 19 | this.text = TextUtils.toHtml(TextUtils.toBold("#" + lvn.index) + " "); 20 | if (lvn.desc != null && !lvn.desc.isEmpty()) { 21 | this.text += InstrUtils.getDisplayType(lvn.desc, true) + " "; 22 | } 23 | this.text += TextUtils.addTag(TextUtils.escape(lvn.name), "font color=#995555"); 24 | } 25 | 26 | public ClassNode getCn() { 27 | return cn; 28 | } 29 | 30 | public MethodNode getMn() { 31 | return mn; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return text; 37 | } 38 | 39 | public LocalVariableNode getLvn() { 40 | return lvn; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/lists/entries/PrototypeEntry.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.lists.entries; 2 | 3 | public class PrototypeEntry extends InstrEntry { 4 | 5 | public PrototypeEntry() { 6 | super(null, null); 7 | } 8 | 9 | @Override 10 | public String toString() { 11 | return " "; 12 | } 13 | 14 | @Override 15 | public String toEasyString() { 16 | return " "; 17 | } 18 | 19 | @Override 20 | public String getHint() { 21 | return null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/ui/lists/entries/TCBEntry.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.ui.lists.entries; 2 | 3 | import me.grax.jbytemod.utils.InstrUtils; 4 | import me.grax.jbytemod.utils.TextUtils; 5 | import me.lpk.util.OpUtils; 6 | import org.objectweb.asm.tree.ClassNode; 7 | import org.objectweb.asm.tree.MethodNode; 8 | import org.objectweb.asm.tree.TryCatchBlockNode; 9 | 10 | public class TCBEntry { 11 | private ClassNode cn; 12 | private MethodNode mn; 13 | private TryCatchBlockNode tcbn; 14 | private String text; 15 | 16 | public TCBEntry(ClassNode cn, MethodNode mn, TryCatchBlockNode tcbn) { 17 | this.cn = cn; 18 | this.mn = mn; 19 | this.tcbn = tcbn; 20 | this.text = TextUtils.toHtml( 21 | (tcbn.type != null ? InstrUtils.getDisplayType(tcbn.type, true) : TextUtils.addTag("Null type", "font color=" + InstrUtils.primColor.getString())) + ": label " + OpUtils.getLabelIndex(tcbn.start) + " -> label " 22 | + OpUtils.getLabelIndex(tcbn.end) + " handler: label " + (tcbn.handler == null ? "null" : OpUtils.getLabelIndex(tcbn.handler))); 23 | } 24 | 25 | public ClassNode getCn() { 26 | return cn; 27 | } 28 | 29 | public MethodNode getMn() { 30 | return mn; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return text; 36 | } 37 | 38 | public TryCatchBlockNode getTcbn() { 39 | return tcbn; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/FileUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils; 2 | 3 | import org.objectweb.asm.tree.ClassNode; 4 | 5 | import java.io.File; 6 | 7 | public class FileUtils { 8 | public static boolean exists(File f) { 9 | return f.exists() && !f.isDirectory(); 10 | } 11 | 12 | public static boolean isType(File f, String... types) { 13 | for (String type : types) { 14 | if (f.getName().endsWith(type)) { 15 | return true; 16 | } 17 | } 18 | return false; 19 | } 20 | 21 | public static int isBadClass(ClassNode classNode){ 22 | int toReturn = 0; 23 | 24 | if(classNode.methods.size() == 0) toReturn =+ 10; 25 | if(classNode.fields.size() == 0 || classNode.fields.size() == 32) toReturn =+ 10; 26 | if(classNode.fields.size() > 500) toReturn += 50; 27 | if(classNode.fields.size() == 32) toReturn += 30; 28 | if(classNode.version > 55) toReturn += 10; 29 | if(classNode.access == 0 && classNode.methods.size() == 0) toReturn += 50; 30 | if(classNode.access == 0) toReturn += 20; 31 | if(classNode.name == null) toReturn = 100; 32 | if(classNode.version == 49) toReturn += 20; 33 | if(classNode.methods.size() == 2 34 | && classNode.methods.get(0).name.equals("") 35 | && classNode.methods.get(1).access == 10 36 | && classNode.version == 49) 37 | toReturn += 100; 38 | if(classNode.access == 33 && classNode.methods.size() == 1 && classNode.fields.size() == 0) toReturn += 100; 39 | 40 | if(toReturn > 100) toReturn = 100; 41 | return toReturn; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/ImageUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils; 2 | 3 | import java.awt.*; 4 | import java.awt.image.BufferedImage; 5 | 6 | public class ImageUtils { 7 | private static final String watermark = "Created with JByteMod"; 8 | 9 | public static BufferedImage watermark(BufferedImage old) { 10 | BufferedImage copy = copyImage(old); 11 | Graphics2D g2d = copy.createGraphics(); 12 | g2d.setPaint(Color.black); 13 | g2d.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); 14 | FontMetrics fm = g2d.getFontMetrics(); 15 | int x = copy.getWidth() - fm.stringWidth(watermark) - 5; 16 | int y = fm.getHeight(); 17 | g2d.drawString(watermark, x, y); 18 | g2d.dispose(); 19 | return copy; 20 | } 21 | 22 | private static BufferedImage copyImage(BufferedImage source) { 23 | BufferedImage b = new BufferedImage(source.getWidth() + 60, source.getHeight() + 60, source.getType()); 24 | Graphics g = b.createGraphics(); 25 | g.setColor(Color.WHITE); 26 | g.fillRect(0, 0, source.getWidth() + 60, source.getHeight() + 60); 27 | g.setColor(Color.BLACK); 28 | g.drawImage(source, 30, 30, null); 29 | g.dispose(); 30 | return b; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/TextUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils; 2 | 3 | public class TextUtils { 4 | 5 | public static String toHtml(String str) { 6 | return "" + toBlack(str); 7 | } 8 | 9 | public static String toBlack(String str) { 10 | return addTag(str, "font color=#000000"); 11 | } 12 | 13 | public static String addTag(String str, String tag) { 14 | return "<" + tag + ">" + str + ""; 15 | } 16 | 17 | public static String toLight(String str) { 18 | return addTag(str, "font color=#999999"); 19 | } 20 | 21 | public static String toBold(String str) { 22 | return addTag(str, "b"); 23 | } 24 | 25 | public static String escape(String str) { 26 | return str.replace("&", "&").replace("<", "<").replace(">", ">"); 27 | } 28 | 29 | public static String toItalics(String str) { 30 | return addTag(str, "i"); 31 | } 32 | 33 | public static String max(String string, int i) { 34 | if (string.length() > i) { 35 | return string.substring(0, i) + "..."; 36 | } 37 | return string; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/asm/Loader.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils.asm; 2 | 3 | import me.grax.jbytemod.JByteMod; 4 | import me.lpk.util.ASMUtils; 5 | import org.objectweb.asm.tree.ClassNode; 6 | 7 | import java.io.ByteArrayOutputStream; 8 | import java.io.IOException; 9 | import java.io.InputStream; 10 | 11 | public class Loader { 12 | public static ClassNode classToNode(String type) throws IOException { 13 | return ASMUtils.getNode(classToBytes(type)); 14 | } 15 | 16 | public static byte[] classToBytes(String type) throws IOException { 17 | if (type == null) { 18 | return null; 19 | } 20 | InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream(type + ".class"); 21 | if (is == null) { 22 | JByteMod.LOGGER.err(type + " not in classpath"); 23 | return null; 24 | } 25 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 26 | byte[] buffer = new byte[4096]; 27 | int n; 28 | while ((n = is.read(buffer)) > 0) { 29 | baos.write(buffer, 0, n); 30 | } 31 | return baos.toByteArray(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/asm/ParentUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils.asm; 2 | 3 | import org.objectweb.asm.tree.ClassNode; 4 | 5 | import java.util.Map; 6 | 7 | public class ParentUtils { 8 | private Map classes; 9 | 10 | public ParentUtils(Map classes) { 11 | this.classes = classes; 12 | } 13 | 14 | public boolean isAssignableFrom(ClassNode cn, ClassNode cn2) { 15 | if (cn2.name.equals(cn.name)) { 16 | return true; 17 | } 18 | for (String itfn : cn2.interfaces) { 19 | ClassNode itf = classes.get(itfn); 20 | if (itf == null) 21 | continue; 22 | if (isAssignableFrom(cn, itf)) { 23 | return true; 24 | } 25 | } 26 | if (cn2.superName != null) { 27 | ClassNode sn = classes.get(cn2.superName); 28 | if (sn != null) 29 | if (isAssignableFrom(cn, sn)) { 30 | return true; 31 | } 32 | } 33 | return false; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/gui/LookUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils.gui; 2 | 3 | import com.alee.laf.WebLookAndFeel; 4 | import me.grax.jbytemod.JByteMod; 5 | import me.grax.jbytemod.utils.ThemeChanges; 6 | 7 | import javax.swing.*; 8 | 9 | public class LookUtils { 10 | public static void setLAF() { 11 | try { 12 | JByteMod.LOGGER.log("Setting default Look and Feel"); 13 | if (JByteMod.ops.get("use_weblaf").getBoolean()) { 14 | WebLookAndFeel.install(); 15 | } else { 16 | if (!changeLAF("javax.swing.plaf.nimbus.NimbusLookAndFeel")) { 17 | JByteMod.LOGGER.err("Failed to set Nimbus Look and Feel, trying to use WebLaF"); 18 | WebLookAndFeel.install(); 19 | } 20 | } 21 | } catch (Throwable t) { 22 | t.printStackTrace(); 23 | JByteMod.LOGGER.err("Failed to set Look and Feel"); 24 | } 25 | } 26 | 27 | public static boolean changeLAF(String name) { 28 | try { 29 | JByteMod.LOGGER.log("Changing UI to " + name); 30 | UIManager.setLookAndFeel(name); 31 | UIManager.getLookAndFeel().uninitialize(); 32 | UIManager.setLookAndFeel(name); 33 | if (name.equals("javax.swing.plaf.nimbus.NimbusLookAndFeel")) { 34 | ThemeChanges.setDefaults(); 35 | } 36 | if (JByteMod.instance != null) { 37 | JByteMod.restartGUI(); 38 | } 39 | return true; 40 | } catch (Exception e) { 41 | e.printStackTrace(); 42 | } 43 | return false; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/gui/SwingUtils.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils.gui; 2 | 3 | import com.alee.laf.list.WebListUI; 4 | 5 | import javax.swing.*; 6 | import javax.swing.plaf.ListUI; 7 | import java.awt.*; 8 | import java.awt.event.ActionListener; 9 | 10 | public class SwingUtils { 11 | public static JPanel withButton(Component c, String text, ActionListener e) { 12 | JPanel jp = new JPanel(); 13 | jp.setLayout(new BorderLayout()); 14 | jp.add(c, BorderLayout.CENTER); 15 | JButton help = new JButton(text); 16 | help.addActionListener(e); 17 | jp.add(help, BorderLayout.EAST); 18 | return jp; 19 | } 20 | 21 | public static void disableSelection(JList jl) { 22 | ListUI ui = (ListUI) jl.getUI(); 23 | if (ui instanceof WebListUI) { 24 | WebListUI wlui = (WebListUI) ui; 25 | wlui.setHighlightRolloverCell(false); 26 | wlui.setDecorateSelection(false); 27 | } 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/me/grax/jbytemod/utils/list/LazyListModel.java: -------------------------------------------------------------------------------- 1 | package me.grax.jbytemod.utils.list; 2 | 3 | import javax.swing.*; 4 | import java.util.ArrayList; 5 | 6 | public class LazyListModel extends AbstractListModel { 7 | 8 | private ArrayList list; 9 | 10 | public LazyListModel() { 11 | this.list = new ArrayList(); 12 | } 13 | 14 | public void addElement(E e) { 15 | list.add(e); 16 | } 17 | 18 | @Override 19 | public int getSize() { 20 | return list.size(); 21 | } 22 | 23 | @Override 24 | protected void fireIntervalAdded(Object source, int index0, int index1) { 25 | } 26 | 27 | @Override 28 | public E getElementAt(int index) { 29 | return list.get(index); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/me/lpk/util/drop/IDropUser.java: -------------------------------------------------------------------------------- 1 | package me.lpk.util.drop; 2 | 3 | import java.io.File; 4 | 5 | public interface IDropUser { 6 | public void preLoadJars(int id); 7 | 8 | public void onJarLoad(int id, File input); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/me/lpk/util/drop/JarDropHandler.java: -------------------------------------------------------------------------------- 1 | package me.lpk.util.drop; 2 | 3 | import javax.swing.*; 4 | import java.awt.datatransfer.DataFlavor; 5 | import java.awt.datatransfer.Transferable; 6 | import java.io.File; 7 | import java.util.List; 8 | 9 | public class JarDropHandler extends TransferHandler { 10 | private static final long serialVersionUID = 1232L; 11 | private final IDropUser user; 12 | private final int id; 13 | 14 | public JarDropHandler(IDropUser user, int id) { 15 | this.user = user; 16 | this.id = id; 17 | } 18 | 19 | @Override 20 | public boolean canImport(TransferHandler.TransferSupport info) { 21 | info.setShowDropLocation(false); 22 | return info.isDrop() && info.isDataFlavorSupported(DataFlavor.javaFileListFlavor); 23 | } 24 | 25 | @SuppressWarnings("unchecked") 26 | @Override 27 | public boolean importData(TransferHandler.TransferSupport info) { 28 | if (!info.isDrop()) 29 | return false; 30 | Transferable t = info.getTransferable(); 31 | List data = null; 32 | try { 33 | data = (List) t.getTransferData(DataFlavor.javaFileListFlavor); 34 | } catch (Exception e) { 35 | return false; 36 | } 37 | user.preLoadJars(id); 38 | for (File jar : data) { 39 | if (jar.getName().toLowerCase().endsWith(".jar")) { 40 | user.onJarLoad(id, jar); 41 | break; 42 | } 43 | } 44 | return true; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/ExceptionHandler.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.code; 3 | 4 | import org.jetbrains.java.decompiler.main.DecompilerContext; 5 | 6 | public class ExceptionHandler { 7 | public int from = 0; 8 | public int to = 0; 9 | public int handler = 0; 10 | 11 | public int from_instr = 0; 12 | public int to_instr = 0; 13 | public int handler_instr = 0; 14 | 15 | public String exceptionClass = null; 16 | 17 | public String toString() { 18 | String new_line_separator = DecompilerContext.getNewLineSeparator(); 19 | return "from: " + from + " to: " + to + " handler: " + handler + new_line_separator + 20 | "from_instr: " + from_instr + " to_instr: " + to_instr + " handler_instr: " + handler_instr + new_line_separator + 21 | "exceptionClass: " + exceptionClass + new_line_separator; 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/ExceptionTable.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.code; 3 | 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | public class ExceptionTable { 8 | public static final ExceptionTable EMPTY = new ExceptionTable(Collections.emptyList()); 9 | 10 | private final List handlers; 11 | 12 | public ExceptionTable(List handlers) { 13 | this.handlers = handlers; 14 | } 15 | 16 | public List getHandlers() { 17 | return handlers; 18 | } 19 | } -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/FullInstructionSequence.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.code; 3 | 4 | import org.jetbrains.java.decompiler.util.VBStyleCollection; 5 | 6 | 7 | public class FullInstructionSequence extends InstructionSequence { 8 | 9 | // ***************************************************************************** 10 | // constructors 11 | // ***************************************************************************** 12 | 13 | public FullInstructionSequence(VBStyleCollection collinstr, ExceptionTable extable) { 14 | super(collinstr); 15 | this.exceptionTable = extable; 16 | 17 | // translate raw exception handlers to instr 18 | for (ExceptionHandler handler : extable.getHandlers()) { 19 | handler.from_instr = this.getPointerByAbsOffset(handler.from); 20 | handler.to_instr = this.getPointerByAbsOffset(handler.to); 21 | handler.handler_instr = this.getPointerByAbsOffset(handler.handler); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/JumpInstruction.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.code; 3 | 4 | public class JumpInstruction extends Instruction { 5 | public int destination; 6 | 7 | public JumpInstruction(int opcode, int group, boolean wide, int bytecodeVersion, int[] operands) { 8 | super(opcode, group, wide, bytecodeVersion, operands); 9 | } 10 | 11 | @Override 12 | public void initInstruction(InstructionSequence seq) { 13 | destination = seq.getPointerByRelOffset(this.operand(0)); 14 | } 15 | 16 | @Override 17 | public JumpInstruction clone() { 18 | JumpInstruction copy = (JumpInstruction)super.clone(); 19 | copy.destination = destination; 20 | return copy; 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/code/SimpleInstructionSequence.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.code; 3 | 4 | import org.jetbrains.java.decompiler.util.VBStyleCollection; 5 | 6 | public class SimpleInstructionSequence extends InstructionSequence { 7 | 8 | public SimpleInstructionSequence() { 9 | } 10 | 11 | public SimpleInstructionSequence(VBStyleCollection collinstr) { 12 | super(collinstr); 13 | } 14 | 15 | @Override 16 | public SimpleInstructionSequence clone() { 17 | SimpleInstructionSequence newseq = new SimpleInstructionSequence(collinstr.clone()); 18 | newseq.setPointer(this.getPointer()); 19 | 20 | return newseq; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/main/collectors/CounterContainer.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.main.collectors; 3 | 4 | public class CounterContainer { 5 | public static final int STATEMENT_COUNTER = 0; 6 | public static final int EXPRESSION_COUNTER = 1; 7 | public static final int VAR_COUNTER = 2; 8 | 9 | private final int[] values = new int[]{1, 1, 1}; 10 | 11 | public void setCounter(int counter, int value) { 12 | values[counter] = value; 13 | } 14 | 15 | public int getCounter(int counter) { 16 | return values[counter]; 17 | } 18 | 19 | public int getCounterAndIncrement(int counter) { 20 | return values[counter]++; 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/main/collectors/VarNamesCollector.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.main.collectors; 3 | 4 | import java.util.Collection; 5 | import java.util.HashSet; 6 | import java.util.Set; 7 | 8 | public class VarNamesCollector { 9 | 10 | private final Set usedNames = new HashSet<>(); 11 | 12 | public VarNamesCollector() { } 13 | 14 | public VarNamesCollector(Collection setNames) { 15 | usedNames.addAll(setNames); 16 | } 17 | 18 | public void addName(String value) { 19 | usedNames.add(value); 20 | } 21 | 22 | public String getFreeName(int index) { 23 | return getFreeName("var" + index); 24 | } 25 | 26 | public String getFreeName(String proposition) { 27 | while (usedNames.contains(proposition)) { 28 | proposition += "x"; 29 | } 30 | usedNames.add(proposition); 31 | return proposition; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/main/decompiler/BaseDecompiler.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.main.decompiler; 3 | 4 | import org.jetbrains.java.decompiler.main.Fernflower; 5 | import org.jetbrains.java.decompiler.main.extern.IBytecodeProvider; 6 | import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger; 7 | import org.jetbrains.java.decompiler.main.extern.IResultSaver; 8 | 9 | import java.io.File; 10 | import java.util.Map; 11 | 12 | @SuppressWarnings("unused") 13 | public class BaseDecompiler { 14 | private final Fernflower engine; 15 | 16 | public BaseDecompiler(IBytecodeProvider provider, IResultSaver saver, Map options, IFernflowerLogger logger) { 17 | engine = new Fernflower(provider, saver, options, logger); 18 | } 19 | 20 | public void addSource(File source) { 21 | engine.addSource(source); 22 | } 23 | 24 | public void addLibrary(File library) { 25 | engine.addLibrary(library); 26 | } 27 | 28 | /** @deprecated use {@link #addSource(File)} / {@link #addLibrary(File)} instead */ 29 | @Deprecated 30 | public void addSpace(File file, boolean own) { 31 | if (own) { 32 | addSource(file); 33 | } 34 | else { 35 | addLibrary(file); 36 | } 37 | } 38 | 39 | public void decompileContext() { 40 | try { 41 | engine.decompileContext(); 42 | } 43 | finally { 44 | engine.clearContext(); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/main/extern/IBytecodeProvider.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.main.extern; 3 | 4 | import java.io.IOException; 5 | 6 | public interface IBytecodeProvider { 7 | byte[] getBytecode(String externalPath, String internalPath) throws IOException; 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/main/extern/IFernflowerLogger.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.main.extern; 3 | 4 | public abstract class IFernflowerLogger { 5 | 6 | public enum Severity { 7 | TRACE("TRACE: "), INFO("INFO: "), WARN("WARN: "), ERROR("ERROR: "); 8 | 9 | public final String prefix; 10 | 11 | Severity(String prefix) { 12 | this.prefix = prefix; 13 | } 14 | } 15 | 16 | private Severity severity = Severity.INFO; 17 | 18 | public boolean accepts(Severity severity) { 19 | return severity.ordinal() >= this.severity.ordinal(); 20 | } 21 | 22 | public void setSeverity(Severity severity) { 23 | this.severity = severity; 24 | } 25 | 26 | public abstract void writeMessage(String message, Severity severity); 27 | 28 | public abstract void writeMessage(String message, Severity severity, Throwable t); 29 | 30 | public void writeMessage(String message, Throwable t) { 31 | writeMessage(message, Severity.ERROR, t); 32 | } 33 | 34 | public void startReadingClass(String className) { } 35 | 36 | public void endReadingClass() { } 37 | 38 | public void startClass(String className) { } 39 | 40 | public void endClass() { } 41 | 42 | public void startMethod(String methodName) { } 43 | 44 | public void endMethod() { } 45 | 46 | public void startWriteClass(String className) { } 47 | 48 | public void endWriteClass() { } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/main/extern/IIdentifierRenamer.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.main.extern; 3 | 4 | public interface IIdentifierRenamer { 5 | 6 | enum Type {ELEMENT_CLASS, ELEMENT_FIELD, ELEMENT_METHOD} 7 | 8 | boolean toBeRenamed(Type elementType, String className, String element, String descriptor); 9 | 10 | String getNextClassName(String fullName, String shortName); 11 | 12 | String getNextFieldName(String className, String field, String descriptor); 13 | 14 | String getNextMethodName(String className, String method, String descriptor); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/main/extern/IResultSaver.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.main.extern; 3 | 4 | import java.util.jar.Manifest; 5 | 6 | public interface IResultSaver { 7 | void saveFolder(String path); 8 | 9 | void copyFile(String source, String path, String entryName); 10 | 11 | void saveClassFile(String path, String qualifiedName, String entryName, String content, int[] mapping); 12 | 13 | void createArchive(String path, String archiveName, Manifest manifest); 14 | 15 | void saveDirEntry(String path, String archiveName, String entryName); 16 | 17 | void copyEntry(String source, String path, String archiveName, String entry); 18 | 19 | void saveClassEntry(String path, String archiveName, String qualifiedName, String entryName, String content); 20 | 21 | void closeArchive(String path, String archiveName); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/ClearStructHelper.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.modules.decompiler; 3 | 4 | import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement; 5 | import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; 6 | 7 | import java.util.LinkedList; 8 | 9 | 10 | public class ClearStructHelper { 11 | 12 | public static void clearStatements(RootStatement root) { 13 | 14 | LinkedList stack = new LinkedList<>(); 15 | stack.add(root); 16 | 17 | while (!stack.isEmpty()) { 18 | 19 | Statement stat = stack.removeFirst(); 20 | 21 | stat.clearTempInformation(); 22 | 23 | stack.addAll(stat.getStats()); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/ExprentStack.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.modules.decompiler; 3 | 4 | import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent; 5 | import org.jetbrains.java.decompiler.util.ListStack; 6 | 7 | public class ExprentStack extends ListStack { 8 | 9 | public ExprentStack() { 10 | } 11 | 12 | public ExprentStack(ListStack list) { 13 | super(list); 14 | pointer = list.getPointer(); 15 | } 16 | 17 | @Override 18 | public Exprent pop() { 19 | 20 | return this.remove(--pointer); 21 | } 22 | 23 | @Override 24 | public ExprentStack clone() { 25 | return new ExprentStack(this); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/PrimitiveExprsList.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.modules.decompiler; 3 | 4 | import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class PrimitiveExprsList { 10 | 11 | private final List lstExprents = new ArrayList<>(); 12 | 13 | private ExprentStack stack = new ExprentStack(); 14 | 15 | public PrimitiveExprsList() { 16 | } 17 | 18 | public PrimitiveExprsList copyStack() { 19 | PrimitiveExprsList prlst = new PrimitiveExprsList(); 20 | prlst.setStack(stack.clone()); 21 | return prlst; 22 | } 23 | 24 | public List getLstExprents() { 25 | return lstExprents; 26 | } 27 | 28 | public ExprentStack getStack() { 29 | return stack; 30 | } 31 | 32 | public void setStack(ExprentStack stack) { 33 | this.stack = stack; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/decompose/IGraph.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.modules.decompiler.decompose; 3 | 4 | import java.util.List; 5 | import java.util.Set; 6 | 7 | public interface IGraph { 8 | 9 | List getReversePostOrderList(); 10 | 11 | Set getRoots(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/decompose/IGraphNode.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.modules.decompiler.decompose; 3 | 4 | import java.util.List; 5 | 6 | public interface IGraphNode { 7 | 8 | List getPredecessors(); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/exps/AssertExprent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 3 | */ 4 | package org.jetbrains.java.decompiler.modules.decompiler.exps; 5 | 6 | import org.jetbrains.java.decompiler.util.TextBuffer; 7 | import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer; 8 | 9 | import java.util.List; 10 | 11 | public class AssertExprent extends Exprent { 12 | 13 | private final List parameters; 14 | 15 | public AssertExprent(List parameters) { 16 | super(EXPRENT_ASSERT); 17 | this.parameters = parameters; 18 | } 19 | 20 | @Override 21 | public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) { 22 | TextBuffer buffer = new TextBuffer(); 23 | 24 | buffer.append("assert "); 25 | 26 | tracer.addMapping(bytecode); 27 | 28 | if (parameters.get(0) == null) { 29 | buffer.append("false"); 30 | } 31 | else { 32 | buffer.append(parameters.get(0).toJava(indent, tracer)); 33 | } 34 | 35 | if (parameters.size() > 1) { 36 | buffer.append(" : "); 37 | buffer.append(parameters.get(1).toJava(indent, tracer)); 38 | } 39 | 40 | return buffer; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/stats/DummyExitStatement.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.modules.decompiler.stats; 3 | 4 | import java.util.Collection; 5 | import java.util.HashSet; 6 | import java.util.Set; 7 | 8 | /** 9 | * @author egor 10 | */ 11 | public class DummyExitStatement extends Statement { 12 | public Set bytecode = null; // offsets of bytecode instructions mapped to dummy exit 13 | 14 | public DummyExitStatement() { 15 | type = Statement.TYPE_DUMMYEXIT; 16 | } 17 | 18 | public void addBytecodeOffsets(Collection bytecodeOffsets) { 19 | if (bytecodeOffsets != null && !bytecodeOffsets.isEmpty()) { 20 | if (bytecode == null) { 21 | bytecode = new HashSet<>(bytecodeOffsets); 22 | } 23 | else { 24 | bytecode.addAll(bytecodeOffsets); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/stats/RootStatement.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.modules.decompiler.stats; 3 | 4 | import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer; 5 | import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor; 6 | import org.jetbrains.java.decompiler.util.TextBuffer; 7 | 8 | public class RootStatement extends Statement { 9 | private final DummyExitStatement dummyExit; 10 | 11 | public RootStatement(Statement head, DummyExitStatement dummyExit) { 12 | type = Statement.TYPE_ROOT; 13 | 14 | first = head; 15 | this.dummyExit = dummyExit; 16 | 17 | stats.addWithKey(first, first.id); 18 | first.setParent(this); 19 | } 20 | 21 | @Override 22 | public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) { 23 | return ExprProcessor.listToJava(varDefinitions, indent, tracer).append(first.toJava(indent, tracer)); 24 | } 25 | 26 | public DummyExitStatement getDummyExit() { 27 | return dummyExit; 28 | } 29 | } -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/vars/CheckTypesResult.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.modules.decompiler.vars; 3 | 4 | import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent; 5 | import org.jetbrains.java.decompiler.struct.gen.VarType; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | public class CheckTypesResult { 11 | private final List lstMaxTypeExprents = new ArrayList<>(); 12 | private final List lstMinTypeExprents = new ArrayList<>(); 13 | 14 | public void addMaxTypeExprent(Exprent exprent, VarType type) { 15 | lstMaxTypeExprents.add(new ExprentTypePair(exprent, type)); 16 | } 17 | 18 | public void addMinTypeExprent(Exprent exprent, VarType type) { 19 | lstMinTypeExprents.add(new ExprentTypePair(exprent, type)); 20 | } 21 | 22 | public List getLstMaxTypeExprents() { 23 | return lstMaxTypeExprents; 24 | } 25 | 26 | public List getLstMinTypeExprents() { 27 | return lstMinTypeExprents; 28 | } 29 | 30 | public static class ExprentTypePair { 31 | public final Exprent exprent; 32 | public final VarType type; 33 | 34 | public ExprentTypePair(Exprent exprent, VarType type) { 35 | this.exprent = exprent; 36 | this.type = type; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionEdge.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.modules.decompiler.vars; 3 | 4 | public class VarVersionEdge { // FIXME: can be removed? 5 | 6 | public static final int EDGE_GENERAL = 0; 7 | public static final int EDGE_PHANTOM = 1; 8 | 9 | public final int type; 10 | 11 | public final VarVersionNode source; 12 | 13 | public final VarVersionNode dest; 14 | 15 | private final int hashCode; 16 | 17 | public VarVersionEdge(int type, VarVersionNode source, VarVersionNode dest) { 18 | this.type = type; 19 | this.source = source; 20 | this.dest = dest; 21 | this.hashCode = source.hashCode() ^ dest.hashCode() + type; 22 | } 23 | 24 | @Override 25 | public boolean equals(Object o) { 26 | if (o == this) return true; 27 | if (!(o instanceof VarVersionEdge)) return false; 28 | 29 | VarVersionEdge edge = (VarVersionEdge)o; 30 | return type == edge.type && source == edge.source && dest == edge.dest; 31 | } 32 | 33 | @Override 34 | public int hashCode() { 35 | return hashCode; 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | return source.toString() + " ->" + type + "-> " + dest.toString(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionPair.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.modules.decompiler.vars; 3 | 4 | import org.jetbrains.java.decompiler.modules.decompiler.exps.VarExprent; 5 | 6 | public class VarVersionPair { 7 | 8 | public final int var; 9 | public final int version; 10 | 11 | private int hashCode = -1; 12 | 13 | public VarVersionPair(int var, int version) { 14 | this.var = var; 15 | this.version = version; 16 | } 17 | 18 | public VarVersionPair(Integer var, Integer version) { 19 | this.var = var; 20 | this.version = version; 21 | } 22 | 23 | public VarVersionPair(VarExprent var) { 24 | this.var = var.getIndex(); 25 | this.version = var.getVersion(); 26 | } 27 | 28 | @Override 29 | public boolean equals(Object o) { 30 | if (o == this) return true; 31 | if (!(o instanceof VarVersionPair)) return false; 32 | 33 | VarVersionPair paar = (VarVersionPair)o; 34 | return var == paar.var && version == paar.version; 35 | } 36 | 37 | @Override 38 | public int hashCode() { 39 | if (hashCode == -1) { 40 | hashCode = this.var * 3 + this.version; 41 | } 42 | return hashCode; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return "(" + var + "," + version + ")"; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/renamer/ClassWrapperNode.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.modules.renamer; 3 | 4 | import org.jetbrains.java.decompiler.struct.StructClass; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class ClassWrapperNode { 10 | private final StructClass classStruct; 11 | private final List subclasses = new ArrayList<>(); 12 | 13 | public ClassWrapperNode(StructClass cl) { 14 | this.classStruct = cl; 15 | } 16 | 17 | public void addSubclass(ClassWrapperNode node) { 18 | subclasses.add(node); 19 | } 20 | 21 | public StructClass getClassStruct() { 22 | return classStruct; 23 | } 24 | 25 | public List getSubclasses() { 26 | return subclasses; 27 | } 28 | } -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/modules/renamer/PoolInterceptor.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.modules.renamer; 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | public class PoolInterceptor { 8 | private final Map mapOldToNewNames = new HashMap<>(); 9 | private final Map mapNewToOldNames = new HashMap<>(); 10 | 11 | public void addName(String oldName, String newName) { 12 | mapOldToNewNames.put(oldName, newName); 13 | mapNewToOldNames.put(newName, oldName); 14 | } 15 | 16 | public String getName(String oldName) { 17 | return mapOldToNewNames.get(oldName); 18 | } 19 | 20 | public String getOldName(String newName) { 21 | return mapNewToOldNames.get(newName); 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/IDecompiledData.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.struct; 3 | 4 | public interface IDecompiledData { 5 | 6 | String getClassEntryName(StructClass cl, String entryname); 7 | 8 | String getClassContent(StructClass cl); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/StructField.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.struct; 3 | 4 | import org.jetbrains.java.decompiler.struct.consts.ConstantPool; 5 | import org.jetbrains.java.decompiler.util.DataInputFullStream; 6 | 7 | import java.io.IOException; 8 | 9 | /* 10 | field_info { 11 | u2 access_flags; 12 | u2 name_index; 13 | u2 descriptor_index; 14 | u2 attributes_count; 15 | attribute_info attributes[attributes_count]; 16 | } 17 | */ 18 | public class StructField extends StructMember { 19 | 20 | private final String name; 21 | private final String descriptor; 22 | 23 | 24 | public StructField(DataInputFullStream in, StructClass clStruct) throws IOException { 25 | accessFlags = in.readUnsignedShort(); 26 | int nameIndex = in.readUnsignedShort(); 27 | int descriptorIndex = in.readUnsignedShort(); 28 | 29 | ConstantPool pool = clStruct.getPool(); 30 | String[] values = pool.getClassElement(ConstantPool.FIELD, clStruct.qualifiedName, nameIndex, descriptorIndex); 31 | name = values[0]; 32 | descriptor = values[1]; 33 | 34 | attributes = readAttributes(in, pool); 35 | } 36 | 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | public String getDescriptor() { 42 | return descriptor; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return name; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/attr/StructAnnDefaultAttribute.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.struct.attr; 3 | 4 | import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent; 5 | import org.jetbrains.java.decompiler.struct.consts.ConstantPool; 6 | import org.jetbrains.java.decompiler.util.DataInputFullStream; 7 | 8 | import java.io.IOException; 9 | 10 | public class StructAnnDefaultAttribute extends StructGeneralAttribute { 11 | 12 | private Exprent defaultValue; 13 | 14 | @Override 15 | public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { 16 | defaultValue = StructAnnotationAttribute.parseAnnotationElement(data, pool); 17 | } 18 | 19 | public Exprent getDefaultValue() { 20 | return defaultValue; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/attr/StructAnnotationParameterAttribute.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.struct.attr; 3 | 4 | import org.jetbrains.java.decompiler.modules.decompiler.exps.AnnotationExprent; 5 | import org.jetbrains.java.decompiler.struct.consts.ConstantPool; 6 | import org.jetbrains.java.decompiler.util.DataInputFullStream; 7 | 8 | import java.io.IOException; 9 | import java.util.ArrayList; 10 | import java.util.Collections; 11 | import java.util.List; 12 | 13 | public class StructAnnotationParameterAttribute extends StructGeneralAttribute { 14 | 15 | private List> paramAnnotations; 16 | 17 | @Override 18 | public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { 19 | int len = data.readUnsignedByte(); 20 | if (len > 0) { 21 | paramAnnotations = new ArrayList<>(len); 22 | for (int i = 0; i < len; i++) { 23 | List annotations = StructAnnotationAttribute.parseAnnotations(pool, data); 24 | paramAnnotations.add(annotations); 25 | } 26 | } 27 | else { 28 | paramAnnotations = Collections.emptyList(); 29 | } 30 | } 31 | 32 | public List> getParamAnnotations() { 33 | return paramAnnotations; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/attr/StructConstantValueAttribute.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.struct.attr; 3 | 4 | import org.jetbrains.java.decompiler.struct.consts.ConstantPool; 5 | import org.jetbrains.java.decompiler.util.DataInputFullStream; 6 | 7 | import java.io.IOException; 8 | 9 | public class StructConstantValueAttribute extends StructGeneralAttribute { 10 | 11 | private int index; 12 | 13 | @Override 14 | public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { 15 | index = data.readUnsignedShort(); 16 | } 17 | 18 | public int getIndex() { 19 | return index; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/attr/StructEnclosingMethodAttribute.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.struct.attr; 3 | 4 | import org.jetbrains.java.decompiler.struct.consts.ConstantPool; 5 | import org.jetbrains.java.decompiler.struct.consts.LinkConstant; 6 | import org.jetbrains.java.decompiler.util.DataInputFullStream; 7 | 8 | import java.io.IOException; 9 | 10 | public class StructEnclosingMethodAttribute extends StructGeneralAttribute { 11 | 12 | private String className; 13 | private String methodName; 14 | private String methodDescriptor; 15 | 16 | @Override 17 | public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { 18 | int classIndex = data.readUnsignedShort(); 19 | int methodIndex = data.readUnsignedShort(); 20 | 21 | className = pool.getPrimitiveConstant(classIndex).getString(); 22 | if (methodIndex != 0) { 23 | LinkConstant lk = pool.getLinkConstant(methodIndex); 24 | methodName = lk.elementname; 25 | methodDescriptor = lk.descriptor; 26 | } 27 | } 28 | 29 | public String getClassName() { 30 | return className; 31 | } 32 | 33 | public String getMethodDescriptor() { 34 | return methodDescriptor; 35 | } 36 | 37 | public String getMethodName() { 38 | return methodName; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/attr/StructExceptionsAttribute.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.struct.attr; 3 | 4 | import org.jetbrains.java.decompiler.struct.consts.ConstantPool; 5 | import org.jetbrains.java.decompiler.util.DataInputFullStream; 6 | 7 | import java.io.IOException; 8 | import java.util.ArrayList; 9 | import java.util.Collections; 10 | import java.util.List; 11 | 12 | public class StructExceptionsAttribute extends StructGeneralAttribute { 13 | 14 | private List throwsExceptions; 15 | 16 | @Override 17 | public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { 18 | int len = data.readUnsignedShort(); 19 | if (len > 0) { 20 | throwsExceptions = new ArrayList<>(len); 21 | for (int i = 0; i < len; i++) { 22 | throwsExceptions.add(data.readUnsignedShort()); 23 | } 24 | } 25 | else { 26 | throwsExceptions = Collections.emptyList(); 27 | } 28 | } 29 | 30 | public String getExcClassname(int index, ConstantPool pool) { 31 | return pool.getPrimitiveConstant(throwsExceptions.get(index)).getString(); 32 | } 33 | 34 | public List getThrowsExceptions() { 35 | return throwsExceptions; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/attr/StructGenericSignatureAttribute.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.struct.attr; 3 | 4 | import org.jetbrains.java.decompiler.struct.consts.ConstantPool; 5 | import org.jetbrains.java.decompiler.util.DataInputFullStream; 6 | 7 | import java.io.IOException; 8 | 9 | public class StructGenericSignatureAttribute extends StructGeneralAttribute { 10 | 11 | private String signature; 12 | 13 | @Override 14 | public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { 15 | int index = data.readUnsignedShort(); 16 | signature = pool.getPrimitiveConstant(index).getString(); 17 | } 18 | 19 | public String getSignature() { 20 | return signature; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/consts/PooledConstant.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.struct.consts; 3 | 4 | import org.jetbrains.java.decompiler.code.CodeConstants; 5 | 6 | public class PooledConstant implements CodeConstants { 7 | public final int type; 8 | 9 | public PooledConstant(int type) { 10 | this.type = type; 11 | } 12 | 13 | public void resolveConstant(ConstantPool pool) { } 14 | } -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/consts/PrimitiveConstant.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.struct.consts; 3 | 4 | public class PrimitiveConstant extends PooledConstant { 5 | public int index; 6 | public Object value; 7 | public boolean isArray; 8 | 9 | public PrimitiveConstant(int type, Object value) { 10 | super(type); 11 | this.value = value; 12 | 13 | initConstant(); 14 | } 15 | 16 | public PrimitiveConstant(int type, int index) { 17 | super(type); 18 | this.index = index; 19 | } 20 | 21 | private void initConstant() { 22 | if (type == CONSTANT_Class) { 23 | String className = getString(); 24 | isArray = (className.length() > 0 && className.charAt(0) == '['); // empty string for a class name seems to be possible in some android files 25 | } 26 | } 27 | 28 | public String getString() { 29 | return (String)value; 30 | } 31 | 32 | @Override 33 | public void resolveConstant(ConstantPool pool) { 34 | if (type == CONSTANT_Class || type == CONSTANT_String || type == CONSTANT_MethodType) { 35 | value = pool.getPrimitiveConstant(index).getString(); 36 | initConstant(); 37 | } 38 | } 39 | 40 | @Override 41 | public boolean equals(Object o) { 42 | if (o == this) return true; 43 | if (!(o instanceof PrimitiveConstant)) return false; 44 | 45 | PrimitiveConstant cn = (PrimitiveConstant)o; 46 | return this.type == cn.type && 47 | this.isArray == cn.isArray && 48 | this.value.equals(cn.value); 49 | } 50 | } -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/gen/NewClassNameBuilder.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.struct.gen; 3 | 4 | public interface NewClassNameBuilder { 5 | String buildNewClassname(String className); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/gen/generics/GenericClassDescriptor.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.struct.gen.generics; 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | public class GenericClassDescriptor { 8 | 9 | public GenericType superclass; 10 | 11 | public final List superinterfaces = new ArrayList<>(); 12 | 13 | public final List fparameters = new ArrayList<>(); 14 | 15 | public final List> fbounds = new ArrayList<>(); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/gen/generics/GenericFieldDescriptor.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.struct.gen.generics; 3 | 4 | public class GenericFieldDescriptor { 5 | public final GenericType type; 6 | 7 | public GenericFieldDescriptor(GenericType type) { 8 | this.type = type; 9 | } 10 | } -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/gen/generics/GenericMethodDescriptor.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.struct.gen.generics; 3 | 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | public class GenericMethodDescriptor { 8 | public final List typeParameters; 9 | public final List> typeParameterBounds; 10 | public final List parameterTypes; 11 | public final GenericType returnType; 12 | public final List exceptionTypes; 13 | 14 | public GenericMethodDescriptor(List typeParameters, 15 | List> typeParameterBounds, 16 | List parameterTypes, 17 | GenericType returnType, 18 | List exceptionTypes) { 19 | this.typeParameters = substitute(typeParameters); 20 | this.typeParameterBounds = substitute(typeParameterBounds); 21 | this.parameterTypes = substitute(parameterTypes); 22 | this.returnType = returnType; 23 | this.exceptionTypes = substitute(exceptionTypes); 24 | } 25 | 26 | private static List substitute(List list) { 27 | return list.isEmpty() ? Collections.emptyList() : list; 28 | } 29 | } -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/struct/match/IMatchable.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.struct.match; 3 | 4 | public interface IMatchable { 5 | enum MatchProperties { 6 | STATEMENT_TYPE, 7 | STATEMENT_RET, 8 | STATEMENT_STATSIZE, 9 | STATEMENT_EXPRSIZE, 10 | STATEMENT_POSITION, 11 | STATEMENT_IFTYPE, 12 | 13 | EXPRENT_TYPE, 14 | EXPRENT_RET, 15 | EXPRENT_POSITION, 16 | EXPRENT_FUNCTYPE, 17 | EXPRENT_EXITTYPE, 18 | EXPRENT_CONSTTYPE, 19 | EXPRENT_CONSTVALUE, 20 | EXPRENT_INVOCATION_CLASS, 21 | EXPRENT_INVOCATION_SIGNATURE, 22 | EXPRENT_INVOCATION_PARAMETER, 23 | EXPRENT_VAR_INDEX, 24 | EXPRENT_FIELD_NAME, 25 | } 26 | 27 | IMatchable findObject(MatchNode matchNode, int index); 28 | 29 | boolean match(MatchNode matchNode, MatchEngine engine); 30 | } -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/util/DataInputFullStream.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.util; 3 | 4 | import java.io.ByteArrayInputStream; 5 | import java.io.DataInputStream; 6 | import java.io.IOException; 7 | 8 | public class DataInputFullStream extends DataInputStream { 9 | public DataInputFullStream(byte[] bytes) { 10 | super(new ByteArrayInputStream(bytes)); 11 | } 12 | 13 | public byte[] read(int n) throws IOException { 14 | return InterpreterUtil.readBytes(this, n); 15 | } 16 | 17 | public void discard(int n) throws IOException { 18 | InterpreterUtil.discardBytes(this, n); 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/java/org/jetbrains/java/decompiler/util/ListStack.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. 2 | package org.jetbrains.java.decompiler.util; 3 | 4 | import java.util.ArrayList; 5 | 6 | public class ListStack extends ArrayList { 7 | protected int pointer = 0; 8 | 9 | public ListStack() { 10 | super(); 11 | } 12 | 13 | public ListStack(ArrayList list) { 14 | super(list); 15 | } 16 | 17 | @Override 18 | @SuppressWarnings("MethodDoesntCallSuperMethod") 19 | public ListStack clone() { 20 | ListStack copy = new ListStack<>(this); 21 | copy.pointer = this.pointer; 22 | return copy; 23 | } 24 | 25 | public void push(T item) { 26 | this.add(item); 27 | pointer++; 28 | } 29 | 30 | public T pop() { 31 | pointer--; 32 | T o = this.get(pointer); 33 | this.remove(pointer); 34 | return o; 35 | } 36 | 37 | public T pop(int count) { 38 | T o = null; 39 | for (int i = count; i > 0; i--) { 40 | o = this.pop(); 41 | } 42 | return o; 43 | } 44 | 45 | public void removeMultiple(int count) { 46 | while (count > 0) { 47 | pointer--; 48 | this.remove(pointer); 49 | count--; 50 | } 51 | } 52 | 53 | public int getPointer() { 54 | return pointer; 55 | } 56 | 57 | public T getByOffset(int offset) { 58 | return this.get(pointer + offset); 59 | } 60 | 61 | public void insertByOffset(int offset, T item) { 62 | this.add(pointer + offset, item); 63 | pointer++; 64 | } 65 | 66 | @Override 67 | public void clear() { 68 | super.clear(); 69 | pointer = 0; 70 | } 71 | } -------------------------------------------------------------------------------- /src/main/resources/resources/access/abstract.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/access/abstract.png -------------------------------------------------------------------------------- /src/main/resources/resources/access/final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/access/final.png -------------------------------------------------------------------------------- /src/main/resources/resources/access/native.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/access/native.png -------------------------------------------------------------------------------- /src/main/resources/resources/access/static.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/access/static.png -------------------------------------------------------------------------------- /src/main/resources/resources/access/synthetic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/access/synthetic.png -------------------------------------------------------------------------------- /src/main/resources/resources/classtype/enum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/classtype/enum.png -------------------------------------------------------------------------------- /src/main/resources/resources/classtype/interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/classtype/interface.png -------------------------------------------------------------------------------- /src/main/resources/resources/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/file.png -------------------------------------------------------------------------------- /src/main/resources/resources/icon_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/icon_close.png -------------------------------------------------------------------------------- /src/main/resources/resources/jar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/jar.png -------------------------------------------------------------------------------- /src/main/resources/resources/java.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/java.png -------------------------------------------------------------------------------- /src/main/resources/resources/krakatau.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/krakatau.zip -------------------------------------------------------------------------------- /src/main/resources/resources/method/methdef.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/method/methdef.png -------------------------------------------------------------------------------- /src/main/resources/resources/method/methpri.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/method/methpri.png -------------------------------------------------------------------------------- /src/main/resources/resources/method/methpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/method/methpro.png -------------------------------------------------------------------------------- /src/main/resources/resources/method/methpub.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/method/methpub.png -------------------------------------------------------------------------------- /src/main/resources/resources/package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/package.png -------------------------------------------------------------------------------- /src/main/resources/resources/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/search.png -------------------------------------------------------------------------------- /src/main/resources/resources/toolbar/load.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/toolbar/load.png -------------------------------------------------------------------------------- /src/main/resources/resources/toolbar/plug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/toolbar/plug.png -------------------------------------------------------------------------------- /src/main/resources/resources/toolbar/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/toolbar/refresh.png -------------------------------------------------------------------------------- /src/main/resources/resources/toolbar/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/toolbar/save.png -------------------------------------------------------------------------------- /src/main/resources/resources/toolbar/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/toolbar/search.png -------------------------------------------------------------------------------- /src/main/resources/resources/toolbar/table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/toolbar/table.png -------------------------------------------------------------------------------- /src/main/resources/resources/txt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/txt.png -------------------------------------------------------------------------------- /src/main/resources/resources/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DotRacel/JByteMod-Reborn/5973de95baed24461033e3ae8e1aef71f64543e6/src/main/resources/resources/warning.png --------------------------------------------------------------------------------