radare2/test/new/db/cmd/cmd_project
2020-03-08 19:56:34 -05:00

442 lines
6.7 KiB
Plaintext

NAME=Import project
FILE=malloc://512
CMDS=<<EOF
e dir.projects = ../bins/other/projects
Po test > /dev/null
C*
EOF
EXPECT=<<EOF
CCu base64:U29tZSB0ZXN0 @ 0x00404890
EOF
RUN
NAME=Import project with overwriting
FILE=malloc://512
CMDS=<<EOF
e asm.bits=64
e asm.arch = x86
e anal.arch = x86
e dir.projects = ../bin/
CC Some test @ 0x00404890
Po import2 > /dev/null
CC*
EOF
EXPECT=<<EOF
CCu base64:U29tZSB0ZXN0 @ 0x00404890
EOF
RUN
NAME=Import project with overwriting
FILE=malloc://512
CMDS=<<EOF
t-*
e asm.arch = x86
e anal.arch = x86
e dir.projects = .tmp/
e asm.bits=64
wx 31ed4989d15e4889e24883e4f0505449c7c09024410048c7c12024410048c7c7a0284000e857dcfffff4
af test
afF @ test
pdf
Ps testw > /dev/null
Pc testw~afF
rm .tmp/testw
EOF
EXPECT=<<EOF
/ (fcn) test
\ 0x00000000 (42 byte folded function)
afF @ 0x00000000
EOF
RUN
NAME=Export project
FILE=malloc://512
CMDS=<<EOF
e dir.projects = .tmp/
CC "Some other test" @ 0x00404890
Ps testexp > /dev/null
cat .tmp/testexp/rc | grep base64
rmdir -p .tmp/testexp
EOF
EXPECT=<<EOF
"e bin.debase64 = false"
CCu base64:IlNvbWUgb3RoZXIgdGVzdCI= @ 0x00404890
EOF
RUN
NAME=Set, export, unset and import
FILE=malloc://512
CMDS=<<EOF
e dir.projects = .tmp/
t-*
CC "First comment" @ 0x00404890
CC "Second comment" @ 0x00404800
Ps testset > /dev/null
C- @ 0x00404890
C- @ 0x00404800
Po project.r2
cat .tmp/testset/rc | grep CC
rmdir -p .tmp/testset
EOF
EXPECT=<<EOF
CCu base64:IlNlY29uZCBjb21tZW50Ig== @ 0x00404800
CCu base64:IkZpcnN0IGNvbW1lbnQi @ 0x00404890
EOF
RUN
NAME=xrefs
FILE=malloc://512
CMDS=<<EOF
ax 1
e dir.projects = .tmp/
axq
Ps xrefs > /dev/null
axq
EOF
EXPECT=<<EOF
0x00000000 -> 0x00000001 UNKNOWN
0x00000000 -> 0x00000001 UNKNOWN
EOF
RUN
NAME=Import mapped project
FILE=malloc://512
CMDS=<<EOF
e dir.projects = ../bins/other/projects/
Po resetc64 > /dev/null
pu 3 @0xc000
EOF
EXPECT=<<EOF
%4c%e2%fc
EOF
RUN
NAME=asm.emu in project
FILE=../bins/elf/analysis/simpleARM.elf
CMDS=<<EOF
e asm.flags = false
e asm.emu = true
e dir.projects = .tmp/
Ps emu > /dev/null
Po emu
CC-
om `o~[0]` 0
pd 1
rm .tmp/emu
EOF
EXPECT=<<EOF
0x08000060 0d20a0e3 mov r2, 0xd ; r2=0xd -> 0x2000000
EOF
RUN
NAME=Variables in project file
FILE=../bins/efi/bootia32.efi
CMDS=<<EOF
e dir.projects = .tmp/
af
afvr edi blahblah typeR @ 0x10002d8d
afvb 8 ImageHandle blah @ 0x10002d8d
Ps var > /dev/null
Pc var~ImageHandle
Pc var~blahblah
rm .tmp/var
EOF
EXPECT=<<EOF
afvb 8 ImageHandle blah @ 0x10002d8d
afvr edi blahblah typeR @ 0x10002d8d
EOF
RUN
NAME=Types and link in project file
FILE=-
CMDS=<<EOF
e dir.projects = .tmp/
tk zoby = type
tl char @ 0x0
Ps types > /dev/null
Pc types~?link.,symlink,unlink
Pc types~?zoby
EOF
EXPECT=<<EOF
10
1
EOF
RUN
NAME=Breakpoints in project file
FILE=../bins/elf/analysis/main
BROKEN=1
CMDS=<<EOF
e dbg.bpinmaps = false
e dir.projects = .tmp/
db 0x1234567
Ps breakpoints > /dev/null
Pc breakpoints~?0x1234567
EOF
EXPECT=<<EOF
1
EOF
RUN
NAME=Visual Marks in project file
FILE=../bins/elf/analysis/main
CMDS=<<EOF
fV 49 0x400410
fV 50 0x400412
Ps vmarks > /dev/null
Pc vmarks~fV
Pd vmarks > /dev/null
EOF
EXPECT=<<EOF
fV 49 0x400410
fV 50 0x400412
EOF
RUN
NAME=Custom types in project file
BROKEN=1
FILE=../bins/elf/analysis/main
CMDS=<<EOF
tk char **=type
tk type.char **=**z
tk type.char **.size=64
Ps custom_types > /dev/null
Pc custom_types~?char **
"td struct Foo { int bar; int x; int y; };"
Ps custom_types > /dev/null
Pc custom_types~?char **
Pc custom_types~?Foo
Pd custom_types > /dev/null
EOF
EXPECT=<<EOF
9
9
8
EOF
RUN
NAME=Export custom types and import again
FILE=../bins/elf/analysis/main
BROKEN=1
CMDS=<<EOF
tk char **=type
tk type.char **=**z
tk type.char **.size=64
"td struct Foo { int bar; int x; int y; };"
Ps custom_types > /dev/null
t- char **
t- Foo
tk~?char **
tk~?Foo
Po custom_types > /dev/null
tk~?char **
tk~?Foo
Pd custom_types > /dev/null
EOF
EXPECT=<<EOF
5
0
7
5
EOF
RUN
NAME=Save project for a binary and checking opened files
FILE=../bins/elf/analysis/main
BROKEN=1
CMDS=<<EOF
e dir.projects = .tmp/
Ps ulumulu > /dev/null
Po ulumulu > /dev/null
o*~?
EOF
EXPECT=<<EOF
1
EOF
RUN
NAME=Save project for a binary without saving its info
FILE=../bins/elf/analysis/main
ARGS=-n
CMDS=<<EOF
e dir.projects = .tmp/
Ps blub > /dev/null
Po blub > /dev/null
i~format
EOF
EXPECT=<<EOF
EOF
RUN
NAME=Save project for a binary after analysis
FILE=../bins/elf/analysis/main
CMDS=<<EOF
e dir.projects = .tmp/
aaa
Ps beer
# Following command hangs:
# Po beer
y
EOF
EXPECT=<<EOF
beer
EOF
RUN
NAME=Save project for a binary without saving its info at a specific map offset
FILE=../bins/elf/analysis/main
ARGS=-n -m 0x1337
CMDS=<<EOF
e dir.projects = .tmp/
Ps hand > /dev/null
Po hand > /dev/null
om*~?
om*~[2]
EOF
EXPECT=<<EOF
1
0x00001337
EOF
RUN
NAME=Delete a saved project (with Pd)
FILE=../bins/elf/analysis/main
ARGS=-n
CMDS=<<EOF
e dir.projects = .tmp/
Ps cannot > /dev/null
Pd cannot > /dev/null
Pl~cannot
EOF
EXPECT=<<EOF
EOF
RUN
NAME=Delete a saved project (with P-)
FILE=../bins/elf/analysis/main
ARGS=-n
CMDS=<<EOF
e dir.projects = .tmp/
Ps erase > /dev/null
P- erase > /dev/null
Pl~erase
EOF
EXPECT=<<EOF
EOF
RUN
NAME=Delete a saved project and used directory (with Pd)
FILE=../bins/elf/analysis/main
ARGS=-n
CMDS=<<EOF
e dir.projects = .tmp/
Ps anesthetize > /dev/null
Pd anesthetize > /dev/null
Pl~blah
ls -l `e dir.projects`~anesthetize
EOF
EXPECT=<<EOF
EOF
RUN
NAME=Delete a saved project and used directory (with P-)
FILE=../bins/elf/analysis/main
BROKEN=1
ARGS=-n
CMDS=<<EOF
e dir.projects = .tmp/
Ps lightbulb > /dev/null
P- lightbulb > /dev/null
Pl~lightbulb
ls -l `e dir.projects`~lightbulb
EOF
EXPECT=<<EOF
-drwxr-xr-x 1 501:20 96 .tmp/lightbulb/
EOF
RUN
NAME=Save project for a file with asm.bits=32 and check the value after loading again
FILE=../bins/src/hello.c
ARGS=
CMDS=<<EOF
e dir.projects = .tmp/
e asm.bits=16
Ps sun > /dev/null
Po sun > /dev/null
e asm.bits
EOF
EXPECT=<<EOF
16
EOF
RUN
NAME=prj.name saved in project
FILE=malloc://512
CMDS=<<EOF
e dir.projects = .tmp/
Ps named_prj > /dev/null
e prj.name=
Po named_prj > /dev/null
e prj.name
rm .tmp/named_prj
EOF
EXPECT=<<EOF
named_prj
EOF
RUN
NAME=Checking e prj.name after saving again
FILE=../bins/elf/analysis/main
CMDS=<<EOF
e dir.projects = .tmp/
Ps stupid > /dev/null
Po stupid > /dev/null
Ps stupid > /dev/null
Po stupid > /dev/null
e prj.name
EOF
EXPECT=<<EOF
stupid
EOF
RUN
NAME=Restoring xrefs
FILE=malloc://512
CMDS=<<EOF
e asm.arch = x86
e anal.arch = x86
e asm.bits=32
e dir.projects = .tmp/
wx 5031c0e801000000c3b801000000c3
af
Ps dream > /dev/null
Po dream > /dev/null
axq
EOF
EXPECT=<<EOF
0x00000003 -> 0x00000009 CALL
EOF
RUN
NAME=Reopening projects bin info loading
FILE=../bins/elf/analysis/main
BROKEN=1
CMDS=<<EOF
e dir.projects = .tmp/
Ps bininfo > /dev/null
Po bininfo
i~?
ie~?
ii~?
EOF
EXPECT=<<EOF
37
3
5
EOF
RUN