ASLR
ASLR(Address space layout randomization)是一種針對緩沖區(qū)溢出的安全保護技術(shù),通過對堆、棧、共享庫映射等線性區(qū)布局的隨機化,通過增加攻擊者預(yù)測目的地址的難度,防止攻擊者直接定位攻擊代碼位置,達到阻止溢出攻擊的目的。內(nèi)核在加載文件的給的偏移地址
大部分主流的操作系統(tǒng)已經(jīng)實現(xiàn)了ASLR。
- Linux
Linux已在內(nèi)核版本2.6.12中添加ASLR。 - Windows
Windows Server 2008,Windows 7,Windows Vista,Windows Server 2008 R2,默認情況下啟用ASLR,但它僅適用于動態(tài)鏈接庫和可執(zhí)行文件。 - Mac OS X
Apple在Mac OS X Leopard10.5(2007年十月發(fā)行)中某些庫導(dǎo)入了隨機地址偏移,但其實現(xiàn)并沒有提供ASLR所定義的完整保護能力。而Mac OS X Lion10.7則對所有的應(yīng)用程序均提供了ASLR支持。Apple宣稱為應(yīng)用程序改善了這項技術(shù)的支持,能讓32及64位的應(yīng)用程序避開更多此類攻擊。從OS X Mountain Lion10.8開始,核心及核心擴充(kext)與zones在系統(tǒng)啟動時也會隨機配置。 - iOS(iPhone, iPod touch, iPad)
Apple在iOS4.3內(nèi)導(dǎo)入了ASLR。 - Android
Android 4.0提供地址空間配置隨機加載(ASLR),以幫助保護系統(tǒng)和第三方應(yīng)用程序免受由于內(nèi)存管理問題的攻擊,在Android 4.1中加入地址無關(guān)代碼(position-independent code)的支持。
Macho文件偏移值
Macho文件的首地址 pageZero 0x0000000010000000
通過image list 獲取到首地址 0x00000000102ae00a3
差距:0x02ae00a3 偏移地址獲取函數(shù)的得真實地址
函數(shù)在Macho文件中得地址 0x100002ea1
加上便宜地址 0x02ae00a3 即可獲得函數(shù)加載在內(nèi)存中的真實地址基地址 Macho的首地址
image list 中內(nèi)存首地址 0x00000000102ae00a3
方法在文件中的偏移值 0x00000000100002ea1 0x100002ea1 0x00002ea1例:
值在內(nèi)存中的地址為:0x0000000102fd0668
值在文件中的地址為:0x0000000102df612e
值在內(nèi)存中的地址為 - 值在文件中的地址為 即為文件中得偏移值 ASLR
chisel
chisel 安轉(zhuǎn)
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的響應(yīng)鏈(xxxxxx能響應(yīng)事件)
presponder 0x389992edb

image.png
- pactions 0xxxxxxxxx xxxxxx的target響應(yīng)者(xxxxxx能響應(yīng)事件)
pactions 0x22df36900

image.png
- pclass 0xxxxxxxxx 繼承關(guān)系
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 定位到界面能響應(yīng)事件的控件,點擊控件時調(diào)用
taplog

image.png
- flicker 0xxxxxxxx(view地址) 修改xxxxxxx樣式
flicker 0xxxxxxxx
- vs 0xxxxxxxx(view地址) 動態(tài)調(diào)試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調(diào)試
DerekSelander插件使用
- search ObjectName 查找類名
search ObjectName
- sbt 恢復(fù)符號
當利用內(nèi)存下斷點后,bt命名查看函數(shù)調(diào)用棧看到的是去符號調(diào)用信息

image.png
此時利用sbt命名可恢復(fù)符號

image.png