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 mov_immediate_data_between_memory_and_registers.md
Abdul Wahab Junaidc31430017066
diff --git a/Reverse Engineering/Malware Data/Malware/mov_immediate_data_between_memory_and_registers.md b/Reverse Engineering/Malware Data/Malware/mov_immediate_data_between_memory_and_registers.mdnew file mode 100644index 0000000..80fc53e--- /dev/null+++ b/Reverse Engineering/Malware Data/Malware/mov_immediate_data_between_memory_and_registers.md@@ -0,0 +1,119 @@+### **Commented and Explained Code**+```asm+section .data ; Define the data section for initialized variables+ constant:+ .int 10 ; Define a constant integer with value 10++section .text ; Define the text (code) section+ global _start ; Make the `_start` label globally accessible (entry point)++_start:+ nop ; No-operation instruction (does nothing, often used as a placeholder)++mov_immediate_data_between_memory_and_registers:+ movl constant, %ecx ; Load the value at the memory address `constant` into the ECX register++exit:+ movl $1, %eax ; System call number for `exit` (Linux syscall 1)+ movl $0, %ebx ; Exit code 0 (successful termination)+ int $0x80 ; Trigger the system call interrupt+```++---++### **Explanation**++1. **Section Definitions:**+ - **`.section .data`:**+ - This section is used for defining initialized data or constants.+ - The `constant:` label is defined here and points to an integer value `10`.+ - **`.section .text`:**+ - This section is for the executable code of the program.++2. **Global Directive:**+ - **`global _start`:**+ - Marks `_start` as the program's entry point, so the linker knows where to begin execution.++3. **NOP Instruction:**+ - **`nop`:**+ - Does nothing but consumes one CPU cycle. It's often used for debugging or instruction alignment.++4. **Memory-to-Register Move:**+ - **`movl constant, %ecx`:**+ - `movl` transfers a 32-bit value from memory (the location labeled `constant`) into the `ECX` register.+ - `constant` refers to the address of the value in the `.data` section, which holds `10`.++5. **Exit System Call:**+ - **`movl $1, %eax`:**+ - Sets up the system call for program termination (`exit` system call).+ - **`movl $0, %ebx`:**+ - Sets the exit status to `0`, indicating successful program completion.+ - **`int $0x80`:**+ - Triggers a software interrupt to invoke the kernel and execute the `exit` system call.++---++### **Steps to Assemble and Link**++1. **Assemble the Code:**+ ```bash+ nasm -f elf32 -o mov_memory_register.o mov_memory_register.asm+ ```++2. **Link the Object File:**+ ```bash+ ld -m elf_i386 -o mov_memory_register mov_memory_register.o+ ```++3. **Run the Program:**+ ```bash+ ./mov_memory_register+ ```++---++### **Testing with GDB**++To observe how the data is moved and inspect the registers:++1. **Start GDB:**+ ```bash+ gdb -q mov_memory_register+ ```++2. **Set Breakpoints:**+ ```bash+ b mov_immediate_data_between_memory_and_registers+ ```++3. **Run and Step Through:**+ ```bash+ r # Run the program+ si # Step through each instruction+ ```++4. **Inspect Registers:**+ - After `movl constant, %ecx`:+ ```bash+ i r ecx+ ```+ This should show `ECX = 0xA`, where `0xA` is the hexadecimal representation of `10`.++5. **Inspect Memory:**+ ```bash+ x/1xw &constant+ ```+ This will display the memory content at the address of `constant`, confirming it holds the value `10`.++---++### **Key Concepts in This Code**+1. **Memory-to-Register Operations:**+ The `movl` instruction demonstrates moving data from a memory location to a register.++2. **Linux System Calls:**+ The program uses the Linux `int $0x80` interface to terminate cleanly.++3. **Data Section:**+ The `.data` section is used to define constants or initialized variables that are accessible during program execution.+