You will make a Pin tool that can make the Flappy Bird immortal. There are two 'game over' conditions:
The Flappy Bird hits the pipe
The Flappy Bird hits the ground
Basically, you will (1) find how the two conditions are detected and handled in the program and (2) modify the program execution so that the two conditions do not meet.
There are multiple ways to achieve.
DATA Modify values of registers/memory in instructions.
CODE Ignore/skip instructions/functions.
Pin supports APIs controlling function calls/returns without you going through the instructions.
All the details will be presented in the class. :)
What to submit?
(1) your pin tool's source code (e.g., code everything in the icount.cpp, and upload it). (2) a 1-page description as a pdf file (including how you locate the memory/variable and which code is added in the pin tool to modify values/code and so on).
After the compilation, you should see mine program and should be able to run it with arguments (if you don't provide any arguments, it will create a 5x5 minesweeper game by default).
$ ./mine
y 0 1 2 3 4
x
0 D D D D D
1 D D D D D
2 D D D D D
3 D D D D D
4 D D D D D
x y mode(o/f)>
$ ./mine 3 3
y 0 1 2
x
0 D D D
1 D D D
2 D D D
x y mode(o/f)>
...
Your task is to identify where are the mines by using your own Pin tool.
The goal of this homework is to experience how you would identify key memory locations/operations without knowing the source code (Note the without).
Hence, while you are given the source code, please try to not use them to solve this homework.
In other words, you should use the source code to understand how the game works, and what patterns of the operations you would expect, but do not use it to precisely pinpoint the memory locations/functions to call.
What to Submit
(1) your pin tool's source code (e.g., code everything in the icount.cpp, and upload it).
(2) a 1-page description as a pdf file (including how you locate the memory/variable and which code is added in the pin tool to modify values/code and so on).
What to be included in the report?
Identifying instructions setting/defining mines (was in the lecture)
Provide a step-by-step analysis identifying the instructions and getting the information from it.
Adding a small code dumping the information (to a file or screen).
Hints
The minesweeper program creates the mine-field with the given number of rows and columns.
You would expect that there should be a function initializes the field, writing values into the memory which represents the mine-field.
That is, if there is a 5x5 mine-field, there will be 25 memory writes to define the mines.
if it is a 6x6 mine-field, there will be 36 memory writes
if it is 7x7 mine-field, there will be 49 memory writes, and so on.
Typically, representing whether there exists a mine at a certain place would be handled by storing a boolean value, with a coordinate.
if there is a mine at (3, 4),
we may expect memory writes with values of 1, 3, and 4.
if there is no mine at (5, 6),
we may expect memory writes with values of 0, 5, and 6.
Note that this is just a guess, and there is no reason that the developer should use such values and store in such a way.
There are different types of memory: heap, stack, and global.
Stack memory is not persistent and only alive during the function execution.
Since the information of where the mines exist should be persistent throughout the execution, it is less likely to be on the stack memory.
Heap and Global are persistent.
If you use malloc, you are alloctating a heap memory. If you are using a global variable, it is on the global section of the memory. The mine-field information is likely to be stored in one of the two.
Homework 3. Running the Hidden Code
This homework is to introduce basic skills for the project 2. Please check out the project 2 for detailed motivation and context.
Assume that you obtain a potential malicious payload (e.g., from network logs), you would like to know what they are doing. Executing them on a real machine or VM is a viable option, but it will also harm the entire VM or machine if the exploitation is successful. Sandboxing is a technique that can run the program while preventing the target program making any harm to the host system. In practice, sandboxing is commonly used to execute potentially malicious code or program as it can observe malicious actions without harming the host system.
This homework asks you to create a sandboxing tool that execute them safely using code emulation techniques. Specifically, give a sequence of code bytes (i.e., instructions), you run them and report what actions they make (e.g., call a system call, doing a particular computations, etc.).
Handling Three Shellcodes
You are given the below shellcode examples. Your goal is to make your program properly interpret their executions (e.g., what system calls were made with which arguments):