We will be looking at Shellcodes the lab.

Please reference the AMD64 ABI Linux Syscall Table

 

Setup

Make sure you have all tooling installed.

 

Demo

In lab 3, your tutor will work through this challenge with you.

 

Prac

The prac challenge will utilise the same runner binary as above.

Challenge 1

Get the binary to print “HELLO WORLD!!!” using shellcode.

Challenge 2

Print a user entered string (from stdin) to stdout.

Challenge 3

  1. Open a file called flag.txt
  2. Copy the first 20 bytes of the file onto a buffer on the stack
  3. Print the contents of the file to stdout
  4. Close the file
  5. Exit cleanly (call exit())

Challenge 4

Transcribe the below code into assembly

int counter = 0
while(1):
    if (counter >= 10){ 
        printf("You win!\n"); 
        break; 
    } else {
        printf("%d\n",counter); 
        counter += 1; 
    }
}

With the expected output being:

0
1
2
3
4
5
6
7
8
9
You win!