Giter VIP home page Giter VIP logo

frida-inject's Introduction

frida-inject

With this module, you can easily inject javascript into processes.

Features

  • Bundle & Transpile injected scripts (no frida-compile needed)
  • Clean frida bloat (tmp folder & injector process)
  • Retry if process not found
  • Easy to use!

Installation

$ npm install frida-inject

Documentation

FridaInject (options): Function

  • options: Object
    • clean: Boolean [default=true]
    • debug: Boolean [default=false]
    • device: FridaDevice [default=localDevice]
    • pid: Number // Process id
    • name: String // Process name
    • scripts: Array< String|Array<String> > [default=[]]
    • waitDelay: Number [default=0] (ms to wait before retrying injection|0=off)
    • onAttach: Function<session>
    • onDetach: Function<session, reason>
    • onLoad: Function<script>
    • onUnload: Function<script>

Example

Simple injection

const FridaInject = require('frida-inject')

FridaInject({
  name: 'notepad++.exe',
  scripts: [
    'console.log("This is some basic injected script")',
    './some_folder'
  ],
  onAttach: session => console.log('Attached to process'),
  onDetach: (session, reason) => console.log('Detached from process'),
  onLoad: script => console.log('Script loaded'),
  onUnload: script => console.log('Script unloaded')
})

Simple injection (Bundled scripts)

Since version 0.3.0 you can provide multiple scripts into one script.
This will allow you to share a global scope.

const FridaInject = require('frida-inject')

FridaInject({
  name: 'notepad++.exe',
  scripts: [
    ['frida-ex-nativefunction', 'console.log(ExNativeFunction)']
  ]
})

Advanced injection (provided device)

const Frida = require('frida')
const FridaInject = require('frida-inject')

async function main() {
  const device = await Frida.getUsbDevice()
  const pid = await device.spawn('com.atebits.Tweetie2', {
    url: 'twitter://user?screen_name=fridadotre',
    env: {
      'OS_ACTIVITY_DT_MODE': 'YES',
      'NSUnbufferedIO': 'YES'
    },
    stdio: 'pipe'
  })

  FridaInject({
    device: device,
    pid: pid,
    scripts: [
      'console.log("This is some basic injected script")',
      './inject'
    ],
    onAttach: session => console.log('Attached to process'),
    onDetach: (session, reason) => console.log('Detached from process'),
    onLoad: script => console.log('Script loaded'),
    onUnload: script => console.log('Script unloaded')
  })
}
main()

TODO

  • Implement better clean logic

frida-inject's People

Contributors

cre3per avatar freehuntx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.