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 indirect_addressing_with_registers.md

Abdul Wahab Junaid7f02f74bf9f2
diff --git a/Reverse Engineering/Malware Data/Malware/indirect_addressing_with_registers.md b/Reverse Engineering/Malware Data/Malware/indirect_addressing_with_registers.md
new file mode 100644
index 0000000..562e514
--- /dev/null
+++ b/Reverse Engineering/Malware Data/Malware/indirect_addressing_with_registers.md
@@ -0,0 +1,137 @@
+```asm
+section .data ; Data section for variables
+ constants: ; Define an array of integers
+ dd 5, 8, 17, 44, 50, 52, 60, 65, 70, 77, 80
+
+section .text ; Code section
+ global _start ; Entry point for the program
+
+_start:
+ nop ; Placeholder instruction
+
+indirect_addressing_with_registers:
+ mov edi, constants ; Load the base address of `constants` into EDI
+ mov eax, [edi] ; Load the first value (5) into EAX
+ mov ebx, [edi + 4] ; Load the second value (8) into EBX (4 bytes after EDI)
+
+ ; Modify the third element in the array (offset = 8 bytes)
+ mov dword [edi + 8], 25 ; Set the value at index 2 to 25
+
+ ; Demonstrate accessing with scaling (using `edi` as base with scaling)
+ mov ebx, [edi + 4*2] ; Load the third value (index 2) into EBX (17 or updated value 25)
+
+exit:
+ mov eax, 1 ; syscall: exit
+ mov ebx, 0 ; exit code 0
+ int 0x80 ; Trigger the system call interrupt
+```
+---
+ ```bash
+
+┌──(komugi㉿komugi)-[~/Desktop]
+└─$ nasm -f elf32 indirect.asm
+
+┌──(komugi㉿komugi)-[~/Desktop]
+└─$ ld -m elf_i386 -o indirect indirect.o
+
+┌──(komugi㉿komugi)-[~/Desktop]
+└─$ ./moving_immediate_data
+
+┌──(komugi㉿komugi)-[~/Desktop]
+└─$
+┌──(komugi㉿komugi)-[~/Desktop]
+└─$ objdump -d -M intel indirect | grep _start.: -A24
+08049000 <_start>:
+ 8049000: 90 nop
+
+08049001 <indirect_addressing_with_registers>:
+ 8049001: bf 00 a0 04 08 mov edi,0x804a000
+ 8049006: 8b 07 mov eax,DWORD PTR [edi]
+ 8049008: 8b 5f 04 mov ebx,DWORD PTR [edi+0x4]
+ 804900b: c7 47 08 19 00 00 00 mov DWORD PTR [edi+0x8],0x19
+ 8049012: 8b 5f 08 mov ebx,DWORD PTR [edi+0x8]
+
+08049015 <exit>:
+ 8049015: b8 01 00 00 00 mov eax,0x1
+ 804901a: bb 00 00 00 00 mov ebx,0x0
+ 804901f: cd 80 int 0x80
+
+┌──(komugi㉿komugi)-[~/Desktop]
+└─$ gdb -q indirect
+Reading symbols from indirect...
+(No debugging symbols found in indirect)
+(gdb) b _start
+Breakpoint 1 at 0x8049000
+(gdb) r
+Starting program: /home/komugi/Desktop/indirect
+
+Breakpoint 1, 0x08049000 in _start ()
+(gdb) disas
+Dump of assembler code for function _start:
+=> 0x08049000 <+0>: nop
+End of assembler dump.
+(gdb) si
+0x08049001 in indirect_addressing_with_registers ()
+(gdb) diasas
+Undefined command: "diasas". Try "help".
+(gdb) disas
+Dump of assembler code for function indirect_addressing_with_registers:
+=> 0x08049001 <+0>: mov $0x804a000,%edi
+ 0x08049006 <+5>: mov (%edi),%eax
+ 0x08049008 <+7>: mov 0x4(%edi),%ebx
+ 0x0804900b <+10>: movl $0x19,0x8(%edi)
+ 0x08049012 <+17>: mov 0x8(%edi),%ebx
+End of assembler dump.
+(gdb) si
+0x08049006 in indirect_addressing_with_registers ()
+(gdb) x/6 &constants
+0x804a000: 5 8 17 44
+0x804a010: 50 52
+(gdb) si
+0x08049008 in indirect_addressing_with_registers ()
+(gdb) disas
+Dump of assembler code for function indirect_addressing_with_registers:
+ 0x08049001 <+0>: mov $0x804a000,%edi
+ 0x08049006 <+5>: mov (%edi),%eax
+=> 0x08049008 <+7>: mov 0x4(%edi),%ebx
+ 0x0804900b <+10>: movl $0x19,0x8(%edi)
+ 0x08049012 <+17>: mov 0x8(%edi),%ebx
+End of assembler dump.
+(gdb) x/6 &constants
+0x804a000: 5 8 17 44
+0x804a010: 50 52
+(gdb) i r
+eax 0x5 5
+ecx 0x0 0
+edx 0x0 0
+ebx 0x0 0
+esp 0xffffcff0 0xffffcff0
+ebp 0x0 0x0
+esi 0x0 0
+edi 0x804a000 134520832
+eip 0x8049008 0x8049008 <indirect_addressing_with_registers+7>
+eflags 0x202 [ IF ]
+cs 0x23 35
+ss 0x2b 43
+ds 0x2b 43
+es 0x2b 43
+fs 0x0 0
+gs 0x0 0
+(gdb) si
+0x0804900b in indirect_addressing_with_registers ()
+(gdb) si
+0x08049012 in indirect_addressing_with_registers ()
+(gdb) si
+0x08049015 in exit ()
+(gdb) disas
+Dump of assembler code for function exit:
+=> 0x08049015 <+0>: mov $0x1,%eax
+ 0x0804901a <+5>: mov $0x0,%ebx
+ 0x0804901f <+10>: int $0x80
+End of assembler dump.
+(gdb) x/6 &constant
+No symbol table is loaded. Use the "file" command.
+(gdb)
+
+
+```