This repository has been archived by the owner on Aug 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
deploy_locally.sh
66 lines (54 loc) · 1.66 KB
/
deploy_locally.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
#!/bin/bash
echo 'Do not forget to change the credentials in hosts.ini'
echo "Kill this process if you haven't changed them"
sleep 8
# Run as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
echo 'This might take over 15 minutes, so curl https://$( cat Starbucks.menu | grep coffee )'
sshd='/etc/ssh/sshd_config'
string1=$(cat $sshd | grep PermitRootLogin )
string2=$(cat hosts.ini | grep ansible_user=root)
# If you are deplying it with the root user
if [[ $string2 == *"root"* ]]; then
echo "Checking "$sshd ".. "
if [[ $string1 == *"yes"* ]]; then
echo "SSH configuration is all set."
else
echo "PermitRootLogin is disabled"
echo "Backing up "$sshd ".."
cp $sshd $sshd.bk
echo "Modifying "$sshd ".."
sed 's/PermitRootLogin/PermitRootLogin yes#/' $sshd.bk > $sshd
systemctl restart ssh
fi
fi
# Fix the source repositories list
echo "
deb http://http.kali.org/kali kali-rolling main non-free contrib
deb http://kali.cs.nctu.edu.tw/kali kali-rolling main contrib non-free
deb-src http://http.kali.org/kali kali-rolling main non-free contrib
" >> /etc/apt/sources.list
# Deploy
echo 'Updating..'
bash scripts/update.sh
# Install ansible
echo 'Installing Ansible..'
bash scripts/install-ansible.sh
# Start SSH
echo 'Starting SSH..'
systemctl start ssh
# Start deploying
ansible-playbook deploy_kali.yml -i hosts.ini -e 'ansible_python_interpreter=/usr/bin/python3'
# If you are deplying it with the root user
if [[ $string2 == *"root"* ]]; then
if [[ $string1 == *"yes"* ]]; then
echo "All set. Hack the planet!"
else
echo "Recovering "$sshd ".."
# Recover the old sshd_config file
mv $sshd.bk $sshd
fi
fi