forked from gh0x0st/Secure_Kali
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecurekali.sh
92 lines (82 loc) · 2.17 KB
/
securekali.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/bash
header()
{
echo -e "\n >> Secure Kali Linux"
echo -e " >> https://www.github.com/gh0x0st \n"
}
check_root()
{
if [ "$EUID" -ne 0 ]
then
echo "[!] Please run with sudo"
exit
fi
}
upgrade_kali()
{
echo "[*] Upgrading Kali Linux"
apt update && apt full-upgrade -y
}
install_utils()
{
echo "[*] Installing Fail2ban, PortSentry, and rsyslog"
apt install fail2ban portsentry rsyslog
}
config_utils()
{
repo="https://raw.githubusercontent.com/vortex1942/Secure_Kali/master"
echo "[*] Downloading jail.conf from repo"
curl $repo/jail.local -s -o '/etc/fail2ban/jail.local'
echo "[*] Downloading http-get-dos.conf from repo"
curl $repo/http-get-dos.conf -s -o '/etc/fail2ban/filter.d/http-get-dos.conf'
echo "[*] Downloading portsentry.conf from repo"
curl $repo/portsentry.conf -s -o '/etc/portsentry/portsentry.conf'
echo "[*] Create PortSentry history file"
touch '/var/lib/portsentry/portsentry.history'
echo "[*] Setting rsyslog to run on start up"
systemctl enable rsyslog
echo "[*] Setting Fail2ban to run on start up"
systemctl enable fail2ban
}
config_ssh()
{
echo "[*] Explicitly denying root ssh access"
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config
echo "[!] Explicitly denying ssh password authentication"
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
echo "[*] Generating new SSH host keys"
mkdir /etc/ssh/temp
mv /etc/ssh/ssh_host_* /etc/ssh/temp
dpkg-reconfigure openssh-server
echo '[!] Restart SSH and ensure you can still connect to SSH. If you can, purge /etc/ssh/temp'
}
start_services()
{
services=("fail2ban" "portsentry")
for s in "${services[@]}"
do
systemctl restart "$s"
if ( systemctl is-active --quiet "$s" )
then
echo "[*] $s is now running"
else
echo "[!] $s did not start properly"
fi
done
}
footer()
{
echo "[*] Done"
}
run()
{
header
check_root
upgrade_kali
install_utils
config_utils
config_ssh
start_services
footer
}
run