radare2/test/db/cmd/cmd_search_hit
2021-08-03 15:14:47 +02:00

357 lines
5.0 KiB
Plaintext

NAME=cmd.hit sugar for /x
FILE=malloc://1024
CMDS=<<EOF
wx 90 @ 10
e cmd.hit=wx 91
/x 90
p8 1 @ 10
EOF
EXPECT=<<EOF
0x0000000a hit0_0 90
91
EOF
RUN
NAME=cmd.hit sugar for /j
FILE=malloc://1024
CMDS=<<EOF
w hello @ 10
psz @@/j hello
EOF
EXPECT=<<EOF
hello
[{"offset":10,"type":"string","data":"hello"}]
EOF
RUN
NAME=/xj utf16
FILE=malloc://1024
CMDS=<<EOF
wx 005c
/xj 005c
EOF
EXPECT=<<EOF
[{"offset":0,"type":"hexpair","data":"005c"}]
EOF
RUN
NAME=/j utf16
FILE=malloc://1024
CMDS=<<EOF
wx 0067
/j g
EOF
EXPECT=<<EOF
[{"offset":1,"type":"string","data":"g"}]
EOF
RUN
NAME=cmd.hit sugar for /x
FILE=malloc://1024
CMDS=<<EOF
wx 90 @ 10
wx 91 @@/x 90
p8 1 @ 10
EOF
EXPECT=<<EOF
0x0000000a hit0_0 90
91
EOF
RUN
NAME=cmd.hit sugar for /
FILE=malloc://1024
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
w A @ 10
wx 33 @@/ A
p8 1 @ 10
EOF
EXPECT=<<EOF
0x0000000a hit0_0 "A"
33
EOF
RUN
NAME=cmd.hit sugar for /
FILE=malloc://1024
CMDS=<<EOF
e asm.arch=x86
e asm.bits=32
wx 90 @ 10
wx 33 @@/adq nop
p8 1 @ 10
EOF
EXPECT=<<EOF
0x0000000a # 1: nop
33
EOF
RUN
NAME=cmd.hit for /!x
FILE=malloc://1024
CMDS=<<EOF
e cmd.hit = p8 1
wx 90 @ 10
/!x 00
EOF
EXPECT=<<EOF
0x0000000a hit0_0 90
90
EOF
RUN
NAME=cmd.hit for /!
FILE=malloc://1024
CMDS=<<EOF
e cmd.hit = p8 1
w AAAAAAAAAAB
/! A
EOF
EXPECT=<<EOF
0x0000000a hit0_0 "AAAAAAAAAAB"
42
EOF
RUN
NAME=cmd.hit for /+
FILE=malloc://1024
CMDS=<<EOF
e cmd.hit = p8 3
w ABCDEF
/+ ABC
EOF
EXPECT=<<EOF
0x00000000 hit0_0 414243
414243
EOF
RUN
NAME=cmd.hit for //
FILE=malloc://1024
CMDS=<<EOF
e cmd.hit = p8 1
w AAAAAAAAAAB
/! A
//
EOF
EXPECT=<<EOF
0x0000000a hit0_0 "AAAAAAAAAAB"
42
0x0000000a hit1_0 "AAAAAAAAAAB"
42
EOF
RUN
NAME=cmd.hit for /d multiple
FILE=malloc://1024
CMDS=<<EOF
s 0x117
wx 999a9b9d
s 0x201
wx a3a4a5a7
s 0
/d 010102
EOF
EXPECT=<<EOF
0x00000117 hit0_0 999a9b9d
0x00000201 hit0_1 a3a4a5a7
EOF
RUN
NAME=cmd.hit for /a
FILE=malloc://1024
CMDS=<<EOF
e asm.arch=x86
e asm.bits=32
e cmd.hit=pi 4
"wa add esp,8;pop ebx; pop ebp; ret"
/a add esp, 8
EOF
EXPECT=<<EOF
0x00000000 hit0_0 83c408
add esp, 8
pop ebx
pop ebp
ret
EOF
RUN
NAME=cmd.hit for /A
FILE=malloc://1024
CMDS=<<EOF
e asm.arch = x86
e anal.arch = x86
e cmd.hit = pi 1
e asm.bits=32
"wa add esp,8;pop ebx; pop ebp; ret"
/at pop
EOF
EXPECT=<<EOF
0x00000003 1 pop ebx
pop ebx
0x00000004 1 pop ebp
pop ebp
EOF
RUN
NAME=cmd.hit for /bx
FILE=malloc://1024
CMDS=<<EOF
e cmd.hit = p8 4
w ABCD @ 0x100
e search.from = 0x100
e search.to = 0x104
b 0x100
/bx 41424344
EOF
EXPECT=<<EOF
0x00000100 hit0_0 41424344
41424344
EOF
RUN
NAME=cmd.hit for /B
FILE=malloc://1024
CMDS=<<EOF
wx cffa edfe
e cmd.hit = px 1
e search.from = 0
e search.to = 0x10
/mb
EOF
EXPECT=<<EOF
0x00000000 mach064
EOF
RUN
NAME=cmd.hit for /i
FILE=malloc://1024
CMDS=<<EOF
e cmd.hit = ps
e search.from = 0
e search.to = 0x10
w AAAAAAAAAAB
/i aaaaaaaaaab
EOF
EXPECT=<<EOF
0x00000000 hit0_0 "AAAAAAAAAAB"
AAAAAAAAAAB
EOF
RUN
NAME=cmd.hit for /r
FILE=bins/elf/analysis/ls-linux64
CMDS=<<EOF
e cmd.hit = pi 1
e search.from = 0x00005c20
e search.to = 0x00005c49
/r sym.imp.__libc_start_main
EOF
EXPECT=<<EOF
(nofunc) 0x5c44 [CALL] call sym.imp.__libc_start_main
call sym.imp.__libc_start_main
EOF
RUN
NAME=from/to for /r
FILE=bins/elf/analysis/ls-linux64
CMDS=<<EOF
e cmd.hit = pi 1
e search.from = 0x00005c20
e search.to = 0x00005c44
/r sym.imp.__cxa_finalize
EOF
EXPECT=<<EOF
EOF
RUN
NAME=/ru search for possible UDS tables
FILE=bins/elf/analysis/ls-linux64
ARGS=-n
CMDS=<<EOF
/ruj
EOF
EXPECT=<<EOF
[{"addr":102769,"score":7,"stride":20},{"addr":11772,"score":6,"stride":24},{"addr":14055,"score":6,"stride":32},{"addr":14151,"score":6,"stride":16},{"addr":87675,"score":6,"stride":32},{"addr":87751,"score":6,"stride":18},{"addr":87771,"score":6,"stride":16},{"addr":87787,"score":6,"stride":10},{"addr":87797,"score":6,"stride":8},{"addr":87813,"score":6,"stride":14},{"addr":87848,"score":6,"stride":12},{"addr":87916,"score":6,"stride":24},{"addr":102745,"score":6,"stride":32},{"addr":102749,"score":6,"stride":28},{"addr":102757,"score":6,"stride":28},{"addr":102789,"score":6,"stride":20},{"addr":11316,"score":5,"stride":24},{"addr":11796,"score":5,"stride":24},{"addr":13847,"score":5,"stride":16},{"addr":14087,"score":5,"stride":32}]
EOF
RUN
NAME=cmd.hit for /s
FILE=bins/elf/analysis/x86-simple
CMDS=<<EOF
aeim
aeip
e cmd.hit = pi 1
/as
EOF
EXPECT=<<EOF
0x08048070 exit
int 0x80
EOF
RUN
NAME=from/to /v
FILE=-
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
wx 01
e cmd.hit = pi 1
e search.in =raw
e search.from = 0x00000000
e search.to = 0x00000004
/v1 1
EOF
EXPECT=<<EOF
0x00000000 hit0_0 01
add dword [rax], eax
EOF
RUN
NAME=from/to /v not in range
FILE=-
CMDS=<<EOF
wx 01
e cmd.hit = pi 1
e search.in =raw
e search.from = 0x00000000
e search.to = 0x00000000
/v1 1
EOF
EXPECT=<<EOF
EOF
RUN
NAME=from/to /V
FILE=-
BROKEN=1
CMDS=<<EOF
wx 05
e cmd.hit = pi 1
e search.in =raw
e search.from = 0x00000000
e search.to = 0x00000004
/V1 1 5
EOF
EXPECT=<<EOF
0x00000000 hit0_0 05
add dword [rax], eax
EOF
RUN
NAME=from/to /V not in range
FILE=-
CMDS=<<EOF
wx 05
e cmd.hit = pi 1
e search.in =raw
e search.from = 0x00000000
e search.to = 0x00000000
/V1 1 5
EOF
EXPECT=<<EOF
EOF
RUN