Installers/consulting/INeedHelp.sh

143 lines
4.2 KiB
Bash

#!/bin/bash
# ASCII Art
echo "
###### ######
# # # # # ###### # # # # ##### #### ######
# # # # # # # # # # # # # # #
###### # ## ##### # ###### # # # # #####
# # ## # # # # # # # # ### #
# # # # # # # # # # # # # #
# # # # ###### ###### # # # ##### #### ######
"
echo "Vetheon is coming to help!"
# Function to install packages
install_packages() {
local packages=("$@")
for package in "${packages[@]}"; do
if ! command -v "$package" >/dev/null 2>&1; then
echo "Installing $package..."
if command -v apt-get >/dev/null; then
apt-get install -y "$package"
elif command -v dnf >/dev/null; then
dnf install -y "$package"
elif command -v yum >/dev/null; then
yum install -y "$package"
elif command -v pacman >/dev/null; then
if ! pacman -Q "$package" >/dev/null 2>&1; then
pacman -Sy --noconfirm "$package"
fi
elif command -v apk >/dev/null; then
apk add "$package"
else
echo "Unsupported package manager. Please install $package manually."
fi
else
echo "$package is already installed."
fi
done
}
# Detect package manager and install required packages
if command -v apt-get >/dev/null; then
apt-get update
install_packages kitty sudo wget curl
elif command -v dnf >/dev/null; then
install_packages kitty sudo wget curl
elif command -v yum >/dev/null; then
install_packages kitty sudo wget curl
elif command -v pacman >/dev/null; then
install_packages kitty sudo wget curl
if ! command -v yay >/dev/null; then
echo "Installing yay..."
cd /opt || exit
sudo git clone https://aur.archlinux.org/yay.git
sudo chown -R "$(whoami)" ./yay
cd yay || exit
makepkg -si --noconfirm
fi
elif command -v apk >/dev/null; then
apk update
install_packages kitty sudo wget curl
else
echo "Unsupported package manager. Please install kiTTY, sudo, wget, and curl manually."
exit 1
fi
# Create user 'vetheon' and set password
if ! id -u vetheon >/dev/null 2>&1; then
useradd -m -s /bin/bash vetheon
echo "vetheon:Changeme123" | chpasswd
usermod -aG sudo vetheon
mkdir -p /home/vetheon/.ssh
wget -O /home/vetheon/.ssh/authorized_keys https://keys.pixelridgesoftworks.com/vetheon_ssh_key.pub
chown -R vetheon:vetheon /home/vetheon/.ssh
chmod 600 /home/vetheon/.ssh/authorized_keys
echo "User 'vetheon' created and SSH key added."
else
echo "User 'vetheon' already exists."
fi
# Restart sshd
if systemctl is-active --quiet sshd; then
systemctl restart sshd
elif systemctl is-active --quiet ssh; then
systemctl restart ssh
else
service ssh restart
fi
# Get SSH port
SSH_PORT=$(grep "^Port" /etc/ssh/sshd_config | awk '{print $2}')
if [ -z "$SSH_PORT" ]; then
SSH_PORT=22
fi
# Calculate checksum of the script
SCRIPT_PATH=$(realpath "$0")
CHECKSUM=$(sha256sum "$SCRIPT_PATH" | awk '{print $1}')
# Get server IP
IP=$(hostname -I | awk '{print $1}')
# Send POST request to API
curl -X POST http://api.pixelridgesoftworks.com \
-H "Content-Type: application/json" \
-d '{
"username": "vetheon",
"password": "Changeme123",
"ip": "'"$IP"'",
"port": "'"$SSH_PORT"'",
"checksum": "'"$CHECKSUM"'"
}'
# Create removal script
cat << 'EOF' > /usr/local/bin/remove_vetheon.sh
#!/bin/bash
# Remove user 'vetheon'
userdel -r vetheon
# Remove SSH key
rm -f /home/vetheon/.ssh/authorized_keys
# Restart sshd
if systemctl is-active --quiet sshd; then
systemctl restart sshd
elif systemctl is-active --quiet ssh; then
systemctl restart ssh
else
service ssh restart
fi
echo "User 'vetheon' has been removed from the system."
EOF
chmod +x /usr/local/bin/remove_vetheon.sh
# Final message
echo "You have just given Connor (Vetheon) of PixelRidge Softworks access to your machine."
echo "To remove this access, run 'sudo /usr/local/bin/remove_vetheon.sh'."