Trace all method entries and exits, the exit also prints the return value, if it is of basic type

Overview

apktrace

Trace all method entries and exits, the exit also prints the return value, if it is of basic type. The apk must have set the android:debuggable="true" flag.

By default it will trace all functions which match(prefixed) package_name.

asciicast

Updates

(07-02-2020 add native function highlighting)

Usage

>> python apktrace.py --help
usage: apktrace.py [-h] [-w 
   
    ] [-c] [-d] [--version]
                   package_name activity

Trace APK files easily

positional arguments:
  package_name          Package Name used to start Application
  activity              start activity of the Application

optional arguments:
  -h, --help            show this help message and exit
  -w 
    
     , --watchlist 
     
      
                        File containing classes to watch, (class per line)
  -c, --clear           Clear APK before start
  -d, --debug           Verbose mode
  -n, --native          Break on native method entry
  --version             Print apktrace version

     
    
   

In action:

()V, [00:12:33-103480] Method Exit, Thread: 10635 [main], Lcom/example/firsttestapp/MainActivity; -> ()V, Retval: 0 [00:12:33-125597] Method Entry, Thread: 10635 [main], Lcom/example/firsttestapp/MainActivity; -> onCreate(Landroid/os/Bundle;)V, [00:12:33-174525] Method Entry, Thread: 10635 [main], Lcom/example/firsttestapp/MainActivity; -> calcOffset(IILjava/lang/String;)I, [00:12:33-175951] Method Exit, Thread: 10635 [main], Lcom/example/firsttestapp/MainActivity; -> calcOffset(IILjava/lang/String;)I, Retval: 325 [00:12:33-224984] Method Entry, Thread: 10635 [main], Lcom/example/firsttestapp/PinHandling; -> (Ljava/io/File;)V, [00:12:33-226337] Method Exit, Thread: 10635 [main], Lcom/example/firsttestapp/PinHandling; -> (Ljava/io/File;)V, Retval: 0 [00:12:33-227446] Method Entry, Thread: 10635 [main], Lcom/example/firsttestapp/PinHandling; -> checkIfPinExists()Z, [00:12:33-230958] Method Exit, Thread: 10635 [main], Lcom/example/firsttestapp/PinHandling; -> checkIfPinExists()Z, Retval: 1 [00:12:34-578716] Method Exit, Thread: 10635 [main], Lcom/example/firsttestapp/MainActivity; -> onCreate(Landroid/os/Bundle;)V, Retval: 0">
>> python apktrace.py -d com.example.firsttestapp .MainActivity
[apktrace] LOG   : start CMD "adb shell am start -D -n com.example.firsttestapp/.MainActivity"
[apktrace] LOG   : forward CMD   "adb forward tcp:33333 jdwp:14856"
[00:12:33-057312] Method Entry, Thread: 10635 [main], Lcom/example/firsttestapp/MainActivity; -> 
       
        ()V, 
[00:12:33-103480] Method Exit,  Thread: 10635 [main], Lcom/example/firsttestapp/MainActivity; -> 
        
         ()V, Retval: 0
[00:12:33-125597] Method Entry, Thread: 10635 [main], Lcom/example/firsttestapp/MainActivity; -> onCreate(Landroid/os/Bundle;)V, 
[00:12:33-174525] Method Entry, Thread: 10635 [main], Lcom/example/firsttestapp/MainActivity; -> calcOffset(IILjava/lang/String;)I, 
[00:12:33-175951] Method Exit,  Thread: 10635 [main], Lcom/example/firsttestapp/MainActivity; -> calcOffset(IILjava/lang/String;)I, Retval: 325
[00:12:33-224984] Method Entry, Thread: 10635 [main], Lcom/example/firsttestapp/PinHandling; -> 
         
          (Ljava/io/File;)V, 
[00:12:33-226337] Method Exit,  Thread: 10635 [main], Lcom/example/firsttestapp/PinHandling; -> 
          
           (Ljava/io/File;)V, Retval: 0
[00:12:33-227446] Method Entry, Thread: 10635 [main], Lcom/example/firsttestapp/PinHandling; -> checkIfPinExists()Z, 
[00:12:33-230958] Method Exit,  Thread: 10635 [main], Lcom/example/firsttestapp/PinHandling; -> checkIfPinExists()Z, Retval: 1
[00:12:34-578716] Method Exit,  Thread: 10635 [main], Lcom/example/firsttestapp/MainActivity; -> onCreate(Landroid/os/Bundle;)V, Retval: 0

          
         
        
       

TODO

  • there is a known Bug in the methodID size in the Rust implementation I wonder how this ever worked^^
  • move JdwpHandler in its own repository and use it as a git submodule, to allow easier usage also for other repositories, for example jdb++
  • implement the --watchlist argument (not possible see issue)
Owner
Kurt Nistelberger
I work with computers, favorite topics are about Reverse Engineering, IT-Security, AI and Logic.
Kurt Nistelberger
Visual Interaction with Code - A portable visual debugger for python

VIC Visual Interaction with Code A simple tool for debugging and interacting with running python code. This tool is designed to make it easy to inspec

Nathan Blank 1 Nov 16, 2021
Trashdbg - TrashDBG the world's worse debugger

The world's worse debugger Over the course of multiple OALABS Twitch streams we

OALabs 21 Jun 17, 2022
Dahua Console, access internal debug console and/or other researched functions in Dahua devices.

Dahua Console, access internal debug console and/or other researched functions in Dahua devices.

bashis 156 Dec 28, 2022
Hunter is a flexible code tracing toolkit.

Overview docs tests package Hunter is a flexible code tracing toolkit, not for measuring coverage, but for debugging, logging, inspection and other ne

Ionel Cristian Mărieș 705 Dec 08, 2022
A drop-in replacement for Django's runserver.

About A drop in replacement for Django's built-in runserver command. Features include: An extendable interface for handling things such as real-time l

David Cramer 1.3k Dec 15, 2022
Graphical Python debugger which lets you easily view the values of all evaluated expressions

birdseye birdseye is a Python debugger which records the values of expressions in a function call and lets you easily view them after the function exi

Alex Hall 1.5k Dec 24, 2022
Auto-detecting the n+1 queries problem in Python

nplusone nplusone is a library for detecting the n+1 queries problem in Python ORMs, including SQLAlchemy, Peewee, and the Django ORM. The Problem Man

Joshua Carp 837 Dec 29, 2022
pdb++, a drop-in replacement for pdb (the Python debugger)

pdb++, a drop-in replacement for pdb What is it? This module is an extension of the pdb module of the standard library. It is meant to be fully compat

1k Dec 24, 2022
Full featured multi arch/os debugger built on top of PyQt5 and frida

Full featured multi arch/os debugger built on top of PyQt5 and frida

iGio90 1.1k Dec 26, 2022
Winpdb Reborn - A GPL Python Debugger, reborn from the unmaintained Winpdb

Note from Philippe Fremy The port of winpdb-reborn to Python 3 / WxPython 4 is unfortunately not working very well. So Winpdb for Python 3 does not re

Philippe F 84 Dec 22, 2022
Voltron is an extensible debugger UI toolkit written in Python.

Voltron is an extensible debugger UI toolkit written in Python. It aims to improve the user experience of various debuggers (LLDB, GDB, VDB an

snare 5.9k Dec 30, 2022
An improbable web debugger through WebSockets

wdb - Web Debugger Description wdb is a full featured web debugger based on a client-server architecture. The wdb server which is responsible of manag

Kozea 1.6k Dec 09, 2022
Debugger capable of attaching to and injecting code into python processes.

DISCLAIMER: This is not an official google project, this is just something I wrote while at Google. Pyringe What this is Pyringe is a python debugger

Google 1.6k Dec 15, 2022
Inject code into running Python processes

pyrasite Tools for injecting arbitrary code into running Python processes. homepage: http://pyrasite.com documentation: http://pyrasite.rtfd.org downl

Luke Macken 2.7k Jan 08, 2023
Sweeter debugging and benchmarking Python programs.

Do you ever use print() or log() to debug your code? If so, ycecream, or y for short, will make printing debug information a lot sweeter. And on top o

42 Dec 12, 2022
Run-time type checker for Python

This library provides run-time type checking for functions defined with PEP 484 argument (and return) type annotations. Four principal ways to do type

Alex Grönholm 1.1k Jan 05, 2023
Trace all method entries and exits, the exit also prints the return value, if it is of basic type

Trace all method entries and exits, the exit also prints the return value, if it is of basic type. The apk must have set the android:debuggable="true" flag.

Kurt Nistelberger 7 Aug 10, 2022
Little helper to run Steam apps under Proton with a GDB debugger

protongdb A small little helper for running games with Proton and debugging with GDB Requirements At least Python 3.5 protontricks pip package and its

Joshie 21 Nov 27, 2022
Visual profiler for Python

vprof vprof is a Python package providing rich and interactive visualizations for various Python program characteristics such as running time and memo

Nick Volynets 3.9k Jan 01, 2023
Trace any Python program, anywhere!

lptrace lptrace is strace for Python programs. It lets you see in real-time what functions a Python program is running. It's particularly useful to de

Karim Hamidou 687 Nov 20, 2022