nowsecure / r2frida

Radare2 and Frida better together.
MIT License
1.18k stars 121 forks source link

Implement /z in r2frida #92

Closed trufae closed 8 months ago

trufae commented 6 years ago

Use this code in agent-side to grab strings from data buffers:


function isPrintable (ch) {
  return (ch >= 32 && ch <= 126);
}

function parseOptions (options) {
  const opts = {
    minLength: 15,
    disabled: false
  };
  if (typeof options === 'object') {
    if (options.enabled === false) {
      opts.disabled = true;
    }
    for (let key of Object.keys(options)) {
      opts[key] = options[key];
    }
  }
  return opts;
}

function parseStrings (data, options) {
  const opt = parseOptions(options);
  const strs = [];
  let str = '';
  data.forEach(ch => {
    if (isPrintable(ch)) {
      str += String.fromCharCode(ch);
    } else {
      if (str.length > opt.minLength) {
        strs.push(str);
        str = '';
      }
    }
  });
  return strs;
}
trufae commented 10 months ago

cc @as0ler

trufae commented 8 months ago

implemented in cf10a0aabd5a5a6106231aad127dd5fa3b2e9d11