Babel Obfuscator
HomeDocumentationShop
  • Introduction
    • General Features
  • Getting Started
    • Install
    • Product Activation
  • Command Line
    • Command Line Reference
      • Miscellaneous
      • Input Files
      • Output Files
      • Plugins
      • Merge and Embed
      • Renaming
      • Control Flow Obfuscation
      • Encryption and Protection
      • Code Generation
  • MSBuild Task
    • Babel Task Reference
    • Customizing Intellisense
  • NuGet Package
    • NuGet Pakage Reference
  • User Interface
    • Obfuscation
    • Tools
    • Custom Themes
  • Obfuscation Rules
    • XML Rules
      • Example Rules
    • Custom Attributes
    • Obfuscation Agent
  • Merge and Embed
    • Assembly Merging
    • Assembly Embedding
  • Symbols Renaming
    • XML Map Files
    • Cross Assembly Renaming
    • XAML Renaming
    • Decoding Stack Traces
  • String Encryption
    • Custom String Encryption
  • Control Flow Obfuscation
  • Code Encryption
    • External Code Files
    • Password Protected Code
    • Dynamic Code
  • Dynamic Proxy
  • Resource Encryption
  • Value And Array Encryption
  • Tampering Detection
  • Anti Debugging
  • Enhancing Code Security
  • Optimizations
    • Dead Code Removal
    • Metadata Optimizations
    • Code Optimizations
  • Appendix
  • Examples
    • Examples
    • General Samples
      • ClickOnce Deploy
      • Detecting Babel Obfuscation
      • Obfuscate .NET MAUI
      • Blazor Web App
    • Code Encryption
      • Feature Based Licenses
    • Cross Assembly Renaming
      • Publish .NET App
    • Build Servers
      • GitHub Actions
      • Unit Tests
    • Babel Obfuscator NuGet
      • Android Application
  • Plugins
    • Babel Obfuscator Plugins
    • Encrypt Plugin
      • Getting Started
      • Source Code
Powered by GitBook
On this page

Was this helpful?

  1. Examples
  2. Babel Obfuscator NuGet

Android Application

In this example project, we will utilize the Babel Obfuscator NuGet package to enable obfuscation in an Android application based on .NET 7. The Babel Obfuscator NuGet package can be easily integrated into a .NET project. It provides a convenient way to configure and apply obfuscation directly from Visual Studio or the command line.

To use this example project and follow the instructions provided, you need to have a site license for Babel Obfuscator (Ultimate, Server or Data Center editions). Additionally, the source code for the example project is available for download from the GitHub repository associated with the project.

git clone https://github.com/babelfornet/android-app-example.git

The example project "AndroidApp" is designed to demonstrate the obfuscation process of an Android application. The project contains the reference to the Babel Obfuscator NuGet package, which runs the obfuscation against the target assembly AndroidApp.dll during the build process.

In addition to using the Babel Obfuscator NuGet package to set up obfuscation in the AndroidApp project, some additional configuration has been added to the project file (AndroidApp.csproj) to enable other types of obfuscations.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net7.0-android</TargetFramework>
    <SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
    <OutputType>Exe</OutputType>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <ApplicationId>com.companyname.AndroidApp</ApplicationId>
    <ApplicationVersion>1</ApplicationVersion>
    <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Babel.Obfuscator" Version="10.0.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>
  
  <PropertyGroup>
    <Use>tagassembly=true</Use>
    <StringEncryption>true</StringEncryption>
    <ControlFlowObfuscation>goto=on;if=on;switch=on;case=on;call=on;true</ControlFlowObfuscation>
    <DynamicProxy>all</DynamicProxy>
    <ResourceEncryption>true</ResourceEncryption>
    <VerboseLevel>3</VerboseLevel>
    <XmlRules>
      <Rules>
        <Rule name="rule1" feature="renaming" exclude="false">
          <Pattern>*</Pattern>
        </Rule>
	</Rules>
    </XmlRules>
  </PropertyGroup>
</Project>

For example, the project file includes settings for string encryption, which obfuscates string literals in the application's code to make it harder for attackers to reverse-engineer the app. Additionally, the configuration sets up a custom rule for renaming all public types, which increases the number of renamed types.

Once the app starts, it shows all the types inside the obfuscated assembly in the main view.

The view displays that most of the types have been renamed by Babel, showing that we are running the obfuscated application.

This example project demonstrates integrating the Babel Obfuscator NuGet package into an Android application and customising its obfuscation settings to achieve specific results. Through this example, users can gain insights into how Babel Obfuscator can help protect their Android applications by renaming types and methods, removing metadata, encrypting strings and adding control flow obfuscation to their code, enhancing the overall application security.

Last updated 2 years ago

Was this helpful?

Android App Emulator