How to use frida-fs - 8 common examples

To help you get started, we’ve selected a few frida-fs 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 ChiChou / bagbak / agent / src / index.js View on Github external
if (opt.verbose)
        console.log('compress:', relative)

      const entry = libarchive.entryNew()
      libarchive.entrySetPathname(entry, Memory.allocUtf8String(path.join(prefix, relative)))
      libarchive.entrySetSize(entry, st.size)
      libarchive.entrySetFiletype(entry, fs.constants.S_IFREG)
      libarchive.entrySetPerm(entry, st.mode & 0o777)
      libarchive.entrySetCtime(entry, timestamp(st.ctime), 0)
      libarchive.entrySetMtime(entry, timestamp(st.mtime), 0)
      libarchive.writeHeader(ar, entry)

      const filename = relative in lookup ? lookup[relative].decrypted : absolute
      let stream
      try {
        stream = fs.createReadStream(filename, { highWaterMark })
      } catch (e) {
        if (!/(\/Plugins\/(.*)\.appex\/)?SC_Info\//.test(relative))
          console.warn(`unable to open ${filename} (${e.message})`)
        continue
      }

      await new Promise((resolve, reject) =>
        stream
          .on('data', chunk => {
            Memory.writeByteArray(buf, chunk)
            libarchive.writeData(ar, buf, chunk.byteLength)
          })
          .on('end', resolve)
          .on('error', reject))

      // delete decrypted file
github ChiChou / bagbak / agent / src / index.js View on Github external
const timestamp = date => Math.floor(date.getTime() / 1000)
    const lookup = {}
    for (let mod of decrypted)
      lookup[mod.relative] = mod

    let nextObj = null
    while (nextObj = enumerator.nextObject()) {
      const relative = nextObj.toString()
      if (/(\_CodeSignature\/CodeResources|SC_Info\/\w+\.s(inf|upf|upp|upx))$/.test(relative))
        continue

      if (!opt.keepWatch && /^Watch\//.test(relative))
        continue

      const absolute = path.join(root, relative)
      const st = fs.statSync(absolute)
      if (st.mode & fs.constants.S_IFDIR) {
        // doesn't need to handle?
        continue
      } else if (!(st.mode & fs.constants.S_IFREG)) {
        console.error('unknown file mode', absolute)
      }

      if (opt.verbose)
        console.log('compress:', relative)

      const entry = libarchive.entryNew()
      libarchive.entrySetPathname(entry, Memory.allocUtf8String(path.join(prefix, relative)))
      libarchive.entrySetSize(entry, st.size)
      libarchive.entrySetFiletype(entry, fs.constants.S_IFREG)
      libarchive.entrySetPerm(entry, st.mode & 0o777)
      libarchive.entrySetCtime(entry, timestamp(st.ctime), 0)
github ChiChou / bagbak / agent / src / index.js View on Github external
const lookup = {}
    for (let mod of decrypted)
      lookup[mod.relative] = mod

    let nextObj = null
    while (nextObj = enumerator.nextObject()) {
      const relative = nextObj.toString()
      if (/(\_CodeSignature\/CodeResources|SC_Info\/\w+\.s(inf|upf|upp|upx))$/.test(relative))
        continue

      if (!opt.keepWatch && /^Watch\//.test(relative))
        continue

      const absolute = path.join(root, relative)
      const st = fs.statSync(absolute)
      if (st.mode & fs.constants.S_IFDIR) {
        // doesn't need to handle?
        continue
      } else if (!(st.mode & fs.constants.S_IFREG)) {
        console.error('unknown file mode', absolute)
      }

      if (opt.verbose)
        console.log('compress:', relative)

      const entry = libarchive.entryNew()
      libarchive.entrySetPathname(entry, Memory.allocUtf8String(path.join(prefix, relative)))
      libarchive.entrySetSize(entry, st.size)
      libarchive.entrySetFiletype(entry, fs.constants.S_IFREG)
      libarchive.entrySetPerm(entry, st.mode & 0o777)
      libarchive.entrySetCtime(entry, timestamp(st.ctime), 0)
      libarchive.entrySetMtime(entry, timestamp(st.mtime), 0)
github ChiChou / bagbak / agent / src / index.js View on Github external
let nextObj = null
    while (nextObj = enumerator.nextObject()) {
      const relative = nextObj.toString()
      if (/(\_CodeSignature\/CodeResources|SC_Info\/\w+\.s(inf|upf|upp|upx))$/.test(relative))
        continue

      if (!opt.keepWatch && /^Watch\//.test(relative))
        continue

      const absolute = path.join(root, relative)
      const st = fs.statSync(absolute)
      if (st.mode & fs.constants.S_IFDIR) {
        // doesn't need to handle?
        continue
      } else if (!(st.mode & fs.constants.S_IFREG)) {
        console.error('unknown file mode', absolute)
      }

      if (opt.verbose)
        console.log('compress:', relative)

      const entry = libarchive.entryNew()
      libarchive.entrySetPathname(entry, Memory.allocUtf8String(path.join(prefix, relative)))
      libarchive.entrySetSize(entry, st.size)
      libarchive.entrySetFiletype(entry, fs.constants.S_IFREG)
      libarchive.entrySetPerm(entry, st.mode & 0o777)
      libarchive.entrySetCtime(entry, timestamp(st.ctime), 0)
      libarchive.entrySetMtime(entry, timestamp(st.mtime), 0)
      libarchive.writeHeader(ar, entry)

      const filename = relative in lookup ? lookup[relative].decrypted : absolute
github ChiChou / bagbak / agent / src / index.js View on Github external
console.warn(`unable to open ${filename} (${e.message})`)
        continue
      }

      await new Promise((resolve, reject) =>
        stream
          .on('data', chunk => {
            Memory.writeByteArray(buf, chunk)
            libarchive.writeData(ar, buf, chunk.byteLength)
          })
          .on('end', resolve)
          .on('error', reject))

      // delete decrypted file
      if (relative in lookup)
        fs.unlinkSync(filename)

      libarchive.writeFinishEntry(ar)
      libarchive.entryFree(entry)
    }

    libarchive.writeFinish(ar)
    console.log('done', pkg)
    return transfer(pkg)
  },
  skipPkdValidationFor(pid) {
github ChiChou / bagbak / agent / src / index.js View on Github external
recv('flush', () => { }).wait()
        sent += chunk.byteLength
        console.log(`downloaded ${format(sent)} of ${format(size)}, ${(sent * 100 / size).toFixed(2)}%`)
      })
      .on('end', resolve)
      .on('error', reject))

  send({
    subject,
    event: 'end',
    session,
  })

  console.log('transfer complete')
  fs.unlinkSync(filename)

  try {
    const SOUND = 1007
    const playSound = Module.findExportByName('AudioToolbox', 'AudioServicesPlaySystemSound')
    new NativeFunction(playSound, 'void', ['int'])(SOUND)
  } catch (e) {

  }
}
github ChiChou / bagbak / agent / src / index.js View on Github external
async function transfer(filename) {
  const session = Math.random().toString(36).substr(2)
  const highWaterMark = 4 * 1024 * 1024
  const subject = 'download'
  const { size } = fs.statSync(filename)
  const stream = fs.createReadStream(filename, { highWaterMark })

  console.log('start transfering')
  send({
    subject,
    event: 'start',
    session,
    size,
  })

  const format = size => `${(size / 1024 / 1024).toFixed(2)}MiB`

  let sent = 0
  await new Promise((resolve, reject) =>
    stream
      .on('data', chunk => {
        send({
github ChiChou / bagbak / agent / src / index.js View on Github external
async function transfer(filename) {
  const session = Math.random().toString(36).substr(2)
  const highWaterMark = 4 * 1024 * 1024
  const subject = 'download'
  const { size } = fs.statSync(filename)
  const stream = fs.createReadStream(filename, { highWaterMark })

  console.log('start transfering')
  send({
    subject,
    event: 'start',
    session,
    size,
  })

  const format = size => `${(size / 1024 / 1024).toFixed(2)}MiB`

  let sent = 0
  await new Promise((resolve, reject) =>
    stream
      .on('data', chunk => {

frida-fs

Create a stream from a filesystem resource

MIT
Latest version published 10 months ago

Package Health Score

59 / 100
Full package analysis

Similar packages