Execute these commands to compile, link, and run the program, and see the results:
section .text global _start _start: mov eax, 8 ; 8 = sys_creat mov ebx, filename mov ecx, 700o ; Permissions: 700 octal (rwx------) int 0x80 mov [fd], eax ; file descriptor mov eax, 4 ; 4 = sys_write mov ebx, [fd] mov ecx, msg mov edx, len int 0x80 mov eax, 6 ; 6 = sys_close mov ebx, [fd] int 0x80 mov eax, 1 ; 1 = sys_exit int 0x80 section .data filename db "write.txt", 0 msg db "Hello World!" len equ $ - msg fd db 0, 0, 0, 0
The program runs, creating a "write.txt" file, as shown below.
nasm -f elf32 write.asm ld -m elf_i386 -o write write.o ./write ls -l w* cat write.txt
ASM 120.1: File Length (5 pts)In the shell, execute these commands:Write a program that reads every byte in that file and counts them. The flag is the length of the file in hexadecimal.
sudo apt update sudo apt install wget -y wget https://samsclass.info/127/proj/ASM120
ASM 120.2: Skip Bytes (10 pts)Use the same ASM120 file.
Skip the first 230 bytes. Print out the next six bytes to see the flag.
ASM 120.3: Third N (10 pts)Use the same ASM120 file.
Find the third capital N. Read five more letters to complete the flag.
ASM 120.4: Fifth (10 pts)Use the same ASM120 file.
Print every fifth character to see the flag.
ASM 120.5: Nth (20 pts)Use the same ASM120 file.
Gather every Nth character to see the flag. You don't know Nn.