Android

To compile for Android, download the Android NDK from https://developer.android.com/ndk/downloads. Create the following shell script, name it "compiler"and set the target to the platform for which you want to compile:


./toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang "$@"

Add any compiler switches you need to the script. Then you can call Tigress as usual to obfuscate your code:

> tigress \
           --Environment=armv8:Android:Gcc:4.6 \
           --Compiler=./compiler \
           --Transform=Flatten \
               --Functions=main \
           --out=test-flat.c test.c


Setting up the Android SDK

To ensure that your obfuscated code runs on Android devices, you need to test it on the Android emulator. First, download the latest version of Android Studio from the official website and follow the installation instructions specific to your operating system. To set it up, do:

  • In Android Studio, Navigate to SDK Manager:
       File > Settings > Appearance & Behavior > System Settings > Android SDK
    

  • Under SDK Tools, make sure Android SDK Platform-Tools is installed. This package includes ADB.
  • To verify ADB is correctly installed, open a terminal or use the Android Studio Terminal and issue the command:
  • > adb version
    

If ADB is not on your execution path on Linux platforms, you will need to add the path to the ADB binary to your $PATH environment variable. By default, ADB is installed to $HOME/Android/Sdk/platform-tools. First, verify that ADB is found in this directory, then add this line to your ~/.bashrc file:

> export PATH=$PATH:$HOME/Android/Sdk/platform-tools

Then issue this command to start the ADB server:

> adb start-server                                                


Setting up the ARM Emulator

In Android Studio, navigate to Android Virtual Device Manager. Click on + to Create Virtual Device:


Choose any desired device and click Next. Select an ARM-based system image. For example, choose "arm64-v8a" under Other Images. Download and select this image, then click Next. NOTE: ARM64 emulation on a x86 host currently only supported up to API level 27 Oreo.


  • Review your graphics as well as other settings before closing the emulator.
  • In the Device Manager, click the Play button next to the ARM-based emulator to launch it.
  • Once the emulator has finished booting and is running, ADB should automatically connect to it. To verify that your emulated device is listed as a connected device. Run:
    > adb devices                                               
    


Running on the ARM Emulator

Create the following shell script and name it adbwrapper:

adb push a.out /data/local/tmp/
adb shell chmod 755 /data/local/tmp/a.out
adb shell /data/local/tmp/a.out