Skip to content

Commit

Permalink
Update userkiller.sh
Browse files Browse the repository at this point in the history
Added back in chattr functions.
  • Loading branch information
fulco committed May 9, 2024
1 parent 36c89ff commit 3c6fed7
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion userkiller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ manage_services() {
}

# Updates the SSH daemon configuration to listen on a new port and disables root user login.
# Set the immutable flag on the SSH configuration file, moves the default chattr file to /var/log/chatol, and creates a script to replace it.
update_sshd_config() {

if [ ! -f "$SSHD_CONFIG" ]; then
Expand All @@ -149,7 +150,7 @@ update_sshd_config() {
exit 1
fi

if grep -q "^PermitRootLogin" "$SSHD_CONFIG"; then
if grep -q "^PermitRootLogin" "$SSHD_CONFIG"; then
sed -i 's/^PermitRootLogin.*/PermitRootLogin no/' "$SSHD_CONFIG"
log "PermitRootLogin has been set to 'no' in $SSHD_CONFIG."
else
Expand All @@ -162,6 +163,30 @@ update_sshd_config() {
exit 1
fi
log "sshd has been configured to listen on port $NEW_SSH_PORT and disabled root user login."

# Set the immutable flag on the SSH configuration file
if chattr +i "$SSHD_CONFIG"; then
log "Immutable flag set on $SSHD_CONFIG."
else
log "Failed to set immutable flag on $SSHD_CONFIG."
exit 1
fi

# Move the default chattr file to /var/log/chatol
if mv /usr/bin/chattr /var/log/chatol; then
log "Default chattr file moved to /var/log/chatol."
else
log "Failed to move default chattr file to /var/log/chatol."
exit 1
fi

# Create a script to replace the default chattr file
cat > /usr/bin/chattr <<EOL
#!/bin/bash
echo "Oops..."
EOL
chmod +x /usr/bin/chattr
log "Replaced chattr file with a script."
}

# Converts an IP range into individual IPs and outputs them.
Expand Down

0 comments on commit 3c6fed7

Please sign in to comment.