This commit is contained in:
M Rizky Satrio 2025-03-29 05:51:56 +07:00 committed by GitHub
commit b852c061ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,67 @@
#!/usr/bin/env bash #!/usr/bin/env bash
print_help() {
echo "Usage: $0 [-s y|n] [-t h|s|l|i|m|t] -u <webuser name> -p <password for web user>"
echo " -s: yes or no (optional)"
echo " -t: h (host),s (sensor), l (llm), i(mini),m(mobile),t(tarpit) (optional)"
echo " -u: web username (optional)"
echo " -p: password for web user (optional)"
exit 1
}
validate_s() {
if [[ -n "$myQST" ]]; then
if [[ "$myQST" =~ ^[yYnN]$ ]]; then
return 1 # Valid
else
print_help
fi
else
print_help
fi
}
validate_t() {
if [[ -n "$myTPOT_TYPE" ]]; then
if [[ "$myTPOT_TYPE" =~ ^[hslimtHSLIMT]$ ]]; then
return 1 # Valid
else
print_help
fi
else
print_help
fi
}
while getopts ":s:t:u:p:" opt; do
case "$opt" in
s)
myQST="${OPTARG}"
validate_s
;;
t)
myTPOT_TYPE="${OPTARG}"
validate_t
;;
u)
export myWEB_USER="${OPTARG}"
;;
p)
export myWEB_PW="${OPTARG}"
;;
:)
echo "Option -${OPTARG} requires an argument."
print_help
exit 1
;;
\?)
print_help
;;
esac
done
myINSTALL_NOTIFICATION="### Now installing required packages ..." myINSTALL_NOTIFICATION="### Now installing required packages ..."
myUSER=$(whoami) myUSER=$(whoami)
myTPOT_CONF_FILE="/home/${myUSER}/tpotce/.env" myTPOT_CONF_FILE="/home/${myUSER}/tpotce/.env"
@ -43,12 +105,13 @@ echo "$myINSTALLER"
echo echo
echo echo
echo "### This script will now install T-Pot and all of its dependencies." echo "### This script will now install T-Pot and all of its dependencies."
while [ "${myQST}" != "y" ] && [ "${myQST}" != "n" ]; if [[ -z "$myQST" ]]; then
do while [ "${myQST}" != "y" ] && [ "${myQST}" != "n" ]; do
echo echo
read -p "### Install? (y/n) " myQST read -p "### Install? (y/n) " myQST
echo echo
done done
fi
if [ "${myQST}" = "n" ]; if [ "${myQST}" = "n" ];
then then
echo echo
@ -183,7 +246,10 @@ echo "### Feed data endlessly to attackers, bots and scanners."
echo "### Also runs a Denial of Service Honeypot (ddospot)." echo "### Also runs a Denial of Service Honeypot (ddospot)."
echo echo
while true; do while true; do
if [[ -z "$myTPOT_TYPE" ]]; then
read -p "### Install Type? (h/s/l/i/m/t) " myTPOT_TYPE read -p "### Install Type? (h/s/l/i/m/t) " myTPOT_TYPE
fi
case "${myTPOT_TYPE}" in case "${myTPOT_TYPE}" in
h|H) h|H)
echo echo
@ -239,55 +305,49 @@ if [ "${myTPOT_TYPE}" == "HIVE" ];
echo "### T-Pot User Configuration ..." echo "### T-Pot User Configuration ..."
echo echo
# Asking for web user name # Asking for web user name
if [[ -z "$myWEB_USER" ]]; then
myWEB_USER="" myWEB_USER=""
while [ 1 != 2 ]; while [ 1 != 2 ]; do
do
myOK="" myOK=""
read -rp "### Enter your web user name: " myWEB_USER read -rp "### Enter your web user name: " myWEB_USER
myWEB_USER=$(echo $myWEB_USER | tr -cd "[:alnum:]_.-") myWEB_USER=$(echo $myWEB_USER | tr -cd "[:alnum:]_.-")
echo "### Your username is: ${myWEB_USER}" echo "### Your username is: ${myWEB_USER}"
while [[ ! "${myOK}" =~ [YyNn] ]]; while [[ ! "${myOK}" =~ [YyNn] ]]; do
do
read -rp "### Is this correct? (y/n) " myOK read -rp "### Is this correct? (y/n) " myOK
done done
if [[ "${myOK}" =~ [Yy] ]] && [ "$myWEB_USER" != "" ]; if [[ "${myOK}" =~ [Yy] ]] && [ "$myWEB_USER" != "" ]; then
then
break break
else else
echo echo
fi fi
done done
fi
# Asking for web user password # Asking for web user password
if [[ -z "$myWEB_PW" ]]; then
myWEB_PW="pass1" myWEB_PW="pass1"
myWEB_PW2="pass2" myWEB_PW2="pass2"
mySECURE=0 mySECURE=0
myOK="" myOK=""
while [ "${myWEB_PW}" != "${myWEB_PW2}" ] && [ "${mySECURE}" == "0" ] while [ "${myWEB_PW}" != "${myWEB_PW2}" ] && [ "${mySECURE}" == "0" ]; do
do
echo echo
while [ "${myWEB_PW}" == "pass1" ] || [ "${myWEB_PW}" == "" ] while [ "${myWEB_PW}" == "pass1" ] || [ "${myWEB_PW}" == "" ]; do
do
read -rsp "### Enter password for your web user: " myWEB_PW read -rsp "### Enter password for your web user: " myWEB_PW
echo echo
done done
read -rsp "### Repeat password you your web user: " myWEB_PW2 read -rsp "### Repeat password you your web user: " myWEB_PW2
echo echo
if [ "${myWEB_PW}" != "${myWEB_PW2}" ]; if [ "${myWEB_PW}" != "${myWEB_PW2}" ]; then
then
echo "### Passwords do not match." echo "### Passwords do not match."
myWEB_PW="pass1" myWEB_PW="pass1"
myWEB_PW2="pass2" myWEB_PW2="pass2"
fi fi
mySECURE=$(printf "%s" "$myWEB_PW" | /usr/sbin/cracklib-check | grep -c "OK") mySECURE=$(printf "%s" "$myWEB_PW" | /usr/sbin/cracklib-check | grep -c "OK")
if [ "$mySECURE" == "0" ] && [ "$myWEB_PW" == "$myWEB_PW2" ]; if [ "$mySECURE" == "0" ] && [ "$myWEB_PW" == "$myWEB_PW2" ]; then
then while [[ ! "${myOK}" =~ [YyNn] ]]; do
while [[ ! "${myOK}" =~ [YyNn] ]];
do
read -rp "### Keep insecure password? (y/n) " myOK read -rp "### Keep insecure password? (y/n) " myOK
done done
if [[ "${myOK}" =~ [Nn] ]] || [ "$myWEB_PW" == "" ]; if [[ "${myOK}" =~ [Nn] ]] || [ "$myWEB_PW" == "" ]; then
then
myWEB_PW="pass1" myWEB_PW="pass1"
myWEB_PW2="pass2" myWEB_PW2="pass2"
mySECURE=0 mySECURE=0
@ -295,6 +355,8 @@ if [ "${myTPOT_TYPE}" == "HIVE" ];
fi fi
fi fi
done done
fi
# Write username and password to T-Pot config file # Write username and password to T-Pot config file
echo "### Creating base64 encoded htpasswd username and password for T-Pot config file: ${myTPOT_CONF_FILE}" echo "### Creating base64 encoded htpasswd username and password for T-Pot config file: ${myTPOT_CONF_FILE}"