Created
December 12, 2021 16:25
-
-
Save TheFlash2k/7d70d3d86b3b02a76f43f42ad73d0ed0 to your computer and use it in GitHub Desktop.
A bash script to compile binaries vulnerable to Stack Buffer Overflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $# != 1 ]]; then | |
echo "[!] No arguments provided! Please provide the name of the file that you want to compile!" | |
echo "Usage: $0 <file_name.c> | |
exit | |
fi | |
out_file=`echo $1 | cut -d '.' -f 1` | |
echo "[+] Disabling ASLR" | |
sudo sysctl -w kernel.randomize_va_space=0 | |
echo "[+] Compiling binary for x86 Architecture" | |
gcc -z execstack -o $out_file $1 -fno-stack-protector -no-pie -m32 2>/dev/null | |
if [[ $? != 0 ]]; then | |
echo "[-] Unable to compile the binary. Please install the following libraries:" | |
echo "sudo apt-get install gcc-multilib" | |
echo "sudo apt-get install libx11-dev:i386 libx11-dev" | |
exit | |
fi | |
echo "[+] Changing permissions to a SETUID binary" | |
sudo chown root stack | |
sudo chgrp root stack | |
sudo chmod 4755 stack | |
echo "[*] Successful!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment