使用 lldb 查找字符串内存

Jon*_*ona 3 string macos mach-o lldb

您好,我正在尝试在 mac os 上的 lldb 中查找字符串的地址。

在 GDB 中,我会使用find带有地址的命令进行搜索。但是我找不到 lldb 这样的命令,我知道该字符串在 cstring 部分中,在我的情况下是0x00000000002e4f08-0x000000000032e0a8. 但我需要确切地知道在哪里。

rus*_*net 5

一个简单的例子,它使用三个 lldb 命令image dump sections, memory findmemory read在一个剥离的发布应用程序中查找一个字符串。

(lldb) image dump sections MyAppBinary 
[0x0000010462c000-0x00000107744000] 0x0003118000 MyApp`__TEXT
[0x00000107744000-0x00000107d48000] 0x0000604000 MyApp`__DATA
/* removed sections for brevity */

(lldb) mem find -s "youtube" -- 0x00000107744000 0x00000107d48000
data found at location: 0x10793362c
0x10793362c: 79 6f 75 74 75 62 65 2e 63 6f 6d 2f 65 6d 62 65  youtube.com/embe


(lldb) memory read -c100 0x10793362c
0x10793362c: 79 6f 75 74 75 62 65 2e 63 6f 6d 2f 65 6d 62 65  youtube.com/embe
0x10793363c: 64 2f 58 46 67 45 59 75 35 71 66 36 38 3f 61 75  d/XFgccu5qf68?a
Run Code Online (Sandbox Code Playgroud)

如果您需要一些有用的别名和脚本,lldb可以访问https://github.com/DerekSelander/LLDB。例如,我更喜欢 Derek 的脚本sections而不是image dump sections MyAppBinary.