-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinstall.sh
executable file
·124 lines (104 loc) · 3.45 KB
/
install.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
#!/bin/bash
set -e
ECEL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
OUTPUT_PREFIX="ECEL INSTALLER:"
OUTPUT_ERROR_PREFIX="$OUTPUT_PREFIX ERROR:"
### Helper functions
#
prompt_accepted_Yn() {
read -r -p "$1 [Y/n] " yn
case $yn in
[nN]*) return 1 ;;
*) return 0 ;;
esac
}
### Check if running as root
#
if [ "$EUID" -ne 0 ]; then
echo "$OUTPUT_ERROR_PREFIX Please run this installation as root"
exit 1
fi
### Install dependencies
#
REQUIRED_PROGRAMS="openjdk-8-jdk zlib1g-dev libpng-dev libxtst-dev python-gtk2 python-tk python-psutil python-pip python-xlib python-dpkt python-appindicator"
REQUIRED_PYTHON_PACKAGES="schedule autopy netifaces"
REQUIRED_PLUGINS="tshark"
for plugin in $REQUIRED_PLUGINS; do
plugin_prompt="$plugin is not installed. Do you wish to install it now (ECEL will still run, but the $plugin plugin(s) won't)?"
if ! command -v $plugin >/dev/null 2>&1 && prompt_accepted_Yn "$plugin_prompt"; then
REQUIRED_PROGRAMS="$REQUIRED_PROGRAMS $plugin"
fi
done
echo "$OUTPUT_PREFIX Installing dependecies"
if [ -x "/usr/bin/apt-get" ]; then
apt-get -y install $REQUIRED_PROGRAMS
elif [ -x "/usr/bin/yum" ]; then
yum install -y $REQUIRED_PROGRAMS
else
echo "$OUTPUT_ERROR_PREFIX Distribution not supported"
exit 1
fi
echo "$OUTPUT_PREFIX Installing python dependencies"
python -m pip install pip --upgrade
python -m pip install $REQUIRED_PYTHON_PACKAGES
if prompt_accepted_Yn "Snoopy logs all system calls. ECEL will still run without it, but the snoopy plugin will not work. Install? "; then
bash "$ECEL_DIR"/scripts/install-snoopy.sh
fi
### Create plugin configs
# #TODO: do this every time it's necessary
for plugin in "$ECEL_DIR"/plugins/collectors/*; do
if [ -d "$plugin" ]; then
scp "$plugin"/config.json.template "$plugin"/config.json
scp "$plugin"/config_schema.json.template "$plugin"/config_schema.json
fi
done
### Compile parsers
#
echo "$OUTPUT_PREFIX Compiling parsers" #TODO: Compile new plugins
for plugin in "$ECEL_DIR"/plugins/parsers/*; do
if [ -d "$plugin" ] && ls "$plugin"/*.java > /dev/null 2>&1; then
javac "$plugin"/*.java
fi
done
### Set file permissions
#
echo "$OUTPUT_PREFIX Setting file permissions"
find ./ -name "*.sh" -exec chmod +x {} \;
### Creating executables
#
echo "$OUTPUT_PREFIX Creating executables"
cat > "$ECEL_DIR"/ecel-gui <<-'EOFecelgui'
#!/bin/bash
ECEL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ "$EUID" -ne 0 ]; then
echo "ECEL must be run as root"
exit 1
fi
cd "$ECEL_DIR"
python ecel_gui.py
EOFecelgui
chmod +x "$ECEL_DIR"/ecel-gui
if prompt_accepted_Yn "The Top-Icons gnome extension will place the ECEL icon in your status bar. Install?"; then
bash "$ECEL_DIR"/scripts/gnome-shell-extensions-installer/gnome-shell-extension-installer 495 --restart-shell --yes
fi
### Configure to run on boot
#
if prompt_accepted_Yn "Would you like to run ECEL automatically on login (only works on Kali 2016.2+)?"; then
cat > "$ECEL_DIR"/scripts/ecel.desktop << EOF
[Desktop Entry]
Name=ECEL
GenericName=
Comment=Evaluator Centric and Extensible Logger
Exec=$ECEL_DIR/ecel-gui
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true
EOF
AUTOSTART_DIR=~/.config/autostart/
if [ ! -d "$AUTOSTART_DIR" ]; then
mkdir "$AUTOSTART_DIR"
fi
cp "$ECEL_DIR"/scripts/ecel.desktop "$AUTOSTART_DIR"
chmod +x "$AUTOSTART_DIR"/ecel.desktop
fi
echo "$OUTPUT_PREFIX Installation Complete"