forked from tracelabs/tlosint-live
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_tracelabsiso_recipe.sh
executable file
·151 lines (128 loc) · 5.08 KB
/
build_tracelabsiso_recipe.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
# Log output to STDOUT and to a file.
export logPath="squid_setup.log"
exec &> >( tee -a $logPath)
##### Fix display output for GUI programs (when connecting via SSH)
export DISPLAY=:0.0
export TERM=xterm
##### Check if we are running as root - else this script will fail
function root_check {
if [[ "${EUID}" -ne 0 ]]; then
echo -e "[!] This script must be run as root" 1>&2
echo -e "[!] Quitting..." 1>&2
exit 1
else
internet_access
fi
}
##### Check Internet access
function internet_access {
#--- Can we ping google?
for i in {1..10}; do ping -c 1 -W ${i} www.google.com &>/dev/null && break; done
#--- Run this, if we can't
if [[ "$?" -ne 0 ]]; then
echo -e '[!]'" Possible DNS issues(?)" 1>&2
echo -e '[!]'" Will try and use DHCP to 'fix' the issue" 1>&2
chattr -i /etc/resolv.conf 2>/dev/null
dhclient -r
#--- Second interface causing issues?
# ip addr show eth1 &>/dev/null
# [[ "$?" == 0 ]] \
# && route delete default gw 192.168.155.1 2>/dev/null
#--- Request a new IP
dhclient
dhclient eth0 2>/dev/null
dhclient wlan0 2>/dev/null
#--- Wait and see what happens
sleep 15s
_TMP="true"
_CMD="$(ping -c 1 8.8.8.8 &>/dev/null)"
if [[ "$?" -ne 0 && "$_TMP" == "true" ]]; then
_TMP="false"
echo -e '[!]'" No Internet access" 1>&2
echo -e '[!]'" You will need to manually fix the issue, before re-running this script" 1>&2
fi
_CMD="$(ping -c 1 www.google.com &>/dev/null)"
if [[ "$?" -ne 0 && "$_TMP" == "true" ]]; then
_TMP="false"
echo -e '[!]'" Possible DNS issues(?)" 1>&2
echo -e '[!]'" You will need to manually fix the issue, before re-running this script" 1>&2
fi
if [[ "$_TMP" == "false" ]]; then
(dmidecode | grep -iq virtual) && echo -e " [i] VM Detected"
(dmidecode | grep -iq virtual) && echo -e " [i] Try switching network adapter mode (e.g. NAT/Bridged)"
echo -e '[!]'" You will need to manually fix the issue, before re-running this script, trying anyway" 1>&2
tlosint-install
fi
else
echo -e " [i] Detected Internet access" 1>&2
tlosint-install
fi
}
##### tlosint-live installation
function tlosint-install {
##### OS Version
OS_VERSION=$(cat /etc/issue)
##### Disabling the lockscreen
#xset s 0 0
#xset s off
#gsettings set org.gnome.desktop.session idle-delay 0
kali_path="/opt/live-build-config"
tl_path="/opt/tlosint-live"
if [ -d "$kali_path" ]; then
if [ -d "$tl_path" ]; then
if [ "$OS_VERSION" != "Kali GNU/Linux Rolling \n \l" ]; then
apt-get -qq install gnupg
wget -q 'https://archive.kali.org/archive-key.asc'
apt-key add archive-key.asc
cat /etc/apt/sources.list > /etc/apt/sources.list.orig
echo "deb http://http.kali.org/kali kali-rolling main non-free contrib" >> /etc/apt/sources.list
wget https://http.kali.org/pool/main/k/kali-archive-keyring/kali-archive-keyring_2020.2_all.deb
apt-get update -qq
dpkg --configure -a
dpkg -i kali-archive-keyring_2020.2_all.deb
fi
apt-get update -qq -y
dpkg --configure -a
apt --fix-broken install
#apt-get upgrade -y
#apt-get dist-upgrade -y
echo "[+] Updates done ... "
apt-get install curl git -y
apt-get install live-build -y
apt-get install cdebootstrap -y
apt-get install squid -y
echo "[+] Live build pre-requisites installed ... "
#wget -O /etc/squid/squid.conf https://raw.githubusercontent.com/prateepb/kali-live-build/master/squid.conf
#/etc/init.d/squid start
#grep -qxF "http_proxy=http://localhost:3128/" /etc/environment || echo "http_proxy=http://localhost:3128/" >> /etc/environment
#echo "[+] Squid set-up completed .... "
# Copy all the files required for the Tracelabs ISO to the latest Kali live-build repo
cp -rfv $tl_path/kali-config/variant-tracelabs/ $kali_path/kali-config/
cp -rfv $tl_path/kali-config/common/hooks/normal $kali_path/kali-config/common/hooks/
cp -rfv $tl_path/kali-config/common/includes.chroot/etc/* $kali_path/kali-config/common/includes.chroot/etc/
cp -rfv $tl_path/kali-config/common/includes.chroot/usr/* $kali_path/kali-config/common/includes.chroot/usr/
echo "[+] Kali ISO build process starting ... "
##### removing version check to allow build on ubuntu (DON'T REMOVE, NEED THIS FOR CI\CD)
sed -i '161s/.*/#exit 1/' /opt/live-build-config/build.sh
sed -i '166s/.*/#exit 1/' /opt/live-build-config/build.sh
sed -i '177s/.*/#exit 1/' /opt/live-build-config/build.sh
sed -i '182s/.*/#exit 1/' /opt/live-build-config/build.sh
$kali_path/build.sh --verbose --variant tracelabs
#-- --apt-http-proxy=${http_proxy}
##### Cleanup
#apt-get remove -qq squid -y
#rm -f /etc/squid/squid.conf
rm -f kali-archive-keyring_2020.2_all.deb
cat /etc/apt/sources.list.orig > /etc/apt/sources.list
rm -f /etc/apt/sources.list.orig
fi
else
# Clone the Kali live-build and Tracelabs repositories
echo "[+] tlosint-live & live-build-config directories not found, creating."
git clone https://gitlab.com/kalilinux/build-scripts/live-build-config.git /opt/live-build-config
git clone https://github.com/tracelabs/tlosint-live.git /opt/tlosint-live
tlosint-install
fi
}
root_check