Skip to content

Commit

Permalink
Spawn package if not running
Browse files Browse the repository at this point in the history
  • Loading branch information
0x742 committed Jul 2, 2020
1 parent c128442 commit d1e00d9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,14 @@ async function get_frida_script(device_id, package_identifier, res) {
if(!Object.keys(session_scripts).includes(`${device_id}:${package_identifier}`)) {
const device = await frida.getDevice(device_id);
let session;
let pid = -1;
try {
session = await device.attach(package_identifier);
}
catch(e) {
try {
session = await device.spawn(package_identifier);
pid = await device.spawn(package_identifier);
session = await device.attach(pid);
}
catch(e) {
return {"error": e.message};
Expand All @@ -144,6 +146,9 @@ async function get_frida_script(device_id, package_identifier, res) {
const script = await session.createScript(source);
script.message.connect(onMessage);
await script.load();
if(pid > -1) { // if the application was spawned we should resume it
device.resume(session.pid);
}
session_scripts[`${device_id}:${package_identifier}`] = script;
}
return session_scripts[`${device_id}:${package_identifier}`];
Expand Down

0 comments on commit d1e00d9

Please sign in to comment.