We will be looking at shellcode in this lab.

Please reference the AMD64 ABI Linux Syscall Table

 

Demo

In lab 3, your tutor will work through the runner 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: write a program to do the following

  • Open a file called flag.txt
  • Copy the first 20 bytes of the file onto a buffer on the stack
  • Print the contents of the file to stdout
  • Close the file
  • 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!