Frida 是否具有支持跟踪内存修改的功能?

发布于 2025-01-13 08:48:07 字数 328 浏览 3 评论 0原文

我在 iOS 上使用 frida 的 javascript 绑定,我想跟踪线程所做的所有内存修改。我的意思不是在特定位置,例如内存访问监视器通常使用的位置。我有一个使用 dispach_once 和 pthread_once 的线程,我希望也跟踪这些线程的所有修改。我所说的修改是指对堆或代码页中内存的任何写入,而不是读取代码页、写入寄存器或任何此类操作。只是对内存进行显式更改,我假设它是静态 C 变量或结构。非常感谢任何帮助,谢谢。旁注:该应用程序具有针对 lldb 的防御措施以及针对 frida-stalker 的一些防御措施:( 所以我不知道什么会起作用...我也不介意切换到 C 而不是 js,但我需要在 iOS a12+ 上工作

I’m using the javascript bindings of frida on iOS and I want to trace all memory modifications made by a thread. I don’t mean at a specific location like memory access monitor usually is used for. I have a thread that uses dispach_once and pthread_once and I want all modifications from those to be traced too. What I mean by modifications is any write to the memory in the heap or code pages, and not reading code pages, writing regs, or any of that. Just explicit changes to memory that I assume is a static C variable or structure. Any help is very much appreciated thanks. Side note: the application has defense measures against lldb and some defenses for frida-stalker also :( so idk what will work... I also don’t mind switching to C instead of js but I need to to work on iOS a12+

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小嗷兮 2025-01-20 08:48:07

您可以使用内存权限并根据您的需要构建一些东西

Intercept &通过使用 mprotect 删除权限来记录谁读/写 x2。

Process.setExceptionHandler(exp => {
  console.warn(JSON.stringify(Object.assign(exp, { _lr: DebugSymbol.fromAddress(exp.context.lr), _pc: DebugSymbol.fromAddress(exp.context.pc) }), null, 2));
  Memory.protect(exp.memory.address, Process.pointerSize, 'rw-');
  return true; // goto PC 
});

Interceptor.attach(funcPtr, {
  onEnter(args) {
    console.log('onEnter', JSON.stringify({
      x2: this.context.x2,
      mprotect_ret: Memory.protect(this.context.x2, 2, '---'),
      errno: this.errno
    }, null, 2));
  }
});

You can play with memory permissions and build something for your needs

Intercept & log who read/write to x2 via removing permissions w/ mprotect.

Process.setExceptionHandler(exp => {
  console.warn(JSON.stringify(Object.assign(exp, { _lr: DebugSymbol.fromAddress(exp.context.lr), _pc: DebugSymbol.fromAddress(exp.context.pc) }), null, 2));
  Memory.protect(exp.memory.address, Process.pointerSize, 'rw-');
  return true; // goto PC 
});

Interceptor.attach(funcPtr, {
  onEnter(args) {
    console.log('onEnter', JSON.stringify({
      x2: this.context.x2,
      mprotect_ret: Memory.protect(this.context.x2, 2, '---'),
      errno: this.errno
    }, null, 2));
  }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文