如何在radare2中为全局变量命名?

时间:2019-03-01 18:05:25

标签: radare2

我有这样的东西:

(fcn) fcn.140001020 20
   fcn.140001020 ();
           ; XREFS: CALL 0x140001080  CALL 0x140001098  CALL 0x1400010b0  CALL 0
           ; XREFS: CALL 0x140001794  CALL 0x1400017ad  CALL 
           0x140001029      mov dword [0x140018a38], eax

我希望能够给地址0x140018a38起一个名字,这样它就会出现类似的内容:

           0x140001029      mov dword [myGlobal], eax

1 个答案:

答案 0 :(得分:0)

环境

  • radare2: radare2 4.2.0-git 23519 @ linux-x86-64 git.4.1.1-84-g0c46c3e1e commit:0c46c3e1e30bb272a5a05fc367d874af32b41fe4 build:2020-01-08__09:49:0
  • 系统: Ubuntu 18.04.3 LTS

解决方案

  • 我不确定radare2是否可以实现您想要的确切功能,但是我们可以使用Cf和CCa命令来接近它。
    • CCa [-at] | [at] [text] [@addr]#在给定地址添加/删除评论
    • Cf [?] [-] [sz] [0 | cnt] [fmt] [a0 a1 ...] [@addr]#格式内存(请参阅pf?)

示例

user@host:~$ r2 /my/example
[0x00000000]> aaaa
...
[0x00000000]> s fcn.140001020
[0x140001020]> pd 1
(fcn) fcn.140001020 20
   fcn.140001020 ();
           ; XREFS: CALL 0x140001080  CALL 0x140001098  CALL 0x1400010b0  CALL 0
           ; XREFS: CALL 0x140001794  CALL 0x1400017ad  CALL 
           0x140001029      mov dword [0x140018a38], eax
[0x140001020]> CCa 0x140001020 0x140018a38 = myGlobal
[0x140001020]> pd 1
(fcn) fcn.140001020 20
   fcn.140001020 ();
           ; XREFS: CALL 0x140001080  CALL 0x140001098  CALL 0x1400010b0  CALL 0
           ; XREFS: CALL 0x140001794  CALL 0x1400017ad  CALL 
           0x140001029      mov dword [0x140018a38], eax ; 0x140001029 = myGlobal
[0x140001020]> Cf 2 w myGlobal @ 0x140018a38
[0x140001020]> pd 1 @ 0x140018a38
            0x140018a38 format w myGlobal {
 myGlobal : 0x140018a38 = 0xffff
} 2
[0x140001020]> q
user@host:~$ 
相关问题