user1342
PocketSmali
Python

A modular and extendable Python tool for emulating simple SMALI code.

Last updated May 18, 2026
92
Stars
8
Forks
0
Issues
0
Stars/day
Attention Score
16
Language breakdown
Python 100.0%
โ–ธ Files click to expand
README

๐Ÿค– A modular and extendable Python tool for emulating simple SMALI code. ๐Ÿ“ฑ


GitHub contributors GitHub Repo stars GitHub watchers GitHub last commit

PocketSmali is a Python tool designed to emulate small chunks of SMALI code.

Instructions covered:

  • -string
    : Emulates the declaration of a string constant in SMALI code.
  • : Emulates the declaration of a numeric constant in SMALI code.
  • .local
    : Emulates the declaration of a local variable in SMALI code.
  • *
    : Emulates the invocation of a method in SMALI code, including different variants such as
    -virtual
    ,
    -direct
    ,
    -static
    , and others.
  • -result*
    : Emulates the handling of the result from a method invocation in SMALI code, including different variants such as
    -result
    ,
    -result-object
    ,
    -result-wide
    , and others.

โžก๏ธ Installation

Download and use as a Python package:

pip install git+https://github.com/user1342/PocketSmali.git
PocketSmali has been tested on Windows 11 and Ubuntu 22.04.2 LTS.

๐Ÿ“ฒ Emulating SMALI

Simple, one instruction emulation:

from PocketSmali.Emulator import Emulator emulator = Emulator() emulator.emulatesmaliinstruction('const-string v0, "TAG"') print(str(emulator))

SMALI code emulation:

from PocketSmali.Emulator import Emulator

code = ''' .method public printVar()Ljava/lang/String; .locals 2

.line 28 const-string v0, "TAG"

const-string v1, "Hello World"

invoke-static {v0, v1}, Landroid/util/Log;->v(Ljava/lang/String;Ljava/lang/String;)I

.line 29 return-object v1 .end method'''

emulator = Emulator(is_verbose=True) emulator.emulatesmalicode(code)

Emulating from a SMALI file:
from PocketSmali.Emulator import Emulator

emulator = Emulator(isverbose=True, smalifilesrootdir=r"MyApplication3\app\build\outputs\apk\debug\app-debug") emulator.emulatesmalimethod(r"MyApplication3\app\build\outputs\apk\debug\app-debug\smali_classes3\com\example\myapplication\MainActivity.smali","onCreate")

Using breakpoints and stubs:

from PocketSmali.Emulator import Emulator

code = ''' .method public printVar()Ljava/lang/String; .locals 2

.line 28 const-string v0, "TAG"

const-string v1, "Hello World"

invoke-static {v0, v1}, Landroid/util/Log;->v(Ljava/lang/String;Ljava/lang/String;)I

.line 29 return-object v1 .end method'''

def updateregv0(emulator): emulator.runtimeenv.setregister("v0","string-pool-2")

emulator = Emulator() emulator.breakpoints[29] = updateregv0 emulator.add_stub("android/util/Log") emulator.emulatesmalicode(code) print(str(emulator))

๐Ÿ™ Contributions

PocketSmali is both extendable and modular. To add handlers for other SMALI instructions, create a Python file in the
subfolder. Inside of this file, create a method that handles a specific instruction type - this method should take the parameters
(opcode, operands, runtimeenv, emulator)
. Then add to the
dictionary in the Emulator class with the key being the name of the instruction and the value being a reference to your created method for handling it.

โš–๏ธ Code of Conduct

PocketSmali follows the Contributor Covenant Code of Conduct. Please make sure to review and adhere to this code of conduct when contributing to Obfu[DE]scate.

๐Ÿ› Bug Reports and Feature Requests

If you encounter a bug or have a suggestion for a new feature, please open an issue in the GitHub repository. Please provide as much detail as possible, including steps to reproduce the issue or a clear description of the proposed feature. Your feedback is valuable and will help improve PocketSmali for everyone.

๐Ÿ“œ License

GNU General Public License v3.0

ยฉ 2026 GitRepoTrend ยท user1342/PocketSmali ยท Updated daily from GitHub