How to use frida - 10 common examples

To help you get started, we’ve selected a few frida examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chaitin / passionfruit / lib / channelsv2.js View on Github external
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) {
github FuzzySecurity / Fermion / Fermion / src / render.js View on Github external
async function start(Path, Args) {
	// Exit on process termination
	process.on('SIGTERM', stop);
	process.on('SIGINT', stop);

	// Attach and load script
	device = await frida.getDevice(deviceId);
	if (!Args || 0 === Args.length) {
		procID = await device.spawn(Path);
	} else {
		procID = await device.spawn([Path,Args]);
	}
	session = await device.attach(procID);
	session.detached.connect(onDetached);
	script = await session.createScript(MonacoCodeEditor.getValue());

	// For performance we can't update the text area all the time
	// it will lock the UI on big volumes of data. Instead we append
	// to an array using a mutex and every X ms we flush the array
	// to the text area
	script.message.connect(message => {
		ChangeLogExclusive(logMutex, 'Append', message.payload);
		setTimeout(function () {
github FuzzySecurity / Fermion / Fermion / src / render.js View on Github external
async function inject(AttachTo) {
	// Exit on process termination
	process.on('SIGTERM', stop);
	process.on('SIGINT', stop);

	// Attach and load script
	device = await frida.getDevice(deviceId);
	session = await device.attach(AttachTo);
	session.detached.connect(onDetached);
	script = await session.createScript(MonacoCodeEditor.getValue());

	// For performance we can't update the text area all the time
	// it will lock the UI on big volumes of data. Instead we append
	// to an array using a mutex and every X ms we flush the array
	// to the text area
	script.message.connect(message => {
		ChangeLogExclusive(logMutex, 'Append', message.payload);
		setTimeout(function () {
			if (RunningLog.length > 0) {
				ChangeLogExclusive(logMutex, 'Write', message.payload);
			}
		}, 500);
	});
github FuzzySecurity / Fermion / Fermion / src / proc.html View on Github external
async function getProcList() {
			// Make sure the device list has updated
			if (atob(deviceId) != "local") {
				for (i = 0; i < 3; i++) {
					var dev = await getDeviceList();
					if (dev.length > 2) {
						break;
					}
					await sleep(1000);
				}
			}
			let currentDevice = await frida.getDevice(atob(deviceId));
			let Applications = await currentDevice.enumerateProcesses();
			return Applications;
		}
		getProcList().then(data => {
github FuzzySecurity / Fermion / Fermion / src / render.js View on Github external
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()
		}
	})
github lmangani / node_ssl_logger / node_ssl_logger.js View on Github external
process.exit(code ? code : 0);
}

if(process.argv.indexOf("-p") != -1){ var pid = process.argv[process.argv.indexOf("-p") + 1]; }
if(process.argv.indexOf("-v") != -1){ debug = true; }

try {
      fs.readFile(filename, function read(err, data) {
        if (!err) {
		fsscript = data.toString();
        } else { quit(1,err); }
      });
} catch(e) { quit(1,'Failed loading script!'); }

if (!pid){ process.exit(1);}
frida.attach(pid)
.then(function (session) {
  if (debug) console.log('attached:', session);
  return session.createScript(fsscript);
})
.then(function (script) {
  if(debug) { console.log('script created:', script); }
  console.log('Press Ctrl+C to stop logging...');
  script.events.listen('message', function (message, data) {
    if(data.length >0) {
    	if (debug) console.log('message from script:', message );
    	console.log(data.toString('utf8'));
    }
  });
  script.load();
})
.catch(function (error) {
github sipcapture / HEPjack.js / hepjack.js View on Github external
if(process.argv.indexOf("-p") != -1){ var pid = process.argv[process.argv.indexOf("-p") + 1]; }
if(process.argv.indexOf("-v") != -1){ debug = true; }

if(!pid) { console.error('No process defined! Exiting'); process.exit(1); }

try {
      fs.readFile(filename, function read(err, data) {
        if (!err) {
		fsscript = data.toString();
        } else { quit(1,err); }
      });
} catch(e) { quit(1,'Failed loading Frida script!'); }

if (!pid){ process.exit(1);}

frida.attach(pid)
.then(function (session) {
  if (debug) console.log('attached:', session);
  return session.createScript(fsscript);
})
.then(function(script) {
  if(debug) { console.log('script created:', script); }
  if (!script.events){ quit(1,'failed initializing script'); }
  console.log('Press Ctrl+C to stop logging...');
  script.events.listen('message', function (message, data) {
    if(data && data.length >0) {
	if(debug) { console.log('GOT DATA:', data.toString('utf8'), message) }
	var hep_proto = { "type": "HEP", "version": 3, "payload_type": "SIP", "captureId": hepId, "capturePass": hepPass, "ip_family": 2};
	var datenow =  new Date().getTime();
	hep_proto.time_sec = Math.floor(datenow / 1000);
	hep_proto.time_usec = datenow - (hep_proto.time_sec*1000);
	hep_proto.srcIp = ipInt(message.payload.src_addr).toIP();
github lailune / SLRRMultiplayer / app.js View on Github external
function AttachHook(pid) {
	frida.attach(pid)
		.then(function (session) {
			return session.createScript(injectScript);
		})
		.then(function (script) {
			script.events.listen('message', function (message, data) {
				//console.log('HScript:', message, data);
				handleMessage(script, message.payload.name, message.payload.data);
			});
			script.load()
				.then(function () {
					console.log('Hook script injected.');
				})
				.catch(function (error) {
					console.log('Hook Error:', error.message);
				});
		})
github frida / frida-presentations / ZeroNights2015 / 09-injecting-errors / app.js View on Github external
co(function *() {
  session = yield frida.attach(process.argv[2]);
  const source = yield load(require.resolve('./agent.js'));
  script = yield session.createScript(source);
  script.events.listen('message', message => {
    console.log(message);
  });
  yield script.load();
})
.catch(console.error);
github frida / frida-presentations / ZeroNights2015 / 10-stalking / app.js View on Github external
co(function *() {
  session = yield frida.attach(process.argv[2]);
  const source = yield load(
      require.resolve('./agent.js'));
  script = yield session.createScript(source);
  script.events.listen('message', message => {
    if (message.type === 'send') {
      const stanza = message.payload;
      switch (stanza.name) {
        case '+ready':
          console.log('Waiting for application to call recv()...');
          break;
        case '+result': {
          console.log('Results received:');
          const events = stanza.payload.events;
          events.forEach(ev => {
            const location = ev[0];
            const target = ev[1];

frida

Inject JavaScript to explore native apps on Windows, Mac, Linux, iOS and Android

LGPL-2.0 WITH WxWindows-excep…
Latest version published 3 months ago

Package Health Score

68 / 100
Full package analysis