0 | 0 |
#!/bin/bash
|
|
1 |
|
1 | 2 |
function install_powershell() {
|
2 | |
# Deb 10.x
|
3 | |
if cat /etc/debian_version | grep 10.* ; then
|
4 | |
# Download the Microsoft repository GPG keys
|
5 | |
wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb
|
|
3 |
# Debian 10.x
|
|
4 |
if grep "10.*" /etc/debian_version 2>/dev/null; then
|
|
5 |
# Download the Microsoft repository GPG keys
|
|
6 |
wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb
|
6 | 7 |
|
7 | |
# Register the Microsoft repository GPG keys
|
8 | |
sudo dpkg -i packages-microsoft-prod.deb
|
|
8 |
# Register the Microsoft repository GPG keys
|
|
9 |
sudo dpkg -i packages-microsoft-prod.deb
|
9 | 10 |
|
10 | |
# Update the list of products
|
11 | |
sudo apt-get update
|
|
11 |
# Update the list of products
|
|
12 |
sudo apt-get update
|
12 | 13 |
|
13 | |
# Install PowerShell
|
14 | |
sudo apt-get install -y powershell
|
15 | |
# Deb 9.x
|
16 | |
elif cat /etc/debian_version | grep 9.* ; then
|
|
14 |
# Install PowerShell
|
|
15 |
sudo apt-get install -y powershell
|
|
16 |
|
|
17 |
# Debian 9.x
|
|
18 |
elif grep "9.*" /etc/debian_version 2>/dev/null; then
|
17 | 19 |
# Install system components
|
18 | 20 |
sudo apt-get install -y apt-transport-https curl
|
|
21 |
|
19 | 22 |
# Import the public repository GPG keys
|
20 | 23 |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
|
|
24 |
|
21 | 25 |
# Register the Microsoft Product feed
|
22 | 26 |
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main" > /etc/apt/sources.list.d/microsoft.list'
|
|
27 |
|
23 | 28 |
# Update the list of products
|
24 | 29 |
sudo apt-get update
|
|
30 |
|
25 | 31 |
# Install PowerShell
|
26 | 32 |
sudo apt-get install -y powershell
|
27 | |
# Deb 8.x
|
28 | |
elif cat /etc/debian_version | grep 8.* ; then
|
|
33 |
|
|
34 |
# Debian 8.x
|
|
35 |
elif grep "8.*" /etc/debian_version 2>/dev/null; then
|
29 | 36 |
# Install system components
|
30 | 37 |
sudo apt-get install -y apt-transport-https curl gnupg
|
|
38 |
|
31 | 39 |
# Import the public repository GPG keys
|
32 | 40 |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
|
|
41 |
|
33 | 42 |
# Register the Microsoft Product feed
|
34 | 43 |
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-jessie-prod jessie main" > /etc/apt/sources.list.d/microsoft.list'
|
|
44 |
|
35 | 45 |
# Update the list of products
|
36 | 46 |
sudo apt-get update
|
|
47 |
|
37 | 48 |
# Install PowerShell
|
38 | 49 |
sudo apt-get install -y powershell
|
39 | |
#Ubuntu
|
40 | |
elif lsb_release -d | grep -q "Ubuntu"; then
|
|
50 |
|
|
51 |
# Ubuntu
|
|
52 |
elif lsb_release -d 2>/dev/null | grep -q "Ubuntu"; then
|
41 | 53 |
# Read Ubuntu version
|
42 | 54 |
local ubuntu_version=$( grep 'DISTRIB_RELEASE=' /etc/lsb-release | grep -o -E [[:digit:]]+\\.[[:digit:]]+ )
|
|
55 |
|
43 | 56 |
# Install system components
|
44 | 57 |
sudo apt-get install -y apt-transport-https curl
|
|
58 |
|
45 | 59 |
# Import the public repository GPG keys
|
46 | 60 |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
|
|
61 |
|
47 | 62 |
# Register the Microsoft Ubuntu repository
|
48 | 63 |
curl https://packages.microsoft.com/config/ubuntu/$ubuntu_version/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list
|
|
64 |
|
49 | 65 |
# Update the list of products
|
50 | 66 |
sudo apt-get update
|
|
67 |
|
51 | 68 |
# Install PowerShell
|
52 | 69 |
sudo apt-get install -y powershell
|
53 | |
#Kali Linux
|
54 | |
elif lsb_release -d | grep -q "Kali"; then
|
|
70 |
|
|
71 |
# Kali Linux
|
|
72 |
elif lsb_release -d 2>/dev/null | grep -q "Kali"; then
|
55 | 73 |
apt update && apt -y install powershell
|
|
74 |
|
|
75 |
else
|
|
76 |
echo 'Unsupported OS. Exiting.' && exit
|
56 | 77 |
fi
|
57 | |
if ls /opt/microsoft/powershell/*/DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY; then
|
58 | |
rm /opt/microsoft/powershell/*/DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY
|
59 | |
fi
|
|
78 |
|
|
79 |
# Disable telemetry
|
|
80 |
rm /opt/microsoft/powershell/*/DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY 2>/dev/null
|
|
81 |
|
|
82 |
# Install Invoke-Obfuscation module
|
60 | 83 |
mkdir -p /usr/local/share/powershell/Modules
|
61 | 84 |
cp -r ../lib/powershell/Invoke-Obfuscation /usr/local/share/powershell/Modules
|
62 | 85 |
}
|
|
80 | 103 |
function install_bomutils() {
|
81 | 104 |
git clone https://github.com/hogliux/bomutils.git
|
82 | 105 |
(cd bomutils && make)
|
83 | |
(cd bomutils && make install)
|
|
106 |
(cd bomutils && sudo make install)
|
84 | 107 |
chmod 755 bomutils/build/bin/mkbom && sudo cp bomutils/build/bin/mkbom /usr/local/bin/.
|
85 | 108 |
}
|
86 | 109 |
|
|
100 | 123 |
false
|
101 | 124 |
}
|
102 | 125 |
|
103 | |
# Ask for the administrator password upfront so sudo is no longer required at Installation.
|
|
126 |
# Ask for the sudo password upfront so it is no longer required during installation.
|
104 | 127 |
sudo -v
|
105 | 128 |
|
106 | 129 |
IFS='/' read -a array <<< pwd
|
|
112 | 135 |
|
113 | 136 |
Pip_file="requirements.txt"
|
114 | 137 |
|
115 | |
if lsb_release -d | grep -q "Kali"; then
|
|
138 |
if lsb_release -d 2>/dev/null | grep -q "Kali"; then
|
116 | 139 |
apt-get update
|
117 | 140 |
sudo apt-get install -y make autoconf g++ python3-dev swig python3-pip libxml2-dev default-jdk zlib1g-dev libssl1.1 build-essential libssl-dev libxml2-dev zlib1g-dev
|
118 | |
elif lsb_release -d | grep -q "Ubuntu"; then
|
|
141 |
elif lsb_release -d 2>/dev/null | grep -q "Ubuntu"; then
|
119 | 142 |
if is_libssl_1_0; then
|
120 | 143 |
LibSSL_pkgs="libssl1.0.0 libssl-dev"
|
121 | 144 |
Pip_file="requirements_libssl1.0.txt"
|
|
123 | 146 |
LibSSL_pkgs="libssl1.1 libssl-dev"
|
124 | 147 |
fi
|
125 | 148 |
sudo apt-get update
|
126 | |
sudo apt-get install -y make autoconf g++ python3-dev swig python3-pip libxml2-dev default-jdk $LibSSL_pkgs build-essential
|
|
149 |
sudo apt-get install -y make autoconf g++ python3-dev swig python3-pip libxml2-dev default-jdk "$LibSSL_pkgs" build-essential
|
|
150 |
elif grep "Fedora release" /etc/redhat-release 2>/dev/null; then
|
|
151 |
sudo dnf update
|
|
152 |
sudo dnf install -y autoconf autogen make gcc-c++ libxml2-devel openssl-devel python3-pip python3-devel python3-m2crypto
|
127 | 153 |
else
|
128 | 154 |
echo "Unknown distro - Debian/Ubuntu Fallback"
|
129 | 155 |
if is_libssl_1_0; then
|
|
133 | 159 |
LibSSL_pkgs="libssl1.1 libssl-dev"
|
134 | 160 |
fi
|
135 | 161 |
sudo apt-get update
|
136 | |
sudo apt-get install -y make autoconf g++ python3-dev swig python3-pip libxml2-dev default-jdk libffi-dev $LibSSL_pkgs build-essential
|
|
162 |
sudo apt-get install -y make autoconf g++ python3-dev swig python3-pip libxml2-dev default-jdk libffi-dev "$LibSSL_pkgs" build-essential
|
137 | 163 |
fi
|
138 | 164 |
|
139 | 165 |
install_xar
|
|
142 | 168 |
|
143 | 169 |
install_powershell
|
144 | 170 |
|
145 | |
if ls /usr/bin/ | grep -q "python3"; then
|
146 | |
if ! type pip3 > /dev/null; then
|
147 | |
sudo apt-get --assume-yes install python3-pip
|
148 | |
fi
|
149 | |
sudo pip3 install -r $Pip_file
|
150 | |
fi
|
|
171 |
# Install Python dependencies
|
|
172 |
sudo pip3 install -r "$Pip_file"
|
151 | 173 |
|
152 | |
# set up the database schema
|
|
174 |
# Set up the database schema
|
153 | 175 |
python3 ./setup_database.py
|
154 | 176 |
|
155 | |
# generate a cert
|
|
177 |
# Generate a cert
|
156 | 178 |
./cert.sh
|
157 | 179 |
|
158 | 180 |
cd ..
|