File: android.py

package info (click to toggle)
pwntools 4.14.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 18,436 kB
  • sloc: python: 59,156; ansic: 48,063; asm: 45,030; sh: 396; makefile: 256
file content (25 lines) | stat: -rw-r--r-- 577 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from __future__ import print_function

import gdb
from pwn import adb, context

# Tell pwntools that the target is an Android device
context.os = "android"
context.arch = "aarch64"  # or 'arm'

# Optionally, set the remote ADB server address
context.adb_host = "172.16.110.1"

# Wait for a device to become available
print(adb.wait_for_device())

# Who am I?
print(adb.process("id").recvall().strip())

# Interactive sessions!
io = adb.shell()
io.sendline("echo Hello, world; exit")
print(io.recvall().replace("\r\n", "\n").strip())

# Debugging!
gdb.debug("sh").interactive()