Execute these commands to compile, link, and run the program:
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
The program runs, as shown below.
nasm -f elf32 hello.asm ld -m elf_i386 -o hello hello.o ./hello
The Gnu debugger opens, as shown below.
gdb -q hello
Execute this command to disassemble the code from the _start location:
Notice the third command, outlined in green in the image below.
The command we entered in the hello.asm source code was:
However, the arguments are reversed in the debugger.
mov ebx, 1
Now the code resembles the source code more closely, as shown below.
set disassembly-flavor intel disassemble _start
Compare that output to the assembly code you wrote and notice these things:
The program runs to the first breakpoint, just before the "mov ebx, 0x1" command, and displays the registers, as shown below.
break * _start + 10 break * _start + 15 run info registers
Notice these things:
In gdb, execute these commands:
The program runs to the second breakpoint, just after the "mov ebx, 0x1" command, and displays the registers, as shown below.
continue info registers
Now ebx contains 0x1.
The memory segments used by the program are listed, as shown below.
info proc mappings
ASM 110.1: Data (5 pts)In gdb, execute this command:The flag is covered by a green rectangle in the image below.
After getting the flag, execute these commands to exit gdb:
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)In the shell, execute these commands:The program crashes with a "Segmetation fault" error.
wget https://samsclass.info/127/proj/ASM110-3 chmod +x ASM110-3 ./ASM110-3
Find the command that caused the crash. That command, in Intel format, is the flag.