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
Pyinstrument - a Python profiler. A profiler is a tool to help you optimize your code - make it faster.

Pyinstrument🚴 Call stack profiler for Python. Shows you why your code is slow!

Joe Rickerby 5k Jan 08, 2023
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
OpenCodeBlocks an open-source tool for modular visual programing in python

OpenCodeBlocks OpenCodeBlocks is an open-source tool for modular visual programing in python ! Although for now the tool is in Beta and features are c

Mathïs Fédérico 1.1k Jan 06, 2023
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
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
printstack is a Python package that adds stack trace links to the builtin print function, so that editors such as PyCharm can link you to the source of the print call.

printstack is a Python package that adds stack trace links to the builtin print function, so that editors such as PyCharm can link to the source of the print call.

101 Aug 26, 2022
🍦 Never use print() to debug again.

IceCream -- Never use print() to debug again Do you ever use print() or log() to debug your code? Of course you do. IceCream, or ic for short, makes p

Ansgar Grunseid 6.5k Jan 07, 2023
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 so中native函数的调用。

trace_natives 一个IDA小脚本,获取SO代码段中所有函数的偏移地址,再使用frida-trace 批量trace so函数的调用。 使用方法 1.将traceNatives.py丢进IDA plugins目录中 2.IDA中,Edit-Plugins-traceNatives IDA输

296 Dec 28, 2022
AryaBota: An app to teach Python coding via gradual programming and visual output

AryaBota An app to teach Python coding, that gradually allows students to transition from using commands similar to natural language, to more Pythonic

5 Feb 08, 2022
A package containing a lot of useful utilities for Python developing and debugging.

Vpack A package containing a lot of useful utilities for Python developing and debugging. Features Sigview: press Ctrl+C to print the current stack in

volltin 16 Aug 18, 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
VizTracer is a low-overhead logging/debugging/profiling tool that can trace and visualize your python code execution.

VizTracer is a low-overhead logging/debugging/profiling tool that can trace and visualize your python code execution.

2.8k Jan 08, 2023
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
Python's missing debug print command and other development tools.

python devtools Python's missing debug print command and other development tools. For more information, see documentation. Install Just pip install de

Samuel Colvin 637 Jan 02, 2023
Tracing instruction in lldb debugger.Just a python-script for lldb.

lldb-trace Tracing instruction in lldb debugger. just a python-script for lldb. How to use it? Break at an address where you want to begin tracing. Im

156 Jan 01, 2023
A gdb-like Python3 Debugger in the Trepan family

Abstract Features More Exact location information Debugging Python bytecode (no source available) Source-code Syntax Colorization Command Completion T

R. Bernstein 126 Nov 24, 2022
A simple rubber duck debugger

Rubber Duck Debugger I found myself many times asking a question on StackOverflow or to one of my colleagues just for finding the solution simply by d

1 Nov 10, 2021
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