40 lines
620 B
Bash
Executable File
40 lines
620 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Set the value for aslr on the kernel depending on $1
|
|
|
|
if [ $EUID != 0 ]; then
|
|
sudo "$0" "$@"
|
|
exit $?
|
|
fi
|
|
|
|
error_msg="Supply an int between 0 and 2!\nQuiting...\n"
|
|
file="/proc/sys/kernel/randomize_va_space"
|
|
|
|
enable -n echo
|
|
|
|
if [ 1 -gt ${#} ]
|
|
then
|
|
printf "No arguments supplied.\n"
|
|
printf "${error_msg}"
|
|
exit 1
|
|
fi
|
|
|
|
|
|
|
|
if [ ${1} -gt 2 ]
|
|
then
|
|
printf "Argument is too large!"
|
|
printf "${error_msg}"
|
|
exit 1
|
|
fi
|
|
|
|
if [ ${1} -lt 0 ]
|
|
then
|
|
printf "Argument is too small!"
|
|
printf "${error_msg}"
|
|
exit 1
|
|
fi
|
|
|
|
echo ${1} | sudo tee ${file}
|
|
echo -e "\33[1mASLR is now set to $(cat ${file}).\33[1m"
|