-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
484 lines (363 loc) · 9.09 KB
/
main.py
File metadata and controls
484 lines (363 loc) · 9.09 KB
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
import os, sys, time, datetime
from pyfiglet import Figlet
from traceroute import trct
from portscan import rhost
from BandWidthServerSide import bwss
from BandWidthClientSide import bwcs
from iperfS import SSideD
from iperfS import SSideC
from iperfS import CSideD
from iperfS import CSideC
#############################################
# TEMPLATE
#############################################
def template():
f = Figlet(font='epic')
g = Figlet(font='straight')
os.system('clear')
print f.renderText('Dam Script')
print g.renderText('Coded by D4m3')
print ('Automated Monitoring Tool')
print ('')
#############################################
# SYTEM MONITOR
#############################################
def glanceMod():
try:
template()
print("\n --- Sytem Monitor ---")
print('\n Chose one option ')
print("\n [1] Start Local Monitoring\n [2] Start WebServer Monitoring\n [3] Back to Menu")
inp = raw_input("\n ---> ")
if inp == '1':
try:
os.system('clear')
template()
print("Loading")
time.sleep(1)
os.system('clear')
template()
print("Loading.")
time.sleep(1)
os.system('clear')
template()
print("Loading..")
time.sleep(1)
os.system('clear')
template()
print("Loading...")
os.system('glances')
except KeyboardInterrupt:
glanceMod()
elif inp == '2':
try:
os.system('clear')
template()
print("Loading")
time.sleep(1)
os.system('clear')
template()
print("Loading.")
time.sleep(1)
os.system('clear')
template()
print("Loading..")
time.sleep(1)
os.system('clear')
template()
print("Loading...")
os.system("clear")
template()
print("Initializing")
print("")
os.system('glances -w')
except KeyboardInterrupt:
glanceMod()
elif inp == '3':
main()
else:
print(" Invalid input..")
time.sleep(2)
glanceMod()
except KeyboardInterrupt:
glanceMod()
#############################################
# NETWORK MON
#############################################
def iftop():
try:
template()
print("\n ---Network Monitor---")
print("\n Chose the interface ")
print("\n [1] Wlan0\n [2] Eth0\n [3] Back to Menu")
inp = raw_input("\n ---> ")
if inp == '1':
os.system('sudo iftop -i wlan0')
elif inp == '2':
os.system('sudo iftop -i eth0')
elif inp == '3':
main()
else:
print(" Invalid input..")
time.sleep(2)
iftop()
main()
except KeyboardInterrupt:
iftop()
#############################################
# IPERF MODULES
#############################################
def iperfServer():
try:
template()
print("\n [1] Default Options\n [2] Custom Options\n [3] Go Back")
inp = raw_input("\n ---> ")
if inp == '1':
try:
SSideD()
except KeyboardInterrupt:
print("\n Press 'q' to exit")
inp = raw_input("\n ---> ")
if inp == 'q':
iperfMain()
else:
print(" Invalid input..")
time.sleep(2)
iperfMain()
elif inp == '2':
try:
SSideC()
except KeyboardInterrupt:
print("\n Press 'q' to exi")
inp = raw_input("\n ---> ")
if inp == 'q':
iperfMain()
else:
print(" Invalid input..")
time.sleep(2)
iperfMain()
elif inp == '3':
iperfMain()
else:
print(" Invalid input..")
time.sleep(2)
iperfServer()
except KeyboardInterrupt:
iperfServer()
def iperfClient():
try:
template()
print("\n [1] Default Options\n [2] Custom Options\n [3] Go Back")
inp = raw_input("\n ---> ")
if inp == '1':
try:
CSideD()
except KeyboardInterrupt:
print("\n Press 'q' to exi")
inp = raw_input("\n ---> ")
if inp == 'q':
iperfMain()
else:
print(" Invalid input..")
time.sleep(2)
iperfMain()
elif inp == '2':
try:
CSideC()
except KeyboardInterrupt:
print("\n Press 'q' to exi")
inp = raw_input("\n ---> ")
if inp == 'q':
iperfMain()
else:
print(" Invalid input..")
time.sleep(2)
iperfMain()
elif inp == '3':
iperfMain()
else:
print(" Invalid input..")
time.sleep(2)
iperfServer()
except KeyboardInterrupt:
iperfClient()
def iperfMain():
try:
template()
print("\n --- Iperf ---")
print('\n Chose one option ')
print("\n [1] Server Side\n [2] Client Side\n [3] Back to Menu")
inp = raw_input("\n ---> ")
if inp == '1': #Server Side
iperfServer()
elif inp == '2': #Client Side
iperfClient()
elif inp == '3':
main()
else:
print(" Invalid input..")
time.sleep(2)
iperfMain()
except KeyboardInterrupt:
iperfMain()
#############################################
# TRACEROUTE MODULE
#############################################
def tracer():
try:
template()
print("\n --- Traceroute ---")
print('\n Chose one option ')
print("\n [1] Launch Traceroute\n [2] Back to Menu")
inp = raw_input("\n ---> ")
if inp == '1':
template()
print("\n --- Traceroute ---")
print("")
trct()
print("\nPress 'q' to go back to main menu...")
inp2 = raw_input("\n ---> ")
if inp2 == 'q':
main()
else:
print(' Invalid input..')
time.sleep(2)
tracer()
elif inp == '2':
main()
else:
print(" Invalid input..")
time.sleep(2)
tracer()
except KeyboardInterrupt:
tracer()
#############################################
# PORT SCANNER MODULE
#############################################
def PortScanner():
try:
template()
print("\n ---Port Scanner---")
print("\n Chose one options")
print("\n [1] Launch Port Scanner\n [2] Back to Menu")
inp = raw_input("\n ---> ")
if inp == '1':
template()
print("\n ---Port Scanner---")
rhost()
print("\nPress 't' to lauch Scanner again, and 'q' to go back to main menu...")
inp = raw_input("\n ---> ")
if inp == 'q':
main()
elif inp == 't':
PortScanner()
else:
print(" Invalid input..")
time.sleep(2)
PortScanner()
elif inp == '2':
main()
else:
print(" Invalid input..")
time.sleep(2)
PortScanner()
except KeyboardInterrupt:
PortScanner()
#############################################
# BANDWIDTH TEST MODULE
#############################################
def bandwidth():
try:
template()
print("\n ---Bandwidth Test---")
print("\n Chose one options")
print("\n [1] Start Server Side\n [2] Start Client Side\n [3] Help\n [4] Back to Menu")
inp = raw_input("\n ---> ")
if inp == '1':
template()
print("\n ---Bandwidth Test---")
bwss()
elif inp == '2':
template()
print("\n ---Bandwidth Test---")
bwcs()
elif inp == '3':
def bandwidthHelp():
template()
print("\n ---Bandwidth Test---")
print("\n In order for you test the Bandwidth")
print("you need to start the server side in a machine")
print("and the client side in a difrent machine!")
print("\n If you want to download one of the scripts needed to run this test")
print("use the comand 'wget https://raw.githubusercontent.com/D4m666/Dam-Script/main/BandWidthServerSide.py' for the server side")
print("or 'wget https://raw.githubusercontent.com/D4m666/Dam-Script/main/BandWidthClientSide.py' for client side ")
print("Press 'q' to go back to main menu...")
inp = raw_input("\n ---> ")
if inp == 'q':
bandwidth()
else:
print(" Invalid input..")
time.sleep(2)
bandwidthHelp()
bandwidthHelp()
elif inp == '4':
main()
else:
print(" Invalid input..")
time.sleep(2)
bandwidth()
except KeyboardInterrupt:
bandwidth()
#############################################
# CREDITS
#############################################
def Credits():
try:
template()
print("The creatr of Dam Script is not reponsible for any of your activities while using the script!")
print("This Script is meant to help you monitor your machine and keep track of any problems it might have.")
print("\n Press 'q' to go back to main menu...")
inp = raw_input("\n ---> ")
if inp == 'q':
main()
else:
print(" Invalid input..")
time.sleep(2)
Credits()
except KeyboardInterrupt:
Credits()
#############################################
# MAIN
#############################################
def main():
try:
template()
print(" Where do you wanna go")
print("\n [1] System Monitor\n [2] Network Monitor\n [3] PortScanner\n [4] Traceroute\n [5] Bandwidth Test\n [6] Iperf Test\n [7] Credits\n [8] Quit")
question = raw_input("\n ---> ")
if question == '1':
glanceMod()
elif question == '2':
iftop()
elif question == '3':
PortScanner()
elif question == '4':
tracer()
elif question == '5':
bandwidth()
elif question == '6':
iperfMain()
elif question == '7':
Credits()
elif question == '8':
print(" Closing..")
time.sleep(2)
sys.exit()
else:
print(" Invalid input..")
time.sleep(2)
main()
except KeyboardInterrupt:
os.system('clear')
quit()
main()