This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.
JavaScript algorithmsartificial-intelligencebugbountycryptographycyber-threat-intelligencecybersecurity-projectsethical-hackinghacking-toolsmalwarenessusnetwork-monitoringnetwork-securitynmapportscannerpythonpythonprojectsthreat-intelligencevirus-scanning
Create Link Register (LR, r14) in ARM32.md
Abdul Wahab Junaid52dc5397d2a0
diff --git a/Reverse Engineering/Malware Data/Malware/Link Register (LR, r14) in ARM32.md b/Reverse Engineering/Malware Data/Malware/Link Register (LR, r14) in ARM32.mdnew file mode 100644index 0000000..0ecdcaa--- /dev/null+++ b/Reverse Engineering/Malware Data/Malware/Link Register (LR, r14) in ARM32.md@@ -0,0 +1,105 @@+++### ARM32 Code++```assembly+.global _start++_start:+ mov r7, #0x30 @ Move hex 30 into r7+ b no_return @ Branch to no_return function++no_return:+ mov r7, #1 @ Move decimal 1 into r7+ bl my_function @ Call my_function; return address is stored in LR (r14)+ @ After execution, it will return to wrap_up++wrap_up:+ mov r7, #0x12 @ Move hex 12 into r7+ b exit @ Branch to exit++my_function:+ mov r0, #10 @ Move decimal 10 into r0+ bx lr @ Return to the address stored in LR (r14)+ @ This will return to wrap_up++exit:+ mov r7, #1 @ syscall: exit (1 is the syscall number for exit on ARM32)+ mov r0, #0 @ Exit code 0+ svc 0 @ Make the system call+```++---++### Explanation of the Code++1. **`_start`**:+ - This is the entry point of the program.+ - The program moves the value `0x30` into register `r7`.+ - It then branches to the `no_return` function.++2. **`no_return`**:+ - The program moves the value `1` into register `r7`.+ - The `bl my_function` instruction calls the `my_function` function. The return address (address of the next instruction) is stored in the Link Register (`LR`, which is `r14` in ARM32).++3. **`wrap_up`**:+ - After returning from `my_function`, the program moves the value `0x12` into register `r7`.+ - It then branches to the `exit` label.++4. **`my_function`**:+ - The function moves the value `10` into register `r0`.+ - The `bx lr` instruction returns to the address stored in the Link Register (`LR`, `r14`), which is the address of the instruction after the `bl` in `no_return`.++5. **`exit`**:+ - The program sets up the exit syscall by moving `1` (syscall number for exit) into `r7` and `0` (exit code) into `r0`.+ - The `svc 0` instruction makes the system call to exit the program.++---++### Compiling and Running the Code++1. **Save the code**:+ - Save the code in a file named `lr_demo_arm32.s`.++2. **Compile the code**:+ - Use the `arm-linux-gnueabi-as` assembler to assemble the code and `arm-linux-gnueabi-ld` to link it.+ ```bash+ arm-linux-gnueabi-as -o lr_demo_arm32.o lr_demo_arm32.s+ arm-linux-gnueabi-ld -o lr_demo_arm32 lr_demo_arm32.o+ ```++3. **Run the code**:+ - If you have an ARM32 environment (e.g., using QEMU), you can run the executable.+ ```bash+ qemu-arm ./lr_demo_arm32+ ```++4. **Debug with GDB**:+ - To debug the program using GDB, you can use `arm-linux-gnueabi-gdb`.+ ```bash+ arm-linux-gnueabi-gdb ./lr_demo_arm32+ ```+ - In GDB, you can set breakpoints, step through the code, and inspect registers.+ ```gdb+ (gdb) break _start+ (gdb) run+ (gdb) stepi+ (gdb) info registers+ ```++---++### Key Differences Between ARM32 and ARM64++1. **Registers**:+ - In ARM32, the Link Register is `r14` (LR), whereas in ARM64, it is `x30`.+ - ARM32 uses `r0-r12` for general-purpose registers, while ARM64 uses `x0-x30`.++2. **Return Instruction**:+ - In ARM32, `bx lr` is used to return from a function, whereas in ARM64, `ret` is used.++3. **Syscall Numbers**:+ - The syscall numbers differ between ARM32 and ARM64. For example, the exit syscall is `1` in ARM32 and `93` in ARM64.++---+