Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation as a plugin #3

Open
NewDwarf opened this issue Jul 16, 2022 · 7 comments
Open

Implementation as a plugin #3

NewDwarf opened this issue Jul 16, 2022 · 7 comments

Comments

@NewDwarf
Copy link

How do you think whether it is possible to implement the obfuscator as a LLVM plugin?
It would be very flexible solution for using with different toolchains.
As an example, following project can be taken.
https://polarply.medium.com/build-your-first-llvm-obfuscator-80d16583392b
https://github.com/tsarpaul/llvm-string-obfuscator

The idea is clear and simple. First, we generate the bitcode then process the bitcode with our plugin and after that translate it to the native code.

clang -emit-llvm hello.c -c -o hello.bc
opt -load-pass-plugin=./build/StringObfuscator/libLLVMStringObfuscator.so -passes="string-obfuscator-pass" < hello.bc -o out.bc
llc out.bc -o out.s
clang -static out.s -o out
@Deniskore
Copy link
Owner

Yes, it is possible, but this approach does not work for all platforms, in the past one of my main tasks was to support Windows.

@NewDwarf
Copy link
Author

NewDwarf commented Jul 16, 2022

What kind of the issues on running on the Windows platform?
And, by the way, can we replace the platform dependent piece of code (__rdtsc())

XorShift() {
    s[0] = __rdtsc();
    s[1] = (uint64_t)__rdtsc() * rotl(s[0], 5);
    jump();
  }

on the platform independent c++ implementation https://en.cppreference.com/w/cpp/numeric/random

@NewDwarf
Copy link
Author

NewDwarf commented Aug 8, 2022

@Deniskore Any update?

@Deniskore
Copy link
Owner

What kind of the issues on running on the Windows platform? And, by the way, can we replace the platform dependent piece of code (__rdtsc())

XorShift() {
    s[0] = __rdtsc();
    s[1] = (uint64_t)__rdtsc() * rotl(s[0], 5);
    jump();
  }

on the platform independent c++ implementation https://en.cppreference.com/w/cpp/numeric/random

C++ random is very slow. If you notice, this random function is called very often.
I will add support(#1) for other platforms and support for LLVM 14 when I have time.

@NewDwarf
Copy link
Author

NewDwarf commented Aug 8, 2022

I meant "implement it as a plugin" as it is more natural design to implement passes as pluggable module rather than modifying the LLVM's source code.
I guess fixing of #1 is pretty straightforward. I would try to port it by myself but it requires understanding of the obfuscator design in great details.

@Deniskore
Copy link
Owner

Deniskore commented Sep 10, 2022

@NewDwarf Sorry for the delay, I will make a separate version of the obfuscator as a plugin. Also in the not so distant future, I will release a new version based on LLVM 15.

@NewDwarf
Copy link
Author

NewDwarf commented Sep 10, 2022

@Deniskore That would be nice! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants