PATH:
usr
/
local
/
sbin
#!/bin/bash #1.CONSTANTS FOR COLORS: RED_COLOR=$'\033[31;1m' GREEN_COLOR=$'\033[32;1m' YELLOW_COLOR=$'\033[33;1m' DEFAULT_COLOR=$'\033[0m' #2.INPUT DOMAIN NAME: printf "%sTYPE THE DOMAIN NAME THAT YOU WISH TO BE RESTICTED.%s\\n" "$GREEN_COLOR" "$DEFAULT_COLOR" #2.1.CHECK IF INPUT DOMAIN EXISTS AND ASK FOR INPUT UNTIL EXISTING DOMAIN IS PROVIDED: current_user=$(whoami) counter=0 while [ -z "$doc_root" ]; do if [ "$counter" != 0 ]; then printf "%sINVALID DOMAIN! TYPE THE DOMAIN AGAIN:%s\\n" "$RED_COLOR" "$DEFAULT_COLOR" fi read -e -r -p $'\e[36mDomain/Subdomain:\e[0m ' input_domain; #2.1.1.CONVERT INPUT TO LOWERCASE: input_domain="${input_domain,,}" #2.1.2.REMOVE ANY '/' AT THE END OF THE INPUT: last_char="${input_domain: -1}" while [ "$last_char" = '/' ]; do input_domain=${input_domain%?}; last_char="${input_domain: -1}" done sub_folder=$( echo "${input_domain}" | cut -d '/' -s -f 2- ) domain_name=$( echo "$input_domain" | cut -d '/' -f 1 ) if [ "$current_user" = 'root' ]; then cpanel_user=$( /scripts/whoowns "$domain_name" ) if [ -n "$cpanel_user" ]; then doc_root=$( uapi --user="$cpanel_user" DomainInfo single_domain_data domain="$domain_name" | grep 'documentroot:' | cut -d ' ' -f 6 ) fi else doc_root=$( uapi DomainInfo single_domain_data domain="$domain_name" | grep 'documentroot:' | cut -d ' ' -f 6 ) fi if [ -n "$doc_root" ]; then if [ -n "$sub_folder" ]; then doc_root=${doc_root}/${sub_folder} fi fi ((counter++)) done cd "$doc_root" 2> /dev/null || (printf "%sDOCUMENT ROOT DOES NOT EXIST! EXITING ...%s\\n" "$RED_COLOR" "$DEFAULT_COLOR"; exit; ) if [[ -f .htaccess && -s .htaccess ]]; then if [[ "$current_user" = 'root' && -n $(lsattr .htaccess | grep 'a\|i' | awk '{print$1}') ]]; then chattr -ai .htaccess fi sed -i '1s/^/ErrorDocument 403 default\nDeny from All\n/' .htaccess else printf 'ErrorDocument 403 default\nDeny from All' > .htaccess if [ "$current_user" = 'root' ]; then chown "$cpanel_user": .htaccess fi fi counter=0 for file in $(find * .[^.]* -type f -name .htaccess); do if [ ! -z $(grep -il 'Allow From All' "$file") ]; then if [ $counter -eq 0 ]; then printf "%sAllow From All found in the following files:%s\\n" "$RED_COLOR" "$DEFAULT_COLOR" ((counter++)) fi printf "$doc_root/$file\\n" read -e -r -p $'\e[36mWould you like to remove the rule?(y/n):\e[0m ' remove; if [ "$remove" = 'y' ]; then sed -i '/Allow From All/Id' "$file" else printf "%sRule not removed from "$file".%s\\n" "$RED_COLOR" "$DEFAULT_COLOR" fi fi done if [ "$current_user" = 'root' ]; then chattr +ai .htaccess fi
[-] 1
[edit]
[-] 99
[edit]
[-] 11
[edit]
[-] 25bl
[edit]
[+]
..
[-] 2
[edit]
[-] portchk
[edit]
[-] restrict
[edit]
[-] 80
[edit]
[-] 12
[edit]
[-] 33
[edit]
[-] 5
[edit]
[-] 7
[edit]
[-] mqkill
[edit]
[-] 3
[edit]
[-] 88
[edit]
[-] dai
[edit]
[-] logs
[edit]
[-] 4
[edit]
[-] ukill
[edit]
[-] c
[edit]
[-] 25
[edit]
[-] 22
[edit]
[-] 6
[edit]
[-] bl
[edit]