写点什么

Threadtear:一款多功能 Java 代码反混淆工具套件

用户头像
极客good
关注
发布于: 刚刚

如果你不想下载项目源码的话,你还可以直接使用该项目 Release 页面提供的最新版本


https://github.com/GraxCode/threadtear/releases


工具使用


=======================================================================


我们可以直接通过扩展


me.nov.threadtear.execution.Execution 方法来创建自己的执行任务:


public class MyExecution extends Execution {


public MyExecution() {


super(ExecutionCategory.CLEANING /* category /, "My execution" / name */,


"Executes something" /* description, can use html */);


}


/**


  • This method is invoked when the user clicks on the Run button

  • @return true if success, false if failure


*/


@Override


public boolean execute(Map<String, Clazz> classes, boolean verbose) {


classes.values().stream().map(c -> c.node).forEach(c -> {


//transform the classes here using the tree-API of ASM


});


return false;


}


}


在运行时加载 ClassNodes 类,可以直接使用?


me.nov.threadtear.asm.vm.VM 类并实现?


me.nov.threadtear.asm.vm.IVMReferenceHandler 方法:


public class MyExecution extends Execution implements IVMReferenceHandler {


public MyExecution() {


super(ExecutionCategory.GENERIC, "My execution", "Loads ClassNodes at runtime");


}


@Override


public boolean execute(Map<String, Clazz> classes, boolean verbose) {


classes.values().stream().map(c -> c.node).forEach(c -> {


VM vm = VM.constructVM(this);


//transform bytecode to java.lang.Class


Class<?> loadedClass = vm.loadClass(c.name.replace('/', '.'), true);


//do stuff with your class here


loadedClass.getMethods[0].invoke(...);


return true;


});


}


/**


  • Will get invoked by VM, when VM.loadClass is called


*/


@Override


public ClassNode tryClassLoad(String name) {


//try to find the class to be loaded in open jar archive


return classes.containsKey(name) ? classes.get(name).node : null;


}


}


通过使用?


me.nov.threadtear.analysis.stack.ConstantTracker 方法,你可以分析目标代码中的方法并追踪非变量栈值:


public class MyExecution extends Execution implements IConstantReferenceHandler {


public MyExecution() {


super(ExecutionCategory.GENERIC, "My execution", "Performs stack analysis and replaces code.");


}


@Override


public boolean execute(Map<String, Clazz> classes, boolean verbose) {


classes.values().stream().map(c -> c.node).forEach(this::analyzeAndRewrite);


retu


【一线大厂Java面试题解析+核心总结学习笔记+最新架构讲解视频+实战项目源码讲义】
浏览器打开:qq.cn.hn/FTf 免费领取
复制代码


rn true;


}


public void analyzeAndRewrite(ClassNode cn) {


cn.methods.forEach(m -> {


// this analyzer keeps known stack values, e.g. can be useful for jump prediction


Analyzer<ConstantValue> a = new Analyzer<ConstantValue>(new ConstantTracker(this, Access.isStatic(m.access), m.maxLocals, m.desc, new Object[0]));


try {


a.analyze(cn.name, m);


} catch (AnalyzerException e) {


logger.severe("Failed stack analysis in " + cn.name + "." + m.name + ":" + e.getMessage());


return;


}


Frame<ConstantValue>[] frames = a.getFrames();


InsnList rewrittenCode = new InsnList();


Map<LabelNode, LabelNode> labels = Instructions.cloneLabels(m.instructions);


// rewrite method instructions


for (int i = 0; i < m.instructions.size(); i++) {


AbstractInsnNode ain = m.instructions.get(i);


Frame<ConstantValue> frame = frames[i];


// replace / modify instructions, etc...


if (frame.getStackSize() > 0) {


ConstantValue top = frame.getStack(frame.getStackSize() - 1);


if (top.isKnown() && top.isInteger()) {

用户头像

极客good

关注

还未添加个人签名 2021.03.18 加入

还未添加个人简介

评论

发布
暂无评论
Threadtear:一款多功能Java代码反混淆工具套件