Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function resolveDevice(device) {
console.error('[+] Using', device, 'target');
switch (device) {
case 'usb':
return frida.getUsbDevice();
case 'local':
return frida.getLocalDevice();
case 'tcp':
return frida.getRemoteDevice();
break;
}
return function() {
this.then = function() {
throw(new Error('invalid device'));
}
}
}
co(function *() {
const device = yield frida.getUsbDevice();
const pid = yield device.spawn(['com.apple.AppStore']);
session = yield device.attach(pid);
const source = yield load(
require.resolve('./agent.js'));
script = yield session.createScript(source);
script.events.listen('message', message => {
if (message.type === 'send' && message.payload.event === 'ready')
device.resume(pid);
else
console.log(message);
});
yield script.load();
})
.catch(console.error);
co(function *() {
device = yield frida.getUsbDevice();
device.events.listen('spawned', onSpawned);
device.enableSpawnGating();
const pending = yield device.enumeratePendingSpawns();
pending.forEach(function (spawn, i) {
console.log('pending[' + i + ']=', spawn, ' Resuming!');
device.resume(spawn.pid);
});
console.log('ready');
})
.catch(function (error) {
co(function *() {
const device = yield frida.getUsbDevice();
const app = yield device.getFrontmostApplication();
if (app === null)
throw new Error("No app in foreground");
session = yield device.attach(app.pid);
const source = yield load(
require.resolve('./agent.js'));
script = yield session.createScript(source);
script.events.listen('message', message => {
console.log(message.payload.ui);
session.detach();
});
yield script.load();
});
co(function *() {
const device = yield frida.getUsbDevice();
session = yield device.attach('re.frida.helloworld');
const source = yield load(
require.resolve('./agent.js'));
script = yield session.createScript(source);
script.events.listen('message', message => {
console.log(message);
});
yield script.load();
});
static async usb() {
return new Device(await frida.getUsbDevice())
}
static async usb(...args) {
return new ExtendedDevice(await getUsbDevice(...args))
}
module.exports = co.wrap(function* (opts) {
opts = opts || require('../config');
const device = opts && opts.remote ?
yield frida.getRemoteDevice() :
yield frida.getUsbDevice();
debug(device);
return device;
});