-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathsetup-cnc-v2
executable file
·42 lines (33 loc) · 1.04 KB
/
setup-cnc-v2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
### SETUP C&C ###
NEXT=0
while [ "$NEXT" == "0" ] ; do
read -p "Drop box user account to create [drop-box]: " DBUSER
if [ "$DBUSER" == "" ] ; then
DBUSER=drop-box
fi
if [ "$(grep $DBUSER /etc/passwd)" == "" ]; then
NEXT=1
else
echo "ERROR: User already exists."
echo
fi
done
# Create the drop box user account
useradd -m -r -s /bin/false $DBUSER
# Setup drop box ssh keys
mkdir /home/$DBUSER/.ssh
#touch /home/$DBUSER/.ssh/authorized_keys
ssh-keygen -f /home/$DBUSER/.ssh/id_rsa -N ""
cat /home/$DBUSER/.ssh/id_rsa.pub >> /home/$DBUSER/.ssh/authorized_keys
chown -R $DBUSER /home/$DBUSER
# Make the SSH service listen on port 443 in addition to 22
if [ "$(grep 'Port 443' /etc/ssh/sshd_config)" == "" ] ; then
sed -i 's/Port 22/Port 22\nPort 443/g' /etc/ssh/sshd_config
fi
# Enable root login over SSH using a password
sed -Ei 's/^PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# Start the SSH service
update-rc.d ssh enable
service ssh restart
echo Done.