Python ADB automation toolkit for Android device management, scripting, and pentesting
Project description
py-adbkit
Python ADB automation toolkit for Android. Control devices, run shell commands, manage apps, capture screenshots, stream logcat, and automate pentesting workflows.
Install
pip install py-adbkit
Quick Start
from pyadbkit import ADB
adb = ADB()
# List devices
devices = adb.devices()
for dev in devices:
print(f"{dev.serial} - {dev.model} (Android {dev.android_version})")
# Connect via WiFi
adb.connect("192.168.1.100")
# Shell commands
code, stdout, stderr = adb.shell("DEVICE_SERIAL", "ls -la /sdcard/")
# Take screenshot
screenshot = adb.screenshot("DEVICE_SERIAL")
with open("screenshot.png", "wb") as f:
f.write(screenshot)
# Battery info
battery = adb.battery("DEVICE_SERIAL")
print(f"Battery: {battery.get('level', '?')}%")
Shell Automation
from pyadbkit import ADB
adb = ADB()
serial = adb.devices()[0].serial
# High-level shell interface
from pyadbkit.commands import Shell
sh = Shell(adb, serial)
# Get/set properties
android_ver = sh.getprop("ro.build.version.release")
# Settings
sh.settings_put("system", "screen_off_timeout", "600000")
# Launch activities
sh.am_start("com.android.settings/.Settings")
# Input automation
sh.input_tap(500, 500)
sh.input_swipe(100, 500, 900, 500, 300)
sh.input_text("hello world")
sh.input_keyevent(3) # HOME
# Root shell (if rooted)
sh.su("cat /data/data/com.package/databases/app.db")
App Management
# List installed packages
packages = adb.packages(serial, third_party=True)
# Install APK
adb.install(serial, "app.apk", flags=["-r", "-g"])
# Uninstall
adb.uninstall(serial, "com.package.name")
# Backup
adb.backup(serial, "backup.ab", packages=["com.package.name"])
Logcat
from pyadbkit.commands import Logcat
logcat = Logcat(adb, serial)
# Dump all logs
lines = logcat.dump(max_lines=500)
# Filter by tag
errors = logcat.by_tag("ActivityManager", level="E")
# Crash logs only
crashes = logcat.crash()
# Kernel logs
kernel = logcat.kernel()
File Operations
from pyadbkit.commands import Push, Pull
# Push file
pusher = Push(adb, serial)
pusher.file("local.apk", "/sdcard/Download/")
# Push entire directory
count = pusher.dir("./my_folder", "/sdcard/my_folder")
# Pull file
puller = Pull(adb, serial)
puller.file("/sdcard/Download/data.json", "./data.json")
# Pull directory
count = puller.dir("/sdcard/Documents", "./backup_docs")
Network
# WiFi ADB
adb.tcpip(serial, port=5555)
adb.connect("192.168.1.100", port=5555)
# Port forwarding
adb.forward(serial, local_port=8080, remote_port=8080)
# Reverse forwarding
adb.reverse(serial, remote_port=9090, local_port=9090)
Device Info
# Full device properties
dev = adb.get_device_props(serial)
print(f"Model: {dev.model}")
print(f"Android: {dev.android_version}")
print(f"Build: {dev.build_id}")
# Battery
battery = adb.battery(serial)
print(battery)
# Disk usage
mounts = adb.df(serial)
for m in mounts:
print(f"{m['mount']}: {m['used']}/{m['size']} ({m['use_pct']})")
# Running processes
processes = adb.process_list(serial)
Requirements
- Python >= 3.10
adbandfastbootinstalled and in PATH- USB debugging enabled on target device
Use Cases
- Root automation: Script the full root workflow alongside moto-root-2026
- Pentesting: Automate Android device reconnaissance and data extraction
- Testing: UI automation, app testing, screenshot capture
- Forensics: Pull app data, databases, and device logs
Donate
If this saved you time:
- PayPal: bill.jtrammell@gmail.com
- Cash App: $slauter99
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py_adbkit-0.1.0.tar.gz
(7.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_adbkit-0.1.0.tar.gz.
File metadata
- Download URL: py_adbkit-0.1.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45e95282b040cd7634d655f8cee1d0930a643a37d62ca92dded6f81e7a84584f
|
|
| MD5 |
0ce0f688260496b899ad1f5ad5115764
|
|
| BLAKE2b-256 |
c7abcc45344f1c7caad331a7ede8ddc131a2dfaf1064b673e28afda2d5c7be26
|
File details
Details for the file py_adbkit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: py_adbkit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e735d9ad0d9bf7f0527ccee0c7be65b275e85fb60b5b5a1c8d2df1d4874c8ac9
|
|
| MD5 |
af99d9e350320285fcbc9d427d2d6ba9
|
|
| BLAKE2b-256 |
a5f6243a63550a22867ccab357d85673e59b1383be02932fc4a0f9511c669ddc
|