1

我正在使用radare2进行逆向工程实践。我想修补 vim 二进制文件(linux),以便当用户按下“i”时,它会被替换为“e”。

如何使用radare2在反汇编文件中找到从键盘读取的内容?

4

1 回答 1

1

假设我无法阅读源代码,我将按如下方式处理问题:

  1. 创建一个不可写文件,用 vim 打开并按“i”。Vim 会给你一个警告 "Changing a readonly file"
  2. 在radare2中执行以下操作
$>r2 /usr/bin/vim
[0x00072220]> #Perform analysis
[0x00072220]> aa
[x] Analyze all flags starting with sym. and entry0 (aa)
[0x00072220]> aae
[0x00072220]> #Search for the warning string from earlier
[0x00072220]> f~str~Changing
0x002a1db8 39 str.W10:_Warning:_Changing_a_readonly_file
[0x00072220]> #Find xref to string
[0x00072220]> axt 0x002a1db8
sym.change_warning 0x138f29 [STRING] lea rsi, str.W10:_Warning:_Changing_a_readonly_file
sym.change_warning 0x138f4c [STRING] lea rsi, str.W10:_Warning:_Changing_a_readonly_file
[0x00072220]> #Find xref to symbol
[0x00072220]> f~sym.change_warning
0x00138e70 369 sym.change_warning
[0x00072220]> axt 0x00138e70
sym.ex_diffgetput 0x8875a [CALL] call sym.change_warning
sym.edit 0x97242 [CALL] call sym.change_warning
sym.changed 0x139058 [CALL] call sym.change_warning
sym.u_undo 0x21d716 [CALL] call sym.change_warning
sym.u_savecommon 0x21de85 [CALL] call sym.change_warning
sym.undo_time 0x21f38c [CALL] call sym.change_warning
sym.undo_time 0x21f635 [CALL] call sym.change_warning
[0x00072220]> 
  1. 您最终会得到一个可以进一步调查的函数调用列表。您可能希望单独检查每个函数或确定哪个函数使用 scanf()
于 2020-03-24T21:34:21.340 回答