Safflower's Blog Security Researcher

Binary Options in Ubuntu


Environment

It’s Ubuntu.

$ uname -a
Linux pwn 4.4.0-34-generic #53-Ubuntu SMP Wed Jul 27 16:06:39 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ gcc --version
gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Disable ASLR in System

$ echo 0 > /proc/sys/kernel/randomize_va_space

Compile x86 in GCC

$ gcc -m32 -o x x.c

Compile x64 in GCC

$ gcc -m64 -o x x.c

Disable RELRO in GCC

$ gcc -z norelro -o x x.c

Enable Partial RELRO in GCC

$ gcc z relro -o x x.c

Enable Full RELRO in GCC

$ gcc -z relro -z now -o x x.c 
$ gcc -z now -o x x.c 

Disable NX Bit in GCC

$ gcc -z execstack -o x x.c

Disable Stack Canary in GCC

$ gcc -fno-stack-protector -o x x.c

Disable PIE in GCC

$ gcc -no-pie -o x x.c

Enable Random .text in GCC

$ gcc -fpie -o x x.c

Enable PIE in GCC

$ gcc -fpie -pie -o x x.c

Disable Instruction to Sort Stack in main() in GCC

$ gcc -mpreferred-stack-boundary=2 -o x x.c

Disable All Options

$ echo 0 > /proc/sys/kernel/randomize_va_space
$ gcc -m32 -z norelro -z execstack -fno-stack-protector -no-pie -mpreferred-stack-boundary=2 -o x x.c
$ checksec x
[*] '/root/study/stack-bof/1/x'
    Arch:     i386-32-little
    RELRO:    No RELRO
    Stack:    No canary found
    NX:       NX disabled
    PIE:      No PIE (0x8048000)
    RWX:      Has RWX segments

Previous Vue.js 시작

Comments

Content