section .text
global _start
_start:
mov edx, len
mov ecx, msg
mov ebx, 1
mov eax, 4
int 0x80
mov eax, 1
int 0x80
section .data
msg db "Hello World!"
len equ $ - msg
Execute these commands to
compile, link, and run the
program:
nasm -f elf32 hello.asm
ld -m elf_i386 -o hello hello.o
./hello
The program runs,
as shown below.
gdb -q hello
The Gnu debugger opens, as shown below.
Execute this command to disassemble the code from the _start location:
disassemble _start
Notice the third command,
outlined in green in the image below.
The command we entered in the hello.asm source code was:
mov ebx, 1
However, the arguments are reversed
in the debugger.
set disassembly-flavor intel
disassemble _start
Now the code resembles the
source code more closely,
as shown below.
Compare that output to the assembly code you wrote and notice these things:
break * _start + 10
break * _start + 15
run
info registers
The program runs to the first breakpoint,
just
before the "mov ebx, 0x1" command,
and displays the registers,
as shown below.
Notice these things:
In gdb, execute these commands:
continue
info registers
The program runs to the second breakpoint,
just
after the "mov ebx, 0x1" command,
and displays the registers,
as shown below.
Now ebx contains 0x1.
info proc mappings
The memory segments used by the
program are listed,
as shown below.
ASM 110.1: Data (5 pts)
In gdb, execute this command:The flag is covered by a green rectangle in the image below.
x/4x ($ecx)
After getting the flag, execute these commands to exit gdb:
q y
ASM 110.2: Extra Command (10 pts)
In the shell, execute these commands:The program prints out a lot of extra garbage after the desired "Hello, World!" message, as shown below.
sudo apt update sudo apt install wget -y wget https://samsclass.info/127/proj/ASM110-2 chmod +x ASM110-2 ./ASM110-2
There is one extra line of assembly code in the program causing that problem. Find the extra line. Submit that entire line as the flag.
ASM 110.3: Crash (15 pts extra)
In the shell, execute these commands:The program crashes with a "Segmentation fault" error.
wget https://samsclass.info/127/proj/ASM110-3 chmod +x ASM110-3 ./ASM110-3Find the command that caused the crash. That command, in Intel format, is the flag.