-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathhackgame.sh
executable file
·347 lines (315 loc) · 12.1 KB
/
hackgame.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
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
#!/bin/bash
#
# Demonstration for Schools
#
# author Ruth Lee
# version 2.0
# date 02.02.2016
# email [email protected]
#
r='\033[31m'
w='\033[0m'
g='\033[32m'
b='\033[34m'
trap "echo -e ""; echo -e \"$w Recieved a request to terminate. Goodbye and good luck.\"; exit" SIGINT SIGTERM
OPTS=$(getopt -o h --long help -- "$@")
eval set -- "$OPTS"
while true; do
case "$1" in
-h|--help)
echo "An interactive script for kids. No flags needed"
exit 1;;
*) break ;;
esac
done
function intro {
echo -e $g"Logging in..."
echo ""
sleep 1
cat << "EOF"
.-;+$XHHHHHHX$+;-.
,;X@@X%/;=----=:/%X@@X/
=$@@%=. .=+H@X:
-XMX: =XMX=
/@@: =H@+
%@X, .$@$
+@X. $@%
-@@, .@@=
%@% +@$
H@: :@H
H@: :HHHHHHHHHHHHHHHHHHX, =@H
%@% ;@M@@@@@@@@@@@@@@@@@H- +@$
=@@, :@@@@@@@@@@@@@@@@@@@@@= .@@:
+@X :@@@@@@@@@@@@@@@M@@@@@@:%@%
$@$, ;@@@@@@@@@@@@@@@@@M@@@@@@$.
+@@HHHHHHH@@@@@@@@@@@@@@@@@@@@@@@+
=X@@@@@@@@@@@@@@@@@@@@@@@@@@@@X=
:$@@@@@@@@@@@@@@@@@@@M@@@@$:
,;$@@@@@@@@@@@@@@@@@@X/-
.-;+$XXHHHHHX$+;-.
BLACK MESA INC
*********************************************************************************
This is a BLACK MESA Computer System. This computer system,
including all related equipment, networks, and network devices, are provided only for authorised use.
Use of this computer system, authorised or unauthorised, constitutes consent to monitoring of this
system. Evidence collected during monitoring may be used for administrative, criminal, or other
adverse action including disclosure BLACK MESA personnel, Aperture Laboratories personnel,
authorised officials of other agencies, both domestic and foreign. Use of this
system constitutes consent to monitoring for these purposes.
LOG OFF IMMEDIATELY if you do not agree to the conditions stated in this warning.
*********************************************************************************
EOF
sleep 1
echo ""
sleep 1
echo ""
sleep 1
echo -e $w"\n\nHello, welcome to Black Mesa. Black Mesa is a leader in scientific research. Recently, one of our smaller divisions had plans for a new device stolen from them. This prototype, the Aperture Science Portable Quantum Tunneling Device (Codename: Portal Gun) is vital to our future research. We need you to break into the systems of the culprits, a hacktivist group called 'anonymous' and re-obtain these plans. You should have all the tools you need at your disposal to do so. Pick the right command for the job and enter it at the prompt. All hints will be shown in white text like this. Are you ready to begin?"$g
echo ""
read -p "[Y/N]: " INPUT
if [[ ${INPUT} == "N" ]]; then
echo "Oh dear better log out now then!"
exit 1;
else [[ ${INPUT} == "Y" ]];
echo "You have accepted the job. Good luck."
echo ""
fi
}
function port_scan {
echo -e $w"First we need to find our target, there's lots of computer systems out there in the wild, so we need to make sure we have the correct one. Be sure to note down the IP address!"$g
SUCCESS=0
while [[ ${SUCCESS} == 0 ]]; do
read -p "neo@torvalds:~$: " INPUT
if [[ ${INPUT} =~ "nmap" ]]; then
echo -e "Initializing"
sleep 2
bar="."
counter=0
echo -n "[scanning] ${bar}"
while [ ${counter} -lt 15 ]
do
counter=$((counter+1))
for i in "${bar}"
do
echo -ne "$i"
sleep 0.2
done
done
echo -e " done \n"
sleep 1
echo -e "\n Hosts identified"
sleep 2
echo -e " \n Hostname: www.google.com \n IP: 8.8.8.8 \n \n Hostname: www.anonserver.com \n IP: 162.141.131.11 \n\n Hostname: www.lara-c-home-pc.com \n IP: 5.79.28.110 \n "
SUCCESS=1
else
echo -e "That doesn't seem right, try a different command or check your spelling"
fi
done
}
function bruteforce {
echo -e $w"\nNow we know what's out there we need to somehow get the login details for the correct server.\n"$g
SUCCESS=0
while [[ ${SUCCESS} == 0 ]]; do
read -p "neo@torvalds:~$: " INPUT
if [[ ${INPUT} =~ "bruteforce 162.141.131.11" ]]; then
echo "Attempting to bruteforce host 162.141.131.11"
echo "Generating possible usernames"
sleep 1
echo "Running algorithms"
sleep 1
max=10
printf "Cracking ["
tput sc
i=0
while [[ ${i} -le ${max} ]];do
j=0
while [[ ${j} -le ${i} ]];do
echo -n "#"
let j=${j}+1
done
printf "%-$((${max}-${i}))s] $(((${i})*100/${max}))%%"
tput rc
sleep 1
let i=${i}+1
done
echo
echo "Complete"
sleep 1
echo -e "\nSuccess! \n\n Credentials \n -------------- \n username: root \n password: calvin \n --------------"
SUCCESS=1
else
if [[ ${INPUT} == "bruteforce" ]]; then
echo "You'll need to provide a computer system to bruteforce, try adding an IP address to the end of the command";
elif [[ ${INPUT} =~ "bruteforce 8" ]]; then
echo -e $r"Warning! Attempting to bruteforce Google's servers will result in criminal charges being pressed. Your IP address has been logged."$g
elif
[[ ${INPUT} =~ "bruteforce 5" ]]; then
echo -e $r"This is a private computer belonging to the Croft family. Attempting to bruteforce it may leave you on the business end of a bow and arrow."$g
else
echo "That doesn't seem right, try a different command or check your spelling."
fi
fi
done
}
function login {
echo -e $w"Great, we've cracked the credentials. Let's login to that server now."$g
SUCCESS=0
while [[ ${SUCCESS} == 0 ]]; do
read -p "neo@torvalds:~$: " INPUT
if [[ ${INPUT} =~ "ssh [email protected]" ]]; then
while [[ ${SUCCESS} == 0 ]]; do
read -p "[email protected]'s password: " INPUT
if [[ ${INPUT} =~ "calvin" ]]; then
echo -e "Password accepted. \n"
sleep 2
cat << "EOF"
******************************************************************************************************
______ __ __ ______ __ __ __ __ __ __ ______ __ __ ______
/\ __ \ /\ "-.\ \ /\ __ \ /\ "-.\ \ /\ \_\ \ /\ "-./ \ /\ __ \ /\ \/\ \ /\ ___\
\ \ __ \ \ \ \-. \ \ \ \/\ \ \ \ \-. \ \ \____ \ \ \ \-./\ \ \ \ \/\ \ \ \ \_\ \ \ \___ \
\ \_\ \_\ \ \_\\"\_\ \ \_____\ \ \_\\"\_\ \/\_____\ \ \_\ \ \_\ \ \_____\ \ \_____\ \/\_____\
\/_/\/_/ \/_/ \/_/ \/_____/ \/_/ \/_/ \/_____/ \/_/ \/_/ \/_____/ \/_____/ \/_____/
******************************************************************************************************
People shouldn't be afraid of their government. Governments should be afraid of their people.
EOF
echo ""
echo -e "Welcome to Anonymous Node 1\nYou are logged in as root"
SUCCESS=1
sleep 2
else
echo -e "Incorrect password, try again"
fi
done
elif [[ ${INPUT} =~ "ssh" ]]; then
echo "You might be missing some parts of this command, try ssh <username>@<IP address>"
else
echo "That doesn't seem right, try a different command or check your spelling"
fi
done
}
function directory {
echo -e $w"\n\nLet's see what directories are on the server!"$g
SUCCESS=0
while [[ ${SUCCESS} == 0 ]]; do
read -p "root@anonserver:~$: " INPUT
if [[ ${INPUT} =~ "ls" ]]; then
echo -e "\nhome \nsystem \nplans \n"
echo ""
echo -e $w"Okay, now we need to pick the right directory and navigate into it."$g
while [[ ${SUCCESS} == 0 ]]; do
read -p "root@anonserver:~$: " INPUT
if [[ ${INPUT} =~ "cd plans" ]]; then
echo -e "\nBank-heist-2010 \nEquipment-list \nPortal-Gun-Blueprints \n"
SUCCESS=1
elif [[ ${INPUT} =~ "cd home" ]]; then
echo "This directory is empty, try another"
elif [[ ${INPUT} =~ "cd system" ]]; then
echo "You do not have permission to access this directory"
else
echo "That doesn't seem right, try a different command or check your spelling"
fi
done
else
echo "That doesn't seem right, try a different command or check your spelling"
fi
done
}
function copy_file {
echo -e $w"Looks like we found the plans! Now we need to copy them over to our own server. Remember, your home server is called 'torvalds'"$g
SUCCESS=0
while [[ ${SUCCESS} == 0 ]]; do
read -p "root@anonserver:~$: " INPUT
if [[ ${INPUT} =~ "scp -file Portal-Gun-Blueprints -dest torvalds" ]]; then
echo -e "\nCopying file"
sleep 1
echo -e "Success: Portal-Gun-Blueprints copied to torvalds\n"
SUCCESS=1
elif [[ ${INPUT} =~ "scp " ]]; then
echo "That might not be the right format or you might be using the wrong filename or destination. Try scp -file <filename> -dest <destination>"
else
echo "That doesn't seem right, try a different command or check your spelling"
fi
done
}
function remove_logs {
echo -e $w"Great work, we have the file. The last step is to erase our tracks. The log we want to delete is called /var/log/secure"$g
SUCCESS=0
while [[ ${SUCCESS} == 0 ]]; do
read -p "root@anonserver:~$: " INPUT
if [[ ${INPUT} =~ "rm /var/log/secure" ]]; then
echo -e "\nErasing logs"
sleep 1
echo -e "Success\n"
sleep 1
echo -e "Logging out of system\n"
sleep 4
echo -e "anon-server: Goodbye\n"
SUCCESS=1
elif [[ ${INPUT} =~ "rm" ]]; then
echo "That might not be the right format, try rm <file location>"
else
echo "That doesn't seem right, try a different command or check your spelling"
fi
done
}
function outro {
echo -e "Logging in..."
echo ""
sleep 1
cat << "EOF"
.-;+$XHHHHHHX$+;-.
,;X@@X%/;=----=:/%X@@X/
=$@@%=. .=+H@X:
-XMX: =XMX=
/@@: =H@+
%@X, .$@$
+@X. $@%
-@@, .@@=
%@% +@$
H@: :@H
H@: :HHHHHHHHHHHHHHHHHHX, =@H
%@% ;@M@@@@@@@@@@@@@@@@@H- +@$
=@@, :@@@@@@@@@@@@@@@@@@@@@= .@@:
+@X :@@@@@@@@@@@@@@@M@@@@@@:%@%
$@$, ;@@@@@@@@@@@@@@@@@M@@@@@@$.
+@@HHHHHHH@@@@@@@@@@@@@@@@@@@@@@@+
=X@@@@@@@@@@@@@@@@@@@@@@@@@@@@X=
:$@@@@@@@@@@@@@@@@@@@M@@@@$:
,;$@@@@@@@@@@@@@@@@@@X/-
.-;+$XXHHHHHX$+;-.
BLACK MESA INC
*********************************************************************************
This is a BLACK MESA Computer System. This computer system,
including all related equipment, networks, and network devices, are provided only for authorised use.
Use of this computer system, authorised or unauthorised, constitutes consent to monitoring of this
system. Evidence collected during monitoring may be used for administrative, criminal, or other
adverse action including disclosure BLACK MESA personnel, Aperture Laboratories personnel,
authorised officials of other agencies, both domestic and foreign. Use of this
system constitutes consent to monitoring for these purposes.
LOG OFF IMMEDIATELY if you do not agree to the conditions stated in this warning.
*********************************************************************************
EOF
sleep 1
echo ""
sleep 1
echo ""
echo -e "torvalds: Welcome to the server\nYou're logged in as Neo\n \n"
echo -e "One file changed since login: New file - Portal-Gun-Blueprints"
sleep 5
echo -e $w"\nYou've successfully liberated the plans from Anonymous' server. Black Mesa will now be able to proceed with developeing our Genetic Lifeform and Disk Operating System (GLaDOS)."
sleep 5
echo -e "\nAll the steps you have taken are a simplified version of how many hackers access and copy confidential data\n"
sleep 3
echo -e "\nIf you've enjoyed this we encourage you to check out games such as Uplink and Hacknet and to explore Linux further\n\n"
echo -e ""
sleep 5
}
intro
port_scan
bruteforce
login
directory
copy_file
remove_logs
outro
exit 1