Skip to content

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.

Create Converting between Intel and AT&T syntax.md

Abdul Wahab Junaid64ff320243cf
diff --git a/Reverse Engineering/Malware Data/Malware/Converting between Intel and AT&T syntax.md b/Reverse Engineering/Malware Data/Malware/Converting between Intel and AT&T syntax.md
new file mode 100644
index 0000000..26228cd
--- /dev/null
+++ b/Reverse Engineering/Malware Data/Malware/Converting between Intel and AT&T syntax.md
@@ -0,0 +1,103 @@
+Converting between Intel and AT&T syntax involves understanding their differences and translating instructions accordingly. Here's a detailed guide to help you switch back and forth:
+
+---
+
+### **Key Differences Between Intel and AT&T Syntax**
+1. **Operand Order:**
+ - Intel: **Destination, Source** (e.g., `mov eax, ebx`)
+ - AT&T: **Source, Destination** (e.g., `movl %ebx, %eax`)
+
+2. **Operand Size:**
+ - Intel: Deduced from the operand/register size (e.g., `mov eax, 5`)
+ - AT&T: Explicitly specified with a suffix:
+ - `b` for byte (8-bit)
+ - `w` for word (16-bit)
+ - `l` for long (32-bit)
+ - `q` for quad (64-bit)
+
+3. **Registers:**
+ - Intel: Registers are written directly (e.g., `eax`, `ebx`)
+ - AT&T: Registers are prefixed with `%` (e.g., `%eax`, `%ebx`)
+
+4. **Immediate Values:**
+ - Intel: Immediate values are written as-is (e.g., `mov eax, 5`)
+ - AT&T: Immediate values are prefixed with `$` (e.g., `movl $5, %eax`)
+
+5. **Memory References:**
+ - Intel: `[base + index * scale + displacement]`
+ - AT&T: `displacement(base, index, scale)`
+
+---
+
+### **Example Translation**
+
+#### Intel to AT&T:
+Intel:
+```assembly
+mov eax, [ebx+4]
+add eax, 10
+```
+
+AT&T:
+```assembly
+movl 4(%ebx), %eax
+addl $10, %eax
+```
+
+---
+
+#### AT&T to Intel:
+AT&T:
+```assembly
+movl $10, %eax
+addl %ebx, %eax
+```
+
+Intel:
+```assembly
+mov eax, 10
+add eax, ebx
+```
+
+---
+
+### **Tools for Conversion**
+
+1. **Manual Conversion:**
+ Use the above rules to rewrite the instructions.
+
+2. **Assembler Options:**
+ - GNU `as` (GAS) defaults to AT&T but supports Intel syntax with the `.intel_syntax noprefix` directive.
+ - Example:
+ ```assembly
+ .intel_syntax noprefix
+ mov eax, ebx
+ ```
+
+3. **Disassemblers:**
+ Many disassemblers (like `objdump` or `gdb`) can switch between syntaxes:
+ - `objdump` with `--disassembler-options=intel` or `--disassembler-options=att`
+ - Example:
+ ```bash
+ objdump -d --disassembler-options=intel program
+ ```
+
+4. **Online Converters:**
+ Websites or tools can automate this, but understanding the syntax is essential for debugging or complex scenarios.
+
+---
+
+### **Practice Recommendations**
+
+1. **Experiment with Code:**
+ Write assembly in one syntax, assemble, and disassemble it in the other.
+
+2. **Use Compiler Flags:**
+ Generate assembly output from C/C++ code using `gcc`:
+ ```bash
+ gcc -S -masm=intel program.c -o program_intel.s
+ gcc -S -masm=att program.c -o program_att.s
+ ```
+
+3. **Analyze Examples:**
+ Practice with real-world examples to become proficient in conversion.