CalebFenton / simplify

Android virtual machine and deobfuscator
Other
4.41k stars 438 forks source link

How to use SmaliVM? #152

Closed siair closed 3 years ago

siair commented 3 years ago

Where are examples? I read the following post and I am confused.

http://calebfenton.github.io/2016/04/30/dalvik-virtual-execution-with-smalivm/

Where should this code be executed?

VirtualMachineFactory vmFactory = new VirtualMachineFactory(); VirtualMachine vm = vmFactory.build("classes.dex"); String methodSignature = "Lorg/cf/example/Main;->foo(Ljava/lang/String;)V"; ExecutionContext ectx = vm.spawnRootContext(methodSignature); MethodState mState = ectx.getMethodState(); mState.assignParameter(0, "wubalubadubdub", "Ljava/lang/String;"); ExecutionGraph graph = vm.execute(methodSignature, ectx);

I want to find the return value of a function from an apk. Its value is a constant. How can I do it? Can SmaliVM find out the return value of this function?

CalebFenton commented 3 years ago

This seems like a general question on how to write java programs. This isn't the best place for that.

Create a java project, add smalivm as dependency, retrofit the code to point to your dex or apk and the method signature you care about. Then setup any caller state aka method arguments as shown in the example above. Get the graph by executing and get the terminating register consensus. Look at the tests and example app for more info.

siair commented 3 years ago

I know that this question is not suitable for posting here, but I searched the Internet and found only an article (http://calebfenton.github.io/2016/04/30/dalvik-virtual-execution-with-smalivm/) introducing this tool, and it is totally incomprehensible for beginners. There is no manual, no documentation, how can this be used? I saw the introduction of this project and I always thought it was great. I thought this was the tool I was looking for. It can easily find the return value of a confused function from the apk and remove useless algorithms or functions that deceive people.. But when I was about to start, I realized that I was at a loss and didn't know how to do it. I searched the Internet and couldn't find a complete example. This is really desperate!

I just want to find a constant from an apk. After complicated confusion, I can't find a clue. Because it is a function return value, although layers of confusion, hidden without a trace, I know it is a fixed value. There are no examples for reference, which is frustrating.

It would be good if there was a complete practical example suitable for beginners.

CalebFenton commented 3 years ago

Your root issue seems to be how you approach problems. Did you try my suggestion? Did you read the README? Did you read the demoapp code (mentioned in the readme)? Did you look at any of the tests? Did you read some tutorials on Java? Please try to stick to technical issues -- explain what you tried and what you don't understand specifically.

There are many ways to run a single function.