-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfino.py
executable file
·82 lines (70 loc) · 2.11 KB
/
fino.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python
"""
Gadget interactive shell
Provices interactive access to Gadget and Fino primitives
for remote inspection of Android applications.
The shell has autocompletion abilities for easy browsing
inside the remote memory.
"""
import sys
import os
import gadget
import traceback
import readline
def completer(base, state):
"""
Autocompletion utility
"""
if "." in base:
split = base.rfind(".")
options = map(lambda x: base[:split+1] + x, filter(
lambda x: x.startswith(base[split+1:]) and not x.startswith("_"),
dir(eval(base[:split]))))
else:
options = filter(
lambda x: x.startswith(base),
globals().keys())
return options[state] if state < len(options) else None
# check for correct usage
if len(sys.argv) < 3:
print "Usage: %s host port [package]" % sys.argv[0]
sys.exit(2)
# get the remote endpoint address
remote = (sys.argv[1], int(sys.argv[2]))
# list the available packages if necessary
if len(sys.argv) < 4:
print "Available packages: " + ",".join(
gadget.proto.list_applications(remote))
sys.exit(0)
# get the package name
package = sys.argv[3]
try:
app = gadget.proto.Application(remote, package)
except Exception as e:
print "Could not connect to the remote application"
traceback.print_exc()
sys.exit(1)
# set some variables
R = app.R
# launch the shell
os.system('clear')
print """
\033[29m
___________ ______
| | |.. | .~ ~.
|______ | | ``.. | | |
| | | ``.. | | |
| | | ``| `.______.'
\033[0m
Fino Copyright (C) 2012 Sysdream
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions, for details see COPYING.
Built-ins:
app -- the current application
gadget -- the main gadget package
R -- the standard resource namespace
"""
os.environ['PYTHONINSPECT'] = 'True'
readline.parse_and_bind("\"\C-tab\": complete")
readline.set_completer(completer)