FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
frida-python/examples/session_persist_timeout.py at main · feicong/frida-python · GitHub
feicong
/
frida-python
Public
forked from
frida/frida-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
frida-python
/
examples
/
session_persist_timeout.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
81 lines (63 loc) · 1.97 KB
Breadcrumbs
frida-python
/
examples
/
session_persist_timeout.py
Copy path
File metadata and controls
81 lines (63 loc) · 1.97 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
from
frida_tools
.
application
import
Reactor
import
frida
class
Application
:
def
__init__
(
self
):
self
.
_reactor
=
Reactor
(
run_until_return
=
self
.
_process_input
)
self
.
_device
=
None
self
.
_session
=
None
def
run
(
self
):
self
.
_reactor
.
schedule
(
lambda
:
self
.
_start
())
self
.
_reactor
.
run
()
def
_start
(
self
):
device
=
frida
.
get_remote_device
()
self
.
_device
=
device
session
=
self
.
_device
.
attach
(
"hello2"
,
persist_timeout
=
30
)
self
.
_session
=
session
session
.
on
(
"detached"
,
lambda
*
args
:
self
.
_reactor
.
schedule
(
lambda
:
self
.
_on_detached
(
*
args
)))
script
=
session
.
create_script
(
"""
let _puts = null;
Interceptor.attach(DebugSymbol.getFunctionByName('f'), {
onEnter(args) {
const n = args[0].toInt32();
send(n);
}
});
rpc.exports.dispose = () => {
puts('Script unloaded');
};
let serial = 1;
setInterval(() => {
puts(`Agent still here! serial=${serial++}`);
}, 5000);
function puts(s) {
if (_puts === null) {
_puts = new NativeFunction(Module.getExportByName(null, 'puts'), 'int', ['pointer']);
}
_puts(Memory.allocUtf8String(s));
}
"""
)
self
.
_script
=
script
script
.
on
(
"message"
,
lambda
*
args
:
self
.
_reactor
.
schedule
(
lambda
:
self
.
_on_message
(
*
args
)))
script
.
load
()
def
_process_input
(
self
,
reactor
):
while
True
:
try
:
command
=
input
(
"> "
).
strip
()
except
:
self
.
_reactor
.
cancel_io
()
return
if
command
==
"resume"
:
try
:
self
.
_session
.
resume
()
except
Exception
as
e
:
print
(
"Failed to resume:"
,
e
)
else
:
print
(
"Unknown command"
)
def
_on_detached
(
self
,
reason
,
crash
):
print
(
f"⚡ detached: reason=
{
reason
}
, crash=
{
crash
}
"
)
def
_on_message
(
self
,
message
,
data
):
print
(
f"⚡ message:
{
message
}
"
)
app
=
Application
()
app
.
run
()
Back
|
FazBrowse Home
|
New Git URL