All Projects → sailro → Dexer

sailro / Dexer

Licence: MIT license
Dexer is an open source framework, written in C#, that reads and writes .DEX files (Dalvik Executable Format) used by the Android Open Source Project.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to Dexer

dali
Indie assembler/linker for Dalvik VM .dex & .apk files (Work In Progress)
Stars: ✭ 55 (-32.1%)
Mutual labels:  dalvik, dex
dalvik
Dalvik parser in pure Rust.
Stars: ✭ 28 (-65.43%)
Mutual labels:  dalvik, dex
dex2jar
Tools to work with android .dex and java .class files
Stars: ✭ 102 (+25.93%)
Mutual labels:  dalvik, dex
Androguard
Reverse engineering, Malware and goodware analysis of Android applications ... and more (ninja !)
Stars: ✭ 3,797 (+4587.65%)
Mutual labels:  dalvik, dex
jitana
A graph-based static-dynamic hybrid DEX code analysis tool
Stars: ✭ 35 (-56.79%)
Mutual labels:  dalvik, dex
dalvikgate
Lightweight dex / odex / apk to jar converter
Stars: ✭ 32 (-60.49%)
Mutual labels:  dalvik, dex
Redexer
The Redexer binary instrumentation framework for Dalvik bytecode
Stars: ✭ 137 (+69.14%)
Mutual labels:  dex
odex-patcher
Run arbitrary code by patching OAT files
Stars: ✭ 44 (-45.68%)
Mutual labels:  dalvik
Atomicdex Desktop
atomicDEX Desktop app - project codename "Dextop"
Stars: ✭ 126 (+55.56%)
Mutual labels:  dex
Dex K8s Authenticator
A Kubernetes Dex Client Authenticator
Stars: ✭ 249 (+207.41%)
Mutual labels:  dex
Hydro Scaffold Dex
A Decentralized Exchange Scaffold - launch a DEX in minutes
Stars: ✭ 112 (+38.27%)
Mutual labels:  dex
Android Crack Tool
🐞Android crack tool For Mac
Stars: ✭ 2,666 (+3191.36%)
Mutual labels:  dex
Hidex Hack
anti reverse by hack dex file
Stars: ✭ 160 (+97.53%)
Mutual labels:  dex
Photonoter
📓Material Design风格的开源照片笔记。(MVP+Dagger2+RxJava+AspectJ+Dex处理)
Stars: ✭ 1,592 (+1865.43%)
Mutual labels:  dex
Lief
Authors
Stars: ✭ 2,730 (+3270.37%)
Mutual labels:  dex
Uniswap Python
🦄 The unofficial Python client for the Uniswap exchange.
Stars: ✭ 191 (+135.8%)
Mutual labels:  dex
Apk Changer
Command line program for modifying apk files
Stars: ✭ 122 (+50.62%)
Mutual labels:  dex
Simplify
Android virtual machine and deobfuscator
Stars: ✭ 3,865 (+4671.6%)
Mutual labels:  dalvik
dex-backend
Backend for Digital Excellence Platform
Stars: ✭ 22 (-72.84%)
Mutual labels:  dex
Chainx
Cross-chain hub for Crypto Asset on Polkadot
Stars: ✭ 187 (+130.86%)
Mutual labels:  dex

Dexer

Build status NuGet

Dexer is an open source framework, written in C#, that reads and writes .DEX files (Dalvik Executable Format) used by the Android Open Source Project.

Usage:

Let's work on the following Android application:

package dexer.poc;
 
import android.app.Activity;
import android.os.Bundle;
 
public class MainActivity extends Activity {
 
        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
       
                int a = 4;
                int b = 5;
                int result = a*b;
       
                setTitle("This demo rocks: " + result);
        }
}

image

And here is the code of the main method using the Dexer object model: image

Now let’s go back to C# to play a little with this application by changing a string constant and an opcode (adding instead of multiplying):

using System;
using Dexer.Core;
using Dexer.Instructions;
 
namespace Dexer.Debug
{
    class Program
    {
        static void Main(string[] args)
        {
            Dex dex = Dex.Load("classes.dex");
            MethodDefinition method = dex.GetClass("dexer.poc.MainActivity").GetMethod("onCreate");
 
            method.Body.Instructions[5].OpCode = OpCodes.Add_int;
            method.Body.Instructions[7].Operand = "Dexer rocks! ";
 
            dex.Write("output.dex");
            Console.ReadLine();
        }
    }
}

image

Here is the result:

image

Now let’s call a method to change the title color:

using System;
using Dexer.Core;
using Dexer.Instructions;
 
namespace Dexer.Debug
{
    class Program
    {
        static void Main(string[] args)
        {
            Dex dex = Dex.Load("classes.dex");
            MethodDefinition method = dex.GetClass("dexer.poc.MainActivity").GetMethod("onCreate");
 
            method.Body.Instructions[5].OpCode = OpCodes.Add_int;
            method.Body.Instructions[7].Operand = "Dexer rocks! ";
 
            int color; unchecked { color = (int)0xFFFF00FF; }
 
            // Declare a new method reference with prototype
            Prototype prototype = new Prototype(PrimitiveType.Void, new Parameter(PrimitiveType.Int));
            MethodReference setTitleColor = dex.Import(new MethodReference(method.Owner, "setTitleColor", prototype));
 
            // Load the color in a register (n°1) then invoke the method (register n°5 is 'this' in our case)
            var regs = method.Body.Registers;
            Instruction iconst = new Instruction(OpCodes.Const, color, regs[1]);
            method.Body.Instructions.Insert(14, iconst);
 
            Instruction iinvoke = new Instruction(OpCodes.Invoke_virtual, setTitleColor, regs[5], regs[1]);
            method.Body.Instructions.Insert(15, iinvoke);
 
            dex.Write("output.dex");
            Console.ReadLine();
        }
    }
}

image

Here is the result:

image

As you can see, altering DEX files is quite easy with Dexer. In order to rebuild APK packages, I’ve used ApkTool and JarSigner (with the default debug key generated by the Android SDK).

apktool d -s -f DexerPOC.apk output
I: Copying raw classes.dex file...
I: Loading resource table...
I: Decoding resources...
I: Copying assets and libs...

apktool b output DexerPOC.new.apk
I: Copying classes.dex file...
I: Checking whether resources has changed...
I: Building resources...
I: Building apk file...

jarsigner -keystore .\.android\debug.keystore -storepass android -keypass android DexerPOC.new.apk androiddebugkey

adb install DexerPOC.new.apk
586 KB/s (12609 bytes in 0.021s)
        pkg: /data/local/tmp/DexerPOC.new.apk
Success.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].