-
Notifications
You must be signed in to change notification settings - Fork 4
/
maas
215 lines (174 loc) · 8.59 KB
/
maas
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/bin/bash
# MAAS
# Multiplexer Adaptive Adminstrator Solution
# Copyright (C) 2016 Aurélien DESBRIÈRES <aurelien@hackers.camp>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
tput clear
the_user="$(whoami)"
#the_admin="$(whoami)"
#admin_ip="$(ip addr show $network | grep 'inet\b' | grep 192 | awk '{print $2}' | cut -d/ -f1)"
printf "\033[1;32mWelcome to MAAS - Multiplexer Adaptive Adminstrator Solution\033[0m%s\n"
printf "\033[1;32mMAAS offer you the way to works with different OS type like they were all the same\033[0m%s\n"
printf "\033[1;32mPlease report your needs to:\033[0m aurelien@hackers.camp%s\n"
printf "\033[1;32mYou need root privileges to run it\033[0m%s\n"
# append to the private key
while true; do
read -p "Do you need to use a private key to connect on this cluster network? Y/n " yn
case $yn in
[Yy]* ) # adding a key
printf "%s\nHere is the list of your keys on this system $the_user%s\n"
ls -la ~/.ssh/
printf "%s\nWrite the name of the private key you wish to use $the_user%s\n"
read private
break;;
[Nn]* ) break;;
* ) echo "Please answer Yes or no.";;
esac
done
# Copy files in the working directory
mkdir -p ~/MAAS-REPORT/
mkdir -p ~/MAAS-REPORT/LOG/
cp -r run maas mussh search.sh scan.awk faron.sh update.sh mi.sh remove.sh virusscan.sh sysinfo.sh cryptosteg.sh ~/MAAS/
cd ~/MAAS/
# Register the user identification during process
printf "\033[1;32m%s\nRegistering you identification during the MAAS process\033[0m%s\n"
if [ ! -S ~/.ssh/ssh_auth_sock ]; then
eval "$(ssh-agent)"
ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
fi
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
ssh-add -l | grep "The agent has no identities" && ssh-add
# copy files to remote host
while true; do
read -p "Do you wish to send M.A.A.S tools to the target machine? Y/n " yn
case $yn in
[Yy]* ) # send files to the target machines
printf "\033[1;32m%s\nCopying files on remote machines\033[0m%s\n"
for target in $(cat maas-hostfile) ; do
rsync -avz ~/MAAS "$target":~/MAAS/
done
break;;
[Nn]* ) break;;
* ) echo "Please answer Yes or no.";;
esac
done
# Request the user what he want to do
# Execute the file in git during the configuration on the machine
while true; do
echo "What do you want to do?"
read -p "Update & Upgrade | Install | Remove | Search | Transfer | Command | Forensic analysis | Virus Scan | Hardware Information | Backup ? " uirstcfvhb
case $uirstcfvhb in
# Full Update
[Uu]* ) mussh/mussh -a -i ~/.ssh/"$private" -d -H maas-hostfile -C 'update.sh' -m2
break;;
# Search for a package
[Ss]* ) echo "which software are you looking for? "
read soft_search
sed -i "s/soft_search/$soft_search/g" search.sh
chmod +x search.sh
echo "Loading MAAS search please wait "
mussh/mussh -a -i ~/.ssh/"$private" -d -H maas-hostfile -C "search.sh" -m2
break;;
# Install a package
[Ii]* ) echo "which software do you wish to install? "
read soft_install
sed -i "s/soft_install/$soft_install/g" mi.sh
chmod +x mi.sh
echo "Loading MAAS install please wait "
mussh/mussh -a -i ~/.ssh/"$private" -d -H maas-hostfile -C 'mi.sh' -m2
break;;
# Remove a package
[Rr]* ) echo "which software do you wish to remove? "
read soft_remove
sed -i "s/soft_remove/$soft_remove/g" remove.sh
chmod +x remove.sh
echo "Loading MAAS remove please wait "
mussh/mussh -a -i ~/.ssh/"$private" -d -H maas-hostfile -C 'remove.sh' -m2
break;;
# Transfer files to remote host
[Tt]* ) echo "Which file do you wan to sent to remote target?"
read from
echo "Where do you want to sent that file on remote target?"
read to
printf "\033[1;32m%s\nCopying files on remote target\033[0m%s\n"
for target in $(cat maas-hostfile) ; do
rsync -avz "$from" "$target":"$to"
done
break;;
# Load a command
[Cc]* ) echo "which command do you want to load? "
read command_request
echo "Loading MAAS command please wait "
mussh/mussh -a -i ~/.ssh/"$private" -d -H maas-hostfile -c "$command_request" -m2
break;;
# Forensic Scan & Log
[Ff]* ) echo "MAAS will now load FARON - Forensic Analyser Remote Over Network"
mussh/mussh -a -i ~/.ssh/"$private" -d -H maas-hostfile -c 'sh /root/MAAS/faron.sh' -m2
# Get the log back
printf "\033[1;32m\nGetting all logs back ...\033[0m%s\n"
for target in $(cat maas-hostfile) ; do
rsync -avz "$target":~/maas-log*tar.gz ~/MAAS-REPORT/LOG/
done
break;;
# Virus Scan & Log
[Vv]* ) echo "MAAS will now load Virus Scan - Scan, log and report"
mkdir ~/MAAS-REPORT/LOG/
mussh/mussh -a -i ~/.ssh/"$private" -d -H maas-hostfile -C 'virusscan.sh' -m2
# Get the log back
printf "\033[1;32m\nGetting all logs back ...\033[0m%s\n"
for target in $(cat maas-hostfile) ; do
rsync -avz "$target":~/maas-virus-log*tar.gz ~/MAAS-REPORT/LOG/
done
break;;
# Hardware and System Information & Log
[Hh]* ) echo "MAAS will now load The Hardware and System Information Scan - Scan, log and report"
mkdir ~/MAAS-REPORT/LOG/
mussh/mussh -a -i ~/.ssh/"$private" -d -H maas-hostfile -C 'sysinfo.sh' -m2
# Get the log back
printf "\033[1;32m\nGetting all logs back ...\033[0m%s\n"
for target in $(cat maas-hostfile) ; do
rsync -avz "$target":~/maas-sysinfo-log*tar.gz ~/MAAS-REPORT/LOG/
done
break;;
# Encrypted backup
[Bb]* ) printf "MAAS will now load the Backup Encryption and Steganographic \nsolution on your remote target"
mkdir ~/MAAS-REPORT/BACKUP/
# Request the user to create an encrypted key
while true; do
read -p "Do you need to create an encrypted key? Y/n " yn
case $yn in
[Yy]* ) # creating a key
printf "/!\ If you forget your passphrase, the key cannot be used\n and any data encrypted using that key will be lost.\n"
gpg2 --full-gen-key
break;;
[Nn]* ) break;;
* ) echo "Please answer Yes or no.";;
esac
done
# Send the forged key on remote target and load the encryption process
rsync -avz ~/.ssh/"$private" "$target":~/.ssh/
# Request the user wish of backup
echo "which file or directory do you wish to backup and encrypt? "
read soft_backup
sed -i "s/soft_backup/$soft_backup/g" cryptosteg.sh
chmod +x cryptosteg.sh
echo "Loading MAAS search please wait "
mussh/mussh -a -i ~/.ssh/"$private" -d -H maas-hostfile -C "cryptosteg.sh" -m2
# Get the backup back
printf "\033[1;32m\nGetting all logs back ...\033[0m%s\n"
for target in $(cat mass-hostfile) ; do
rsync -avz "$target":~/"$soft_backup".tar.xz ~/MAAS-REPORT/BACKUP/
done
break;;
# request of the correct word / letter
* ) printf "Please answer 'U'pdate/'U'pgrade , 'I'nstall , 'C'ommand , 'F'orensic , 'V'irus scan \n 'H'ardware Information or 'B'ackup.";;
esac
done