Open FredyR4zox opened 3 years ago
The most likely problem is, that you are combining RetDec and vanilla LLVM. At the moment, we use modified LLVM 8.0.0 that comes with RetDec. If you use a different LLVM version, or vanilla (unmodified) correct version, it probably won't end up well.
If that won't work either, let me know, I can try to reproduce it more thoroughly.
If you succeed, great. Now, do you really need vanilla LLVM, or can you make do with slightly modified LLVM 8? We can discuss this more when it works.
The ideal would be if RetDec could use vanilla LLVM, but we are not there yet.
Another question: I know that i can't compile the program again to the binary form and that means that i can't JIT it using LLVM right? Only make manual analysis. Is this correct? I have read other issues in github that state this (the re-compile part).
Well, you could try, but because we don't aim at this (missing complex semantics) and we use only static analysis (hard to get everything right), and there is a bunch of bugs and inaccuracies, I don't think you would get anything that could really fully run again.
However, you don't necessarily have to do only manual analysis. After you decode the binary, you can pipe LLVM IR to your LLVM pass at any point - i.e. at any point after retdec-decoder
pass, you have a valid LLVM IR module to work with. You don't have to run all the analyses, only the ones that you want, and you can then run any custom analysis you write. It's just that I think the IR quality is not enough to recompile it. Analysis passes that automatically inspect the IR in order to make sense of it are feasible. Also, if you find some problems, we can make it better.
Try to use only one LLVM - the one that comes with RetDec. Use CMake similar to the example retdectool. As you can see, there are some ugly extra compiler options. Maybe you won't need them (try it without them at first), but if there is some problem, adding them might help - they have something to do with LLVM being huge hard to link.
I've tried to only use the LLVM in retdec and it doesnt work. While executing, it gives back and error. The error is very similar to the one i get in the issue. I haven't tried to compile it with the retdectool flags, will try.
However, you don't necessarily have to do only manual analysis. After you decode the binary, you can pipe LLVM IR to your LLVM pass at any point - i.e. at any point after retdec-decoder pass, you have a valid LLVM IR module to work with. You don't have to run all the analyses, only the ones that you want, and you can then run any custom analysis you write.
Nice! That is what i was looking for.
It's just that I think the IR quality is not enough to recompile it. Analysis passes that automatically inspect the IR in order to make sense of it are feasible. Also, if you find some problems, we can make it better.
The IR quality is not enough to recompile it, but all valid IR isn't compilable? I would want to make analysis and transform the IR. Is this feasible?
I've tried to only use the LLVM in retdec and it doesnt work. While executing, it gives back and error. The error is very similar to the one i get in the issue. I haven't tried to compile it with the retdectool flags, will try.
I will try to use it outside of RetDec repo and investigate what is needed in order to work.
The IR quality is not enough to recompile it, but all valid IR isn't compilable? I would want to make analysis and transform the IR. Is this feasible?
It should be valid, therefore it should be compilable. But it may not (and probably won't) have exactly the same functionality as the original - some things are simplified, omitted, etc. As an entire program, this is unlikely to work. On a function level, it might be possible.
Hi, thank you for making this project available to the community.
I have a problem when using the new retdec C++ library and the LLVM framework. If i use both of them separate, they work just fine. The problem is when the two are in the same program.
Using libraries: Retdec: https://github.com/avast/retdec/commit/6ed327e30fd2bbd45767ff45eae7cfd63fdfc2f1 LLVM: https://github.com/llvm/llvm-project/releases/tag/llvmorg-11.0.1
I compiled both of them and installed system wide.
I copied the example program in the retdec blog post: https://engineering.avast.io/retdec-v4-0-is-out/ - "4. retdec library" And i copied the LLVM example program Fibonacci: https://github.com/llvm/llvm-project/tree/main/llvm/examples/Fibonacci This is my final code:
lift_jit_pass.cpp
CMakeLists.txt
Problem when running:
Does anyone know why is this happening? Maybe the LLVM versions (LLVM 11 and the custom LLVM for retdec) are in conflict.
Another question: I know that i can't compile the program again to the binary form and that means that i can't JIT it using LLVM right? Only make manual analysis. Is this correct? I have read other issues in github that state this (the re-compile part).
PS. (not related): My objective is to make a tool or framework to deobfuscate obfuscated binaries by lifting them and apply deobfuscation techniques to it.