Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
agent.message.connect((message, data) => {
if (message.type === 'error') {
console.error('error message from frida'.red)
console.error((message.stack || message).red)
} else if (message.type === 'send') {
// todo
}
})
await agent.load()
socket.emit('ready')
})
const mgr = frida.getDeviceManager()
const connected = new Map()
export function attach(server) {
socket.attach(server)
const wrap = tag => device =>
devices.emit(tag, new Device(device).valueOf())
const added = wrap('DEVICE_ADD')
const removed = wrap('DEVICE_REMOVE')
mgr.added.connect(added)
mgr.removed.connect(removed)
connected.set(server, [added, removed])
}
export function detach(server) {
async function updateDeviceList() {
// Get dropdown array
var dn = document.getElementById("deviceName");
var currentDevice = dn.options[deviceName.selectedIndex].value;
var dnArr = Array.from(dn.options).map(elem => elem.text);
// Get device array
var dm = frida.getDeviceManager();
var dev = await dm.enumerateDevices();
var devArr = dev.map(elem => elem.id);
// Does the current device still exist?
if (!devArr.includes(currentDevice)) {
// Local is always a valid target
dn.selectedIndex = 0;
deviceId = 'local';
}
// Remove stale entries from the dropdown
dnArr.forEach(function(elem) {
if (!devArr.includes(elem)) {
$(`#deviceName option:contains("${elem}")`).remove()
}
})
const frida = require('frida')
const socketIO = require('socket.io')
const { RpcHandler } = require('./rpc')
const { serializeDevice, serializeApp, FridaUtil } = require('./utils')
const io = socketIO({ path: '/msg' })
const channels = {}
for (const namespace of ['devices', 'session'])
channels[namespace] = io.of(`/${namespace}`)
const deviceMgr = frida.getDeviceManager()
deviceMgr.added.connect(async device => channels.devices.emit('deviceAdd', serializeDevice(device)))
deviceMgr.removed.connect(async device => channels.devices.emit('deviceRemove', serializeDevice(device)))
channels.session.on('connection', async(socket) => {
const { device, bundle } = socket.handshake.query
let dev, session, app
if (!device || !bundle) {
socket.emit('err', 'invalid parameters')
socket.disconnect(true)
return
}
try {
dev = await frida.getDevice(device)
async function getDeviceList() {
var dm = await frida.getDeviceManager();
var dev = await dm.enumerateDevices();
return dev;
}
static remove(host) {
return getDeviceManager().removeRemoteDevice(host)
}
static async connect(host) {
return new ExtendedDevice(await getDeviceManager().addRemoteDevice(host))
}
return this.scheduler.perform("Getting device", async (): Promise => {
let device: frida.Device;
switch (targetDevice.kind) {
case "local":
device = await frida.getLocalDevice();
break;
case "usb":
device = await frida.getUsbDevice();
break;
case "remote":
device = await frida.getRemoteDevice();
break;
case "by-host":
device = await frida.getDeviceManager().addRemoteDevice(targetDevice.host);
break;
case "by-id":
device = await frida.getDevice(targetDevice.id);
break;
default:
throw new Error("Invalid target device");
}
return device;
});
}