Hello, fellows!
I hope that a linux assembly playground will be very helpful for you.
Make sure you have gef installed in your gdb, along with its suggested libraries, in specific "keystone".
Clone the repo:
git clone https://github.com/ThinerDAS/asm-playground.git
cd asm-playground
Then, type in shell:
gcc main.c -o main
and use gdb to open it:
gdb main
and inside gdb, type:
source play.py
play
Homework:
- Try out normal instructions like
mov
,add
, etc. You will need to become familiar with some debugging commands in gdb, includingstepi
(si
),continue
(c
),break
(b
), etc. - Try out instructions related to stack and
rip
, likepush
,pop
,jmp
,call
,ret
,leave
, etc. - Try a C function call. Find out the address of
printf
and callprintf("Hello, %dth challenger!\n", 100);
. Find the address ofmalloc
, allocate a memory,malloc(0x100);
, with assembly and put the memory address tordi
. - Try a syscall. Do
sys_read(0, rsp, 100)
to populate the stack, andsys_execve(rsp, 0, 0)
to execute your program. - Reread the programs we have compiled using
gcc
up to this time, and compile some more programs. Point out the calling convention inside the assembly.