Skip to content

Commit 9c6c515

Browse files
authored
Merge pull request #21 from foundryzero/release/1.1.0
1.1.0 Release - add frequency pane
2 parents 59d59d9 + 2891286 commit 9c6c515

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1418
-650
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ bin/
1313

1414
.venv/*
1515
venv/*
16+
.vscode/*
17+
18+
binder_trace-parse-log*
19+
binder_trace-log*
20+
21+
.tox-info.json

.tox/py310/.tox-info.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"ToxEnv": {
3+
"name": "py310",
4+
"type": "VirtualEnvRunner"
5+
}
6+
}

.tox/py39/.tox-info.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"ToxEnv": {
3+
"name": "py39",
4+
"type": "VirtualEnvRunner"
5+
}
6+
}

README.md

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ You'll need a rooted Android device or emulator.
4848
| -n NAME | The name of the process on DEVICE to attach to e.g. "Messaging". |
4949
| -a [9, 10, 11, 13] | The version of android to load structures for. |
5050
| -s STRUCTPATH | The path to the directory of structure files. |
51-
51+
| -c CONFIG | The path to the config file to filter. |
5252

5353
# ▶️ Starting binder trace
5454

@@ -73,6 +73,7 @@ emulator-5554 device
7373

7474
# ⌨️ Controls
7575

76+
## 🌐 Global
7677
| Key | Action |
7778
|------------------|----------------------------------------|
7879
| `up` | Move up |
@@ -84,17 +85,55 @@ emulator-5554 device
8485
| `tab` | Next pane |
8586
| `shift + tab` | Previous pane |
8687
| `ctrl + c` | Copy pane to clipboard |
87-
| `f` | Open filter options |
8888
| `space` | Pause/Unpause transaction recording |
8989
| `c` | Clear |
9090
| `h` | Open help |
91+
| `r` | Reload config file |
9192
| `q` | Quit |
9293

93-
# 🔎 Filtering
94-
If you're interested in specific messages you can filter the displayed results with the following options.
94+
## 📈 Frequency pane
95+
| Key | Action |
96+
|------------------|----------------------------------------|
97+
| `p` | Toggle order asc/desc|
98+
| `w` | Jump to next interface|
99+
| `s` | Jump to previous interface|
100+
| `enter` | Toggle Filter|
101+
102+
# 🔎 Config File
103+
To filter define any or all of the interface, method, type and inclusive options. To not use an option leave it blank `""`
104+
105+
## Without -c argument
106+
107+
```
108+
> binder-trace -d emulator-5554 -n Contacts -a 13
109+
```
110+
![Before Config](binder-trace-before-config.png)
111+
112+
## With -c argument
113+
### config.json
114+
```py
115+
{
116+
"filters": [
117+
{
118+
"interface": "android.gui.IDisplayEventConnection",
119+
"method": "requestNextVsync",
120+
"type": "",
121+
"inclusive": false
122+
},
123+
{
124+
"interface": "android.content.IContentProvider",
125+
"method": "",
126+
"type": "call",
127+
"inclusive": false
128+
}
129+
]
130+
}
131+
```
132+
133+
```
134+
> binder-trace -d emulator-5554 -n Contacts -a 13 -c .\binder_trace\binder_trace\config.json
135+
```
95136

96-
* __Interface__ - limit results to interfaces that contain the case sensitive search string e.g. "com.android" or "Sms".
97-
* __Method__ - limit results to function names containing the specified case sensitive string.
98-
* __Type__ - Limit results to certain types of messages e.g. requests or responses.
137+
`android.gui.IDisplayEventConnection`->`requestNextVsync`->`""` and `android.content.IContentProvider`->`""` ->`call` have been filtered out
99138

100-
Once you've entered your filter options just press `Enter` to apply them.
139+
![After Config](binder-trace-after-config.png)

binder-trace-after-config.png

123 KB
Loading

binder-trace-before-config.png

119 KB
Loading

binder-trace.gif

5.97 MB
Loading

binder_trace/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ venv/
3232
ENV/
3333
env.bak/
3434
venv.bak/
35+
.vscode/*
3536

3637
# Tox
3738
.tox
Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
import argparse
2+
import json
23
import logging
34
import traceback
4-
5-
import json
65
from os import path
76

8-
import binder_trace.loggers
97
import binder_trace.constants
8+
import binder_trace.loggers
109
import binder_trace.structure
11-
import binder_trace.tui
12-
10+
import binder_trace.tui.interface
1311
from binder_trace import loggers
1412
from binder_trace.generator import FridaInjector
1513

1614
loggers.configure()
1715

1816
log = logging.getLogger(loggers.LOG)
1917

18+
2019
def main():
2120
parser = argparse.ArgumentParser(
2221
description="Connects to a Android device with a "
@@ -28,53 +27,63 @@ def main():
2827
group = parser.add_mutually_exclusive_group(required=True)
2928
group.add_argument("-p", "--pid", dest="pid", type=int, help="the process id to attach to")
3029
group.add_argument("-n", "--name", dest="name", type=str, help="the process name to attach to")
31-
32-
parser.add_argument("-d", "--device", dest="device", type=str, help="the android device to attach to")
3330

34-
struct_group = parser.add_mutually_exclusive_group(required=True)
31+
parser.add_argument(
32+
"-d",
33+
"--device",
34+
dest="device",
35+
type=str,
36+
help="the android device to attach to",
37+
)
3538

36-
struct_group.add_argument("-a",
37-
'--android-version',
38-
const='all',
39-
nargs='?',
40-
choices=['9', '10', '11', '12', '13'],
41-
default='13',
42-
help='Android version structs to use')
39+
struct_group = parser.add_mutually_exclusive_group(required=True)
4340

4441
struct_group.add_argument(
45-
"-s", "--structpath", help="provides the path to the root of the struct directory. e.g. ../structs/android11"
42+
"-a",
43+
"--android-version",
44+
const="all",
45+
nargs="?",
46+
choices=["9", "10", "11", "12", "13"],
47+
default="13",
48+
help="Android version structs to use",
4649
)
4750

48-
parser.add_argument(
49-
"-c", "--config", help="Path to a binder-trace configuration file"
51+
struct_group.add_argument(
52+
"-s",
53+
"--structpath",
54+
help="provides the path to the root of the struct directory. e.g. ../structs/android11",
5055
)
5156

57+
parser.add_argument("-c", "--config", help="Path to a binder-trace configuration file")
5258
args = parser.parse_args()
5359

54-
structs_dict = {"9": "android9", "10": "android10", "11": "android11", "12": "android-12.1.0_r27", "13": "android13.0.0-r_49"}
55-
60+
structs_dict = {
61+
"9": "android9",
62+
"10": "android10",
63+
"11": "android11",
64+
"12": "android-12.1.0_r27",
65+
"13": "android13.0.0-r_49",
66+
}
67+
5668
base_dir = path.dirname(path.abspath(__file__))
5769

5870
struct_path = args.structpath or path.join(base_dir, "structs", structs_dict[args.android_version])
5971

6072
if not path.exists(struct_path):
61-
print(f"Struct path \"{struct_path}\" not found.")
73+
print(f'Struct path "{struct_path}" not found.')
6274
exit(-1)
63-
64-
config = None
65-
if args.config:
66-
if not path.exists(args.config):
67-
print("Config path not found.")
68-
exit(-1)
69-
70-
with open(args.config, "r") as f:
71-
config = json.load(f)
7275

76+
config = None
7377
injector = None
7478
try:
75-
injector = FridaInjector(args.pid or args.name, struct_path, binder_trace.constants.ANDROID_VERSION, args.device)
79+
injector = FridaInjector(
80+
args.pid or args.name,
81+
struct_path,
82+
int(args.android_version),
83+
args.device,
84+
)
7685
injector.start()
77-
binder_trace.tui.start_ui(injector.block_queue, injector.pause_unpause, config)
86+
binder_trace.tui.interface.start_ui(injector.block_queue, injector.pause_unpause, config, args.config)
7887
log.info("UI Stopped")
7988
except Exception as err:
8089
print(err)
@@ -87,5 +96,6 @@ def main():
8796
injector.stop()
8897
log.info("Injector stopped.")
8998

99+
90100
if __name__ == "__main__":
91101
main()
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
{
2-
"filters" : [
3-
{"interface": "android.app.IActivityManager", "inclusive": false},
4-
{"interface": "android.os.IServiceManager", "inclusive": false},
5-
{"interface": "android.content.IContentProvider", "inclusive": false},
6-
{"interface": "android.content.IContentService", "inclusive": false},
7-
{"interface": "android.content.pm.IPackageManager", "inclusive": false}
2+
"filters": [
3+
{
4+
"interface": "android.gui.IDisplayEventConnection",
5+
"method": "requestNextVsync",
6+
"type": "",
7+
"inclusive": false
8+
},
9+
{
10+
"interface": "android.content.IContentProvider",
11+
"method": "",
12+
"type": "call",
13+
"inclusive": false
14+
}
815
]
916
}

0 commit comments

Comments
 (0)