美文网首页hooker
iOS逆向与安全5.2:LLDB进阶

iOS逆向与安全5.2:LLDB进阶

作者: looha | 来源:发表于2019-06-12 00:08 被阅读0次

ASLR

ASLR(Address space layout randomization)是一种针对缓冲区溢出的安全保护技术,通过对堆、栈、共享库映射等线性区布局的随机化,通过增加攻击者预测目的地址的难度,防止攻击者直接定位攻击代码位置,达到阻止溢出攻击的目的。内核在加载文件的给的偏移地址

大部分主流的操作系统已经实现了ASLR。

  • Linux
    Linux已在内核版本2.6.12中添加ASLR。
  • Windows
    Windows Server 2008,Windows 7,Windows Vista,Windows Server 2008 R2,默认情况下启用ASLR,但它仅适用于动态链接库和可执行文件。
  • Mac OS X
    Apple在Mac OS X Leopard10.5(2007年十月发行)中某些库导入了随机地址偏移,但其实现并没有提供ASLR所定义的完整保护能力。而Mac OS X Lion10.7则对所有的应用程序均提供了ASLR支持。Apple宣称为应用程序改善了这项技术的支持,能让32及64位的应用程序避开更多此类攻击。从OS X Mountain Lion10.8开始,核心及核心扩充(kext)与zones在系统启动时也会随机配置。
  • iOS(iPhone, iPod touch, iPad)
    Apple在iOS4.3内导入了ASLR。
  • Android
    Android 4.0提供地址空间配置随机加载(ASLR),以帮助保护系统和第三方应用程序免受由于内存管理问题的攻击,在Android 4.1中加入地址无关代码(position-independent code)的支持。
  • Macho文件偏移值
    Macho文件的首地址 pageZero 0x0000000010000000
    通过image list 获取到首地址 0x00000000102ae00a3
    差距:0x02ae00a3 偏移地址

  • 获取函数的得真实地址
    函数在Macho文件中得地址 0x100002ea1
    加上便宜地址 0x02ae00a3 即可获得函数加载在内存中的真实地址

  • 基地址 Macho的首地址
    image list 中内存首地址 0x00000000102ae00a3
    方法在文件中的偏移值 0x00000000100002ea1 0x100002ea1 0x00002ea1

  • 例:
    值在内存中的地址为:0x0000000102fd0668
    值在文件中的地址为:0x0000000102df612e
    值在内存中的地址为 - 值在文件中的地址为 即为文件中得偏移值 ASLR

chisel

chisel 安转

brew install chisel

安装完成后, vi ~/.lldbinit 在lldb中引入插件

1 command script import /usr/local/opt/chisel/libexec/fblldb.py
2 command script import /opt/LLDB/lldd_commands/dslldb.py

chisel 使用

  • pviews xxxview 输出xxxview
pviews self.view
image.png
  • pviews - u xxxview 输出xxxview上一层 父控件
- pviews - u self.view
image.png
  • pviews 输出当前所有view
 pviews 
image.png
  • pvc 当前vc层级
pvc
image.png
  • presponder 0xxxxxxxxx xxxxxx的响应链(xxxxxx能响应事件)
 presponder 0x389992edb
image.png
  • pactions 0xxxxxxxxx xxxxxx的target响应者(xxxxxx能响应事件)
pactions   0x22df36900
image.png
  • pclass 0xxxxxxxxx 继承关系
pclass 0x22df36900
image.png
  • fv xxxviewName 查找xxxview
 fv  LLCustomView
image.png
  • fvc xxxVC 查找xxxVCName
fvc XXXXXViewController
image.png
  • fvc -v 0xxxxxxxxx 通过地址查找VC
fvc -v 0x10cac3ee
image.png
  • pmethods 0xxxxxxxxx 查看xxxxxxxx地址对象的方法
pmethods 0x10cac3ee
image.png
  • methonds 0xxxxxxxx 查看xxxxxxxx地址对象所有方法以及属性 方法imp
methonds   0x10cac3ee
image.png image.png
  • pinternals 0xxxxxxxx 查看xxxxxxxx地址对象属性的值
pinternals  0x10cac3ee
image.png
  • taplog 定位到界面能响应事件的控件,点击控件时调用
taplog
image.png
  • flicker 0xxxxxxxx(view地址) 修改xxxxxxx样式
flicker  0xxxxxxxx
  • vs 0xxxxxxxx(view地址) 动态调试view
vs  0xxxxxxxx
image.png
image.png

vs 下w 父控件

w
image.png

vs 下s 子控件

s
image.png

vs 下a 当前控件同层移动

a
image.png

vs 下p 当前控件的层级

p 
image.png

vs 下q 退出vs调试

DerekSelander插件使用

  • search ObjectName 查找类名
search  ObjectName 
  • sbt 恢复符号
    当利用内存下断点后,bt命名查看函数调用栈看到的是去符号调用信息
image.png

此时利用sbt命名可恢复符号

image.png

相关文章

网友评论

    本文标题:iOS逆向与安全5.2:LLDB进阶

    本文链接:https://www.haomeiwen.com/subject/ibhhfctx.html