pwnlib.adb — Android Debug Bridge

Provides utilities for interacting with Android devices via the Android Debug Bridge.

class pwnlib.adb.AdbDevice(serial, type, port, product='unknown', model='unknown', device='unknown')[source]

Encapsulates information about a connected device.

pwnlib.adb.adb(argv, *a, **kw)[source]

Returns the output of an ADB subcommand.[source]

Returns the Build ID of the device.


Compile a source file or project with the Android NDK.

pwnlib.adb.devices(*a, **kw)[source]

Returns a list of Device objects corresponding to the connected devices.


Disables dm-verity on the device.

pwnlib.adb.fastboot(args, *a, **kw)[source]

Executes a fastboot command.

Returns:The command output.

Given a directory path, find the topmost project root.

tl;dr “foo/bar/jni/baz.cpp” ==> “foo/bar”


Returns the device build fingerprint.


Sets up a port to forward to the device.


Reads a properties from the system property store.

Parameters:name (str) – Optional, read a single property.
Returns:If name is not specified, a dict of all properties is returned. Otherwise, a string is returned with the contents of the named property.

Spawns an interactive shell.


Returns a list containing the entries in the provided directory.


Because adb shell is used to retrieve the listing, shell environment variable expansion and globbing are in effect.

pwnlib.adb.logcat(*a, **kw)[source]

Reads the system log file.

By default, causes logcat to exit after reading the file.

Parameters:stream (bool) – If True, the contents are streamed rather than read in a one-shot manner. Default is False.
Returns:If stream is False, returns a string containing the log data. Otherwise, it returns a tube connected to the log output.

Returns a list of PIDs for the named process.


Returns the full path of the executable for the provided PID.

pwnlib.adb.process(argv, *a, **kw)[source]

Execute a process on the device.

See pwnlib.tubes.process.process documentation for more info.

Returns:A process tube.

Returns the device product identifier.

pwnlib.adb.pull(remote_path, local_path=None)[source]

Download a file from the device.

  • remote_path (str) – Path or directory of the file on the device.
  • local_path (str) – Path to save the file to. Uses the file’s name by default.
pwnlib.adb.push(local_path, remote_path)[source]

Upload a file to the device.

  • local_path (str) – Path to the local file to push.
  • remote_path (str) – Path or directory to store the file on the device.*a, **kw)[source]

Download a file from the device, and extract its contents.

  • path (str) – Path to the file on the device.
  • target (str) – Optional, location to store the file. Uses a temporary file by default.

Reboots the device.


Reboots the device to the bootloader.


Remounts the filesystem as writable.


Restarts adbd as root.

pwnlib.adb.setprop(name, value)[source]

Writes a property to the system property store.**kw)[source]

Returns an interactive shell.


Unlocks the bootloader of the device.


This requires physical interaction with the device.


Restarts adbd as AID_SHELL.

pwnlib.adb.wait_for_device(*a, **kw)[source]

Waits for a device to be connected.

pwnlib.adb.which(*a, **kw)[source]

Retrieves the full path to a binary in PATH on the device

pwnlib.adb.write(*a, **kw)[source]

Create a file on the device with the provided contents.

  • path (str) – Path to the file on the device
  • data (str) – Contents to store in the file