├── Makefile ├── README.md ├── rosetta.c └── setup.sh /Makefile: -------------------------------------------------------------------------------- 1 | default: all 2 | 3 | all: powerpc arm aarch64 4 | 5 | powerpc: 6 | powerpc-linux-gnu-gcc -o ppc rosetta.c -static 7 | powerpc-linux-gnu-objdump -d -Mintel ./ppc > ppc-dump 8 | 9 | arm: 10 | arm-linux-gnueabi-gcc -o arm rosetta.c -static 11 | arm-linux-gnueabi-objdump -d -Mintel ./arm > arm-dump 12 | 13 | aarch64: 14 | aarch64-linux-gnu-gcc -o aarch64 rosetta.c -static 15 | aarch64-linux-gnu-objdump -d -Mintel ./aarch64 > aarch64-dump 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The ASM Rosetta Stone 2 | This respository contains the ASM Rosetta Stone, a small snippet of C 3 | that you can use to learn a new assembly variant in a short amount of 4 | time. 5 | 6 | ## Getting Started 7 | To get started with studying assembly languages using Rosetta Stone, follow these steps: 8 | 9 | 1. **Clone the repository**: Open a terminal and run the following command to clone the repository to your local machine: 10 | 11 | ``` 12 | git clone https://github.com/lowlevellearning/rosetta-stone.git 13 | ``` 14 | 2. **Install necessary packages**: Install the necessary packages on your system by running the following command: 15 | ``` 16 | ./setup.sh 17 | ``` 18 | 3. **Makefile usage**: You can use the Makefile to compile the rosetta.c file into executables for different architectures. Run the following command to compile the code for all supported architectures (powerpc, arm, aarch64): 19 | ``` 20 | make all 21 | ``` 22 | Alternatively, you can compile the code for individual architectures using the respective target names: 23 | * **PowerPC:** 24 | ``` 25 | make powerpc 26 | ``` 27 | * **ARM** 28 | ``` 29 | make arm 30 | ``` 31 | * **AArch64** 32 | ``` 33 | make aarch64 34 | ``` 35 | The compiled executables will be named ppc (for powerpc), arm (for arm), and aarch64 (for aarch64). 36 | 37 | ## Checklist 38 | - registers 39 | - names [] 40 | - width [] 41 | - stack memory 42 | - how is it used [] 43 | - prolouge, epilouge [] 44 | - calling conventions 45 | - arguments [] 46 | - return value [] 47 | - return address [] 48 | - control flow 49 | - branching [] 50 | - conditional branches[] 51 | - calls [] 52 | - syscall interface [] 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /rosetta.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // calling conventions 6 | int returny_func(int *a, char b, short c, int d) 7 | { 8 | // return value 9 | return b+c; 10 | } 11 | 12 | int main(int argc, char **argv) 13 | { 14 | // 64-bit 15 | long long mylong = 0xbabecafef00dface; 16 | 17 | // 32-bit 18 | int myint = 0xdeadf00d; 19 | 20 | // string operations 21 | char str[] = "mystr"; 22 | 23 | // canary value 24 | int i = 1337; 25 | 26 | // control flow 27 | while (i) 28 | { 29 | i--; 30 | } 31 | 32 | int ret = returny_func(&i, 0x42, 0x69, 0x31337); 33 | 34 | // syscall interface 35 | syscall(SYS_write, 1, "done:)\n", 7); 36 | 37 | return 32; 38 | } 39 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sudo apt install gcc-aarch64-linux-gnu gcc-arm-linux-gnueabi gcc-powerpc-linux-gnu 4 | --------------------------------------------------------------------------------