Coder Social home page Coder Social logo

open-obfuscator / o-mvll Goto Github PK

View Code? Open in Web Editor NEW
562.0 562.0 63.0 766 KB

:electron: O-MVLL is a LLVM-based obfuscator for native code (Android & iOS)

Home Page: https://obfuscator.re/omvll

License: Apache License 2.0

Shell 6.43% CMake 4.15% C++ 75.76% Python 3.29% C 8.67% Dockerfile 0.71% LLVM 0.99%
android ios llvm obfuscator obfuscator-llvm

o-mvll's People

Contributors

antoniofrighetto avatar marcobrador avatar romainthomas avatar sevils avatar stelian42 avatar weliveindetail avatar xxr0ss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

o-mvll's Issues

Feature obfuscate_struct_access crash during startup

How to reproduce:

Using the following configuration:

import omvll
from functools import lru_cache

class MyConfig(omvll.ObfuscationConfig):
def init(self):
super().init()
def obfuscate_arithmetic(self, mod: omvll.Module,
fun: omvll.Function) -> omvll.ArithmeticOpt:
return True

def flatten_cfg(self, mod: omvll.Module, func: omvll.Function):
return True

def obfuscate_constants(_, __, func: omvll.Function):
return True

def obfuscate_struct_access(self, _: omvll.Module, __: omvll.Function,
struct: omvll.Struct):
return True

def obfuscate_string(self, _, __, string: bytes):
return omvll.StringEncOptStack()

@lru_cache(maxsize=1)
def omvll_get_config() -> omvll.ObfuscationConfig:
"""
Return an instance of ObfuscationConfig which
aims at describing the obfuscation scheme
"""
return MyConfig()

Is failing.

If I remove the struct access feature it works fine.

Prebuilt LLVM needs X86 MC backend for JIT execution

OS: Linux manjaro 6.1.38-1-MANJARO #1 SMP PREEMPT_DYNAMIC Wed Jul 5 23:49:30 UTC 2023 x86_64 GNU/Linux
Dokcer build libOMVLL.so.

export OMVLL_CONFIG=/home/junknet/Desktop/test.py
export OMVLL_PYTHONPATH=/home/junknet/Downloads/Python-3.10.7/Lib 
cd  /home/junknet/Downloads/android-ndk-r25c-linux/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin
./aarch64-linux-android21-clang  -fpass-plugin=/home/junknet/Desktop/o-mvll/src/build_ndk_r25/libOMVLL.so /home/junknet/Desktop/kankanshili/src/qwe.cpp -o main

out:
/home/junknet/Downloads/android-ndk-r25c-linux/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang-14 -S -emit-llvm -std=c++17 -o /tmp/omvll-x86_64-unknown-linux-gnu-b682cc.cpp.ll /tmp/omvll-x86_64-unknown-linux-gnu-b682cc.cpp
/home/junknet/Downloads/android-ndk-r25c-linux/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang-14 -S -emit-llvm -target aarch64-unknown-linux-android21 -std=c++17 -o /tmp/omvll-aarch64-unknown-linux-android21-f4f132.cpp.ll /tmp/omvll-aarch64-unknown-linux-android21-f4f132.cpp
No available targets are compatible with triple "x86_64-unknown-linux-gnu"

Stack exhaustion due to for/while loops

Issue related to #39

some obfuscation passes of omvll cause stack exhaustion if applied on for loops or while with a lot of iterations due to saving on the stack variables at each iteration.

for now I've found the following cases:

  • obfuscate_constants with for loops
  • flatten_cfg with while and for loops
  • break_control_flow with while and for loops

To reproduce the crashes you can use the setup described in #39

XCode 14.3 Clang command failing

Followed all instructions :

Using O-MVLL with Xcode is a bit easier than Android since we don’t need to deal with different libstdc++/libc++. To enable O-MVLL, one needs to go to:

Build Settings > Apple Clang - Custom Compiler Flags > Other C/C++ Flags

and add -fpass-plugin=<path>/omvll_xcode_14.dylib. We also need to disable the legacy pass manager with: -fno-legacy-pass-manager.

Finally, we can create an omvll.yml file next to the *.xcodeproj file which defines OMVLL_PYTHONPATH and OMVLL_CONFIG.

Et voila :)

but when i try to build using xcode i get this error:

Screenshot 2023-05-08 at 08 56 59

it seems clang crashed

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGKILL (Code Signature Invalid))
Exception Codes:       UNKNOWN_0x32 at 0x0000000118000000
Exception Codes:       0x0000000000000032, 0x0000000118000000

Can you help me?

Target: iOS
O-MVLL Version: OMVLL Version: 1.1.0-86087c7 / 14.0.0git (d5f117e38620783fc095e5620416bdae08554588)
Compilation of O-MVLL: on my own

Stack underflow using obfuscate_constants

Target: iOS arm64e
OMVLL Version: 1.1.0-b5f1bee / 14.0.0git ( (c41f13252ed4b49f246729b4d91ff521d5a6bf9d))
Compilation of O-MVLL: CI

I've noticed that the stack grows until reaching the maximum size using obfuscate_constants on a function while in a loop:

if I try this function:

void testx(){
    int i=0;
    while(1){   
       i++;
    }
}

and the following config.py

"""
class MyConfig(omvll.ObfuscationConfig):
def init(self):
super().init()

def obfuscate_constants(self, _, __):
    if "testx" in str(__.name):
        return True
    return False

"""
sp grows(decreases) by 0x20 for every iteration in the loop crashing the program

Flaky action in GitHub workflow due to curl network error

Today, I saw one of the GitHub actions fail in our staging repo due to an issue with curl: https://github.com/build38/o-mvll/actions/runs/5153567694

> Run curl -LO https://data.romainthomas.fr/omvll-deps-xcode-14.tar
  ...
  curl: (92) HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)
  Error: Process completed with exit code 92.

curl has some kind of retry mechanism that we could probably use. There may be other better solutions. I am not worried and it's not urgent. I mostly want to document this for future reference, because flaky bots can be annoying.

O-MVLL Python Configuration problem

O-MVLL Python Configuration
[CXX1405] error when building with cmake using /home/mac/AndroidStudioProjects/butterFly/app/src/main/cpp/CMakeLists.txt: -- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/mac/Android/Sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/linux-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /home/mac/Android/Sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
-- Check for working CXX compiler: /home/mac/Android/Sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ - broken
-- Configuring incomplete, errors occurred!
See also "/home/mac/AndroidStudioProjects/butterFly/app/.cxx/Debug/4z1w3t4m/arm64-v8a/CMakeFiles/CMakeOutput.log".
See also "/home/mac/AndroidStudioProjects/butterFly/app/.cxx/Debug/4z1w3t4m/arm64-v8a/CMakeFiles/CMakeError.log".

C++ build system [configure] failed while executing:
/home/mac/Android/Sdk/cmake/3.18.1/bin/cmake
-H/home/mac/AndroidStudioProjects/butterFly/app/src/main/cpp
-DCMAKE_SYSTEM_NAME=Android
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_SYSTEM_VERSION=21
-DANDROID_PLATFORM=android-21
-DANDROID_ABI=arm64-v8a
-DCMAKE_ANDROID_ARCH_ABI=arm64-v8a
-DANDROID_NDK=/home/mac/Android/Sdk/ndk/25.0.8775105
-DCMAKE_ANDROID_NDK=/home/mac/Android/Sdk/ndk/25.0.8775105
-DCMAKE_TOOLCHAIN_FILE=/home/mac/Android/Sdk/ndk/25.0.8775105/build/cmake/android.toolchain.cmake
-DCMAKE_MAKE_PROGRAM=/home/mac/Android/Sdk/cmake/3.18.1/bin/ninja
-DCMAKE_CXX_FLAGS=-fpass-plugin=/home/mac/Desktop/omvll_ndk_r25.so
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/mac/AndroidStudioProjects/butterFly/app/build/intermediates/cxx/Debug/4z1w3t4m/obj/arm64-v8a
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/home/mac/AndroidStudioProjects/butterFly/app/build/intermediates/cxx/Debug/4z1w3t4m/obj/arm64-v8a
-DCMAKE_BUILD_TYPE=Debug
-B/home/mac/AndroidStudioProjects/butterFly/app/.cxx/Debug/4z1w3t4m/arm64-v8a
-GNinja
from /home/mac/AndroidStudioProjects/butterFly/app
CMake Warning at /home/mac/Android/Sdk/ndk/25.0.8775105/build/cmake/android-legacy.toolchain.cmake:415 (message):
An old version of CMake is being used that cannot automatically detect
compiler attributes. Compiler identification is being bypassed. Some
values may be wrong or missing. Update to CMake 3.19 or newer to use
CMake's built-in compiler identification.
Call Stack (most recent call first):
/home/mac/Android/Sdk/ndk/25.0.8775105/build/cmake/android.toolchain.cmake:54 (include)
/home/mac/Android/Sdk/cmake/3.18.1/share/cmake-3.18/Modules/CMakeDetermineSystem.cmake:93 (include)
CMakeLists.txt:10 (project)

CMake Warning at /home/mac/Android/Sdk/ndk/25.0.8775105/build/cmake/android-legacy.toolchain.cmake:415 (message):
An old version of CMake is being used that cannot automatically detect
compiler attributes. Compiler identification is being bypassed. Some
values may be wrong or missing. Update to CMake 3.19 or newer to use
CMake's built-in compiler identification.
Call Stack (most recent call first):
/home/mac/Android/Sdk/ndk/25.0.8775105/build/cmake/android.toolchain.cmake:54 (include)
/home/mac/AndroidStudioProjects/butterFly/app/.cxx/Debug/4z1w3t4m/arm64-v8a/CMakeFiles/3.18.1-g262b901/CMakeSystem.cmake:6 (include)
/home/mac/AndroidStudioProjects/butterFly/app/.cxx/Debug/4z1w3t4m/arm64-v8a/CMakeFiles/CMakeTmp/CMakeLists.txt:2 (project)

CMake Warning at /home/mac/Android/Sdk/ndk/25.0.8775105/build/cmake/android-legacy.toolchain.cmake:415 (message):
An old version of CMake is being used that cannot automatically detect
compiler attributes. Compiler identification is being bypassed. Some
values may be wrong or missing. Update to CMake 3.19 or newer to use
CMake's built-in compiler identification.
Call Stack (most recent call first):
/home/mac/Android/Sdk/ndk/25.0.8775105/build/cmake/android.toolchain.cmake:54 (include)
/home/mac/AndroidStudioProjects/butterFly/app/.cxx/Debug/4z1w3t4m/arm64-v8a/CMakeFiles/3.18.1-g262b901/CMakeSystem.cmake:6 (include)
/home/mac/AndroidStudioProjects/butterFly/app/.cxx/Debug/4z1w3t4m/arm64-v8a/CMakeFiles/CMakeTmp/CMakeLists.txt:2 (project)

CMake Warning at /home/mac/Android/Sdk/ndk/25.0.8775105/build/cmake/android-legacy.toolchain.cmake:415 (message):
An old version of CMake is being used that cannot automatically detect
compiler attributes. Compiler identification is being bypassed. Some
values may be wrong or missing. Update to CMake 3.19 or newer to use
CMake's built-in compiler identification.
Call Stack (most recent call first):
/home/mac/Android/Sdk/ndk/25.0.8775105/build/cmake/android.toolchain.cmake:54 (include)
/home/mac/AndroidStudioProjects/butterFly/app/.cxx/Debug/4z1w3t4m/arm64-v8a/CMakeFiles/3.18.1-g262b901/CMakeSystem.cmake:6 (include)
/home/mac/AndroidStudioProjects/butterFly/app/.cxx/Debug/4z1w3t4m/arm64-v8a/CMakeFiles/CMakeTmp/CMakeLists.txt:2 (project)

CMake Error at /home/mac/Android/Sdk/cmake/3.18.1/share/cmake-3.18/Modules/CMakeTestCXXCompiler.cmake:59 (message):
The C++ compiler

"/home/mac/Android/Sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /home/mac/AndroidStudioProjects/butterFly/app/.cxx/Debug/4z1w3t4m/arm64-v8a/CMakeFiles/CMakeTmp

Run Build Command(s):/home/mac/Android/Sdk/cmake/3.18.1/bin/ninja cmTC_54545 && [1/2] Building CXX object CMakeFiles/cmTC_54545.dir/testCXXCompiler.cxx.o
FAILED: CMakeFiles/cmTC_54545.dir/testCXXCompiler.cxx.o 
/home/mac/Android/Sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --sysroot=/home/mac/Android/Sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/linux-x86_64/sysroot   -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security  -fpass-plugin=/home/mac/Desktop/omvll_ndk_r25.so  -fPIE -MD -MT CMakeFiles/cmTC_54545.dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_54545.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_54545.dir/testCXXCompiler.cxx.o -c testCXXCompiler.cxx
error: ModuleNotFoundError: No module named 'omvll-config'
ninja: build stopped: subcommand failed.

explain:
I found this issue after I input the command "source omvll.env" that the document mentioned. These are the file's contents.
export NDK_VERSION=25.0.8775105
export LD_LIBRARY_PATH=${ANDROID_HOME}/ndk/${NDK_VERSION}/toolchains/llvm/prebuilt/linux-x86_64/lib64
export OMVLL_CONFIG=$(pwd)/app/omvll-config.py
export OMVLL_PYTHONPATH=/home/mac/Desktop/Python-3.10.7/Lib
I don't know why this issue happened?? can you help me?

Environment
Target: Android/
O-MVLL Version: OMVLL Version: 1.1.0-86087c7 / 14.0.6git (4c603efb0cca074e9238af8b4106c30add4418f6)
Compilation of O-MVLL: CI

unable to execute command: Killed: 9

Target: iOS
O-MVLL Version: OMVLL Version: 1.1.0-86087c7 / 14.0.0git (d5f117e38620783fc095e5620416bdae08554588)
Compilation of O-MVLL: CI
Platform: M1 on MacOS Ventura 13.0.1, Apple clang version 14.0.0 (clang-1400.0.29.202)

Steps to reproduce:
main.c:

int main(int arc, char **argv){return 0;}

Compile:

clang -fno-legacy-pass-manager -fpass-plugin=$(pwd)/omvll_xcode_14.dylib -arch arm64 -isysroot $(xcrun --sdk iphoneos --show-sdk-path) -v main.c -o main

Output:

Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple arm64-apple-ios16.1.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.c -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -fno-strict-return -fno-rounding-math -funwind-tables=2 -fobjc-msgsend-selector-stubs -target-sdk-version=16.1 -fvisibility-inlines-hidden-static-local-var -target-cpu apple-a7 -target-feature +fp-armv8 -target-feature +neon -target-feature +crypto -target-feature +zcm -target-feature +zcz -target-feature +sha2 -target-feature +aes -target-abi darwinpcs -fallow-half-arguments-and-returns -debugger-tuning=lldb -target-linker-version 820.1 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.1.sdk -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.1.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.1.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -Wno-cast-function-type -Wno-bitwise-instead-of-logical -fdebug-compilation-dir=/Users/dev/obf -ferror-limit 19 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-legacy-pass-manager -fmax-type-align=16 -fcommon -fcolor-diagnostics -fpass-plugin=/Users/dev/obf/omvll_xcode_14.dylib -clang-vendor-feature=+messageToSelfInClassMethodIdReturnType -clang-vendor-feature=+disableInferNewAvailabilityFromInit -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /var/folders/cv/x7j5p4yd36vd55sbvk0m3l9h0000gn/T/main-8e223f.o -x c main.c
clang -cc1 version 14.0.0 (clang-1400.0.29.202) default target arm64-apple-darwin22.1.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.1.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.1.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/include
 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.1.sdk/usr/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.1.sdk/System/Library/Frameworks (framework directory)
End of search list.
clang: error: unable to execute command: Killed: 9
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/cv/x7j5p4yd36vd55sbvk0m3l9h0000gn/T/main-4e6f4d.c
clang: note: diagnostic msg: /var/folders/cv/x7j5p4yd36vd55sbvk0m3l9h0000gn/T/main-4e6f4d.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/dev/Library/Logs/DiagnosticReports/clang_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg: 

********************

Crash log:

crash.zip

iOS string encoding produces plain-text duplicate

Description

The string-encoding pass removes or encodes strings in a binary. We have it working on x86 Linux and arm64 macOS. When we run it with triple arm64-apple-ios, however, it appears to produce a wrapped version of the encoded string by accident.

How to reproduce the issue

  1. Check out main, configure a build and run ninja check
  2. It will report passes/strings-encoding/basic-aarch64.cpp as "Expectedly Failed"
  3. Run the test in isolation: bin/llvm-lit -a --filter=basic-aarch64 test. The output will be something like this:
o-mvll/src/test/passes/strings-encoding/basic-aarch64.cpp:29:24: error: CHECK-REPLACED-NOT: excluded string found in input
// CHECK-REPLACED-NOT: [[FILE_NAME]]
                       ^
<stdin>:33:3: note: found here
l_o-mvll/src/test/passes/strings-encoding/basic-aarch64.cpp:.str.2
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<stdin>:33:3: note: with "FILE_NAME" equal to "o-mvll/src/test/passes/strings-encoding/basic-aarch64\\.cpp"
l_o-mvll/src/test/passes/strings-encoding/basic-aarch64.cpp:.str.2
  ^

O-MVLL Python Configuration

https://github.com/open-obfuscator/o-mvll/blob/9ce24ea838970558fbff1549e5a3fe1a1299866d/src/test/passes/strings-encoding/config_replace.py

Environment

Additional context

It cannot be reproduce on x86 macOS right now, because clang crashes for a different reason before.

Segmentation fault in clang

I'm trying to build and obfuscate a simple piece of code but clang crashes:
omvll dylib: https://github.com/open-obfuscator/o-mvll/releases/tag/1.0.3
Python-3.10.7

utils.c

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/sysctl.h>
#include <stdlib.h>

int is_debugger_present(void)
{
    int name[4];
    struct kinfo_proc info;
    size_t info_size = sizeof(info);

    info.kp_proc.p_flag = 0;
    name[0] = CTL_KERN;
    name[1] = KERN_PROC;
    name[2] = KERN_PROC_PID;
    name[3] = getpid();

    if (sysctl(name, 4, &info, &info_size, NULL, 0) == -1) {
        perror("sysctl");
        exit(-1);
    }
    return ((info.kp_proc.p_flag & P_TRACED) != 0);
}

int main(){
    is_debugger_present();
    return 0;
}

config.py

import omvll
import os
from functools import lru_cache


class MyConfig(omvll.ObfuscationConfig):
    def __init__(self):
        super().__init__()

    def flatten_cfg(self, mod: omvll.Module, func: omvll.Function):
        if func.name == "is_debugger_present":
            return True
        return False
    
@lru_cache(maxsize=1)
def omvll_get_config() -> omvll.ObfuscationConfig:
    """
    Return an instance of `ObfuscationConfig` which
    aims at describing the obfuscation scheme
    """
    return MyConfig()

output:

clang -fpass-plugin=omvll_xcode_14.dylib utils.c -o main
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/g_/y9nmb9t11lv5bdyscrcfwlg80000gn/T/utils-c2f326.c
clang: note: diagnostic msg: /var/folders/g_/y9nmb9t11lv5bdyscrcfwlg80000gn/T/utils-c2f326.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/gitlab/Library/Logs/DiagnosticReports/clang_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg: 

Attached there is the crashlog of clang

clang-2024-02-28-122142.ips.txt
I've also exported OMVLL_CONFIG and OMVLL_PYTHONPATH
I've tried it also with XCode 15 and 14

String decoding in StackLoop doesn't work

Hello guys, thank You for your great repo!
I m playing around string encoding and found interesting thing which I want to share with you:

You have a code for stack loop encryption:
out[i] = in[i] ^ raw_key[i % sizeof(key)];

And decryption part is:
out[i] = in[i] ^ raw_key[i % sizeof(key)] ^ i;

I believe that decryption part should not contain ^i in the end

Thanks

Support Swift code

Hi, romainthomas.

I test o-mvll on iOS project, it dosen't process swift file. any plan to support it?

Why not read cmake dependencies from environment

I'm building o-mvll with VSCode, currently in src/CMakeLists.txt, there're NO_DEFAULT_PATH which prevent cmake to read dependencies' path from environment variables.

find_package(LLVM 14 REQUIRED CONFIG NO_DEFAULT_PATH)
find_package(Clang REQUIRED CONFIG. NO_DEFAULT_PATH)

find_package(spdlog REQUIRED CONFIG)
find_package(pybind11 REQUIRED CONFIG NO_DEFAULT_PATH)

However I think it's not very convinent when I'm using VSCode with settings.json:

{
    "cmake.sourceDirectory": "${workspaceFolder}/src",
    "cmake.generator": "Ninja",
    "cmake.environment": {
        "LLVM_DIR": "/usr/lib/llvm-14/cmake",
        "Clang_DIR": "/usr/lib/cmake/clang-14",
        "pybind11_DIR": "/usr/lib/cmake/pybind11"
    }
}

but this doesn't work, and cmake will give an error:

  Could not find a package configuration file provided by "LLVM" with any of
  the following names:
    LLVMConfig.cmake
    llvm-config.cmake
  Add the installation prefix of "LLVM" to CMAKE_PREFIX_PATH or set "LLVM_DIR"

to let cmake use DIRs from "cmake.environment", I have to remove NO_DEFAULT_PATH:
and I prefer to set dependencies path in "cmake.environment" like below:

find_package(LLVM 14 REQUIRED CONFIG)
find_package(Clang REQUIRED CONFIG)

find_package(spdlog REQUIRED CONFIG)
find_package(pybind11 REQUIRED CONFIG)

For what I understand, it could be more convinent if we can use the environment approach for VSCode.
because there's no "best practice to develop o-mvll", I'm not sure if NO_DEFAULT_PATH is actually a more reasonable choice in your local workflow.
I would greatly appreciate hearing your opinion!

Can't build in Release mode

O-MVLL ver: omvll_ndk_r25.tar_2024-04-18T14_54_39.gz

Steps how to reproduce:

  1. Create a test project
  2. Write any code (prinf("Hello World!\n") is enough)
  3. Use sample-omvll-config.py config
  4. Set CMake profile to Release
  5. Build
  6. Profit??
[36/36] Linking CXX shared library ../arm64-v8a.so
FAILED: ../arm64-v8a.so
: && /home/ryuu/android/cmake/3.22.1/bin/cmake -E time /home/ryuu/android/ndk/25.0.8775105//toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android23 -fPIC -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fexceptions -frtti -stdlib=libc++ -Wno-deprecated -fvisibility=hidden -Ofast -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -fno-unroll-loops -flto=thin -fno-unroll-loops -Xclang -fmerge-functions -fpass-plugin=/mnt/c/Users/ryuu/CLionProjects/untitled8/omvll_ndk_r25c.so  -O3 -DNDEBUG  -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Qunused-arguments -Wl,--no-undefined -ffixed-x18 --no-undefined -s -shared -Wl,-soname,arm64-v8a.so -o ../arm64-v8a.so CMakeFiles/redacted.dir/src/main.cpp.o *redacted libraries*  -landroid  -lGLESv3  -lEGL  -llog   -static-libstdc++ -latomic -lm && cd /mnt/c/Users/ryuu/CLionProjects/untitled8/cmake-build-release && /home/ryuu/android/ndk/25.0.8775105/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip --discard-all --discard-locals --strip-all --strip-unneeded /mnt/c/Users/ryuu/CLionProjects/untitled8/arm64-v8a.so
ld: error: ignoring debug info with an invalid version (0) in CMakeFiles/redacted.dir/dependencies/imgui/imgui_draw.cpp.o
ld: error: ignoring debug info with an invalid version (0) in CMakeFiles/redacted.dir/src/sdk/sdk.cpp.o
ld: error: ignoring debug info with an invalid version (0) in CMakeFiles/redacted.dir/src/render/render.cpp.o
ld: error: ignoring debug info with an invalid version (0) in CMakeFiles/redacted.dir/dependencies/imgui/imgui.cpp.o
ld: error: ignoring debug info with an invalid version (0) in CMakeFiles/redacted.dir/dependencies/imgui/imgui.cpp.o
ld: error: ignoring debug info with an invalid version (0) in CMakeFiles/redacted.dir/dependencies/imgui/imgui_draw.cpp.o
ld: error: ignoring debug info with an invalid version (0) in CMakeFiles/redacted.dir/dependencies/imgui/imgui_draw.cpp.o
ld: error: ignoring debug info with an invalid version (0) in CMakeFiles/redacted.dir/src/render/backends/imgui_impl_opengl3.cpp.o
ld: error: ignoring debug info with an invalid version (0) in CMakeFiles/redacted.dir/src/render/render.cpp.o
ld: error: ignoring debug info with an invalid version (0) in CMakeFiles/redacted.dir/dependencies/imgui/imgui_demo.cpp.o
ld: error: ignoring debug info with an invalid version (0) in CMakeFiles/redacted.dir/src/sdk/sdk.cpp.o
ld: error: ignoring debug info with an invalid version (0) in CMakeFiles/redacted.dir/src/main.cpp.o
ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Elapsed time: 0 s. (time), 0.000907 s. (clock)
ninja: build stopped: subcommand failed.

break_control_flow: No available targets are compatible with triple "aarch64-none-linux-android27"

cmake can't compile a test program
host: ubuntu 2204 x86_64
app.gradle:

android {
    ndkVersion "25.0.8775105"
    compileSdk 34

    defaultConfig {
        minSdk 27
        targetSdk 34

        ndk {
            abiFilters 'arm64-v8a'
        }
        externalNativeBuild {
            cmake {
                cppFlags '-fpass-plugin=/home/ubuntu/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/lib64/omvll_ndk_r25c.so'
                cFlags   '-fpass-plugin=/home/ubuntu/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/lib64/omvll_ndk_r25c.so'
            }
        }
    }
}

C++ compiler (assembler) output:

The output was:
1
No available targets are compatible with triple "aarch64-none-linux-android27"


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: /home/ubuntu/Android/Sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ 
Build flags: -g;-DANDROID;-fdata-sections;-ffunction-sections;-funwind-tables;-fstack-protector-strong;-no-canonical-prefixes;-D_FORTIFY_SOURCE=2;-Wformat;-Werror=format-security;;-fpass-plugin=/home/ubuntu/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/lib64/omvll_ndk_r25c.so
Id flags:  

The output was:
1
error: <inline asm>:3:11: unknown token in expression
  adr x1, #0x10;
          ^



Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.

config file:

import omvll
from functools import lru_cache

class MyConfig(omvll.ObfuscationConfig):
    def __init__(self):
        super().__init__()

    def obfuscate_string(self, module: omvll.Module, func: omvll.Function,
                               string: bytes):

        return True

#     def anti_hooking(self, mod: omvll.Module, func: omvll.Function) -> omvll.AntiHookOpt:
#         if "nativeobfuscatetest" in func.name:
#             return True
#         return False

#     def anti_hooking(self, mod: omvll.Module, func: omvll.Function) -> omvll.AntiHookOpt:
#         return True


#     def anti_hooking(self, mod: omvll.Module, func: omvll.Function) -> omvll.AntiHookOpt:
#         return True

    def obfuscate_arithmetic(self, mod: omvll.Module,
                                   fun: omvll.Function) -> omvll.ArithmeticOpt:
        return True

    def break_control_flow(self, mod: omvll.Module, func: omvll.Function):
        return True

    def flatten_cfg(self, mod: omvll.Module, func: omvll.Function):
        return True

    def obfuscate_constants(_, __, func: omvll.Function):
        return True

    def obfuscate_struct_access(self, _: omvll.Module, __: omvll.Function,
                                      struct: omvll.Struct):
        return True

    def obfuscate_string(self, _, __, string: bytes):
        return omvll.StringEncOptStack()

@lru_cache(maxsize=1)
def omvll_get_config() -> omvll.ObfuscationConfig:
    """
    Return an instance of `ObfuscationConfig` which
    aims at describing the obfuscation scheme
    """
    return MyConfig()

Duplicate Symbol omvll_decode

Root cause and conditions to reproduce are not yet clear, but under some circumstances enabling String Encoding will result in the compiler raising an error about omvll_decode symbol being duplicated.

This was detected as part of #33

The error of unable to obfuscate when using plugins on Android Studio Windows.

I have installed all the required files and libraries as instructed, but still cannot use this plugin :(

externalNativeBuild {
cmake {
cppFlags '-std=c++14 -frtti -fexceptions -fpass-plugin=C:\Users\Administrator\Downloads\omvll_ndk_r25\omvll_ndk_r25.so'
abiFilters 'arm64-v8a'
}
}

An error occurred when I started building the application.

error: unable to load plugin 'C:\Users\Administrator\Downloads\omvll_ndk_r25\omvll_ndk_r25.so': 'Could not load library 'C:\Users\Administrator\Downloads\omvll_ndk_r25\omvll_ndk_r25.so': C:\Users\Administrator\Downloads\omvll_ndk_r25\omvll_ndk_r25.so: Can't open: Unknown error (0xC1)'
1 error generated.

Could you help me fix this error? I really need it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.