1
1
import os
2
+ import json
2
3
import datetime
3
4
4
5
import lib .banner
@@ -48,7 +49,9 @@ class object for the main terminal of the program
48
49
# clean the hosts file of duplicate IP's
49
50
"clean" , "clear" ,
50
51
# easter eggs!
51
- "idkwhatimdoing" , "ethics" , "skid"
52
+ "idkwhatimdoing" , "ethics" , "skid" ,
53
+ # nmap arguments
54
+ "nmap" , "mapper" , "mappy"
52
55
]
53
56
external_terminal_commands = lib .settings .load_external_commands ()
54
57
api_call_pointers = {
@@ -216,9 +219,14 @@ def do_api_search(self, requested_api_data, query, tokens):
216
219
:param query: the query to be searched
217
220
:param tokens: an argument dict that will contain the token information
218
221
222
+ Command Format:
223
+ --------------
224
+ search[/api/gather] API_NAME[API_NAME,...](shodan,censys,zoomeye) QUERY
225
+
219
226
Examples:
220
227
---------
221
- search/api/gather shodan[,censys[,zoomeye]] windows 10
228
+ search shodan,censys,zoomeye windows 10
229
+ search shodan windows 7
222
230
"""
223
231
acceptable_api_names = ("shodan" , "censys" , "zoomeye" )
224
232
api_checker = lambda l : all (i .lower () in acceptable_api_names for i in l )
@@ -320,9 +328,13 @@ def do_add_single_host(self, ip):
320
328
-----------
321
329
:param ip: IP address to be added
322
330
331
+ Command Format:
332
+ --------------
333
+ single IP[,IP,IP,IP,IP,...]
334
+
323
335
Examples:
324
336
---------
325
- single 89.76.12.124[ ,89.76.12.43,89.90.65.78,...]
337
+ single 89.76.12.124,89.76.12.43
326
338
"""
327
339
for item in ip .split ("," ):
328
340
validated_ip = lib .settings .validate_ip_addr (item )
@@ -357,9 +369,13 @@ def do_exploit_targets(self, workspace_info, shodan_token=None):
357
369
-----------
358
370
:param workspace_info: a tuple of workspace information
359
371
372
+ Command Format:
373
+ --------------
374
+ exploit[/run/attack] IP PORT WORKSPACE_NAME [whitewash list]
375
+
360
376
Examples:
361
377
---------
362
- exploit/run/attack 127.0.0.1 9065 default [whitewash list]
378
+ exploit 127.0.0.1 9065 default whitelist.txt
363
379
"""
364
380
if workspace_info [3 ] is not None and workspace_info [3 ] != "honeycheck" :
365
381
lib .output .misc_info ("doing whitewash on hosts file" )
@@ -420,9 +436,13 @@ def do_load_custom_hosts(self, file_path):
420
436
-----------
421
437
:param file_path: the full path to the loadable hosts file
422
438
439
+ Command Format:
440
+ --------------
441
+ custom[/personal] FILE_PATH
442
+
423
443
Examples:
424
444
---------
425
- custom/personal /some/path/to/myfile.txt
445
+ custom /some/path/to/myfile.txt
426
446
"""
427
447
import shutil
428
448
@@ -437,7 +457,57 @@ def do_load_custom_hosts(self, file_path):
437
457
lib .output .info ("host file replaced, backup stored under '{}'" .format (backup_path ))
438
458
self .loaded_hosts = open (lib .settings .HOST_FILE ).readlines ()
439
459
460
+ def do_nmap_scan (self , target , arguments ):
461
+ """
462
+ Explanation:
463
+ -----------
464
+ Perform a nmap scan on a provided target, given that nmap is on your system.
465
+ If nmap is not on your system, this will not work, you may also provide
466
+ arguments known to nmap.
467
+
468
+ Parameters:
469
+ ----------
470
+ :param target: the target to attack
471
+ :param arguments: a string of arguments separated by a comma
472
+
473
+ Command Format:
474
+ --------------
475
+ nmap[/mapper/mappy] TARGET [ARGUMENTS]
476
+
477
+ Examples:
478
+ --------
479
+ nmap/mapper/mappy 10.0.1.1 -sV,--dns-servers 1.1.1.1,--reason,-A
480
+ nmap 10.0.1.1/24
481
+ """
482
+ import lib .scanner .nmap
483
+
484
+ sep = "-" * 30
485
+ if arguments is not None :
486
+ arguments = arguments .split ("," )
487
+ passable_arguments = lib .scanner .nmap .parse_nmap_args (arguments )
488
+ else :
489
+ passable_arguments = None
490
+ try :
491
+ nmap_path = lib .scanner .nmap .find_nmap (lib .settings .NMAP_POSSIBLE_PATHS )
492
+ except lib .errors .NmapNotFoundException :
493
+ nmap_path = None
494
+ lib .output .error ("nmap was not found on your system please install nmap first" )
495
+ return
496
+ lib .output .info ("performing nmap scan on {}" .format (target ))
497
+ try :
498
+ output , warnings , errors = lib .scanner .nmap .do_scan (target , nmap_path , arguments = passable_arguments )
499
+ formatted_results_output = lib .scanner .nmap .parse_xml_output (output , warnings , errors )
500
+ save_file = lib .scanner .nmap .write_data (target , formatted_results_output , is_xml = False )
501
+ lib .output .misc_info ("JSON data dumped to file: '{}'" .format (save_file ))
502
+ print ("{sep}\n {data}\n {sep}" .format (
503
+ data = json .dumps (formatted_results_output ["nmap_scan" ][target ], indent = 4 ), sep = sep
504
+ ))
505
+ except lib .errors .NmapScannerError as e :
506
+ lib .output .error (str (e ).strip ())
507
+
440
508
def terminal_main_display (self , tokens , extra_commands = None , save_history = True ):
509
+ # idk what the fuck the problem is but this seems to fix it so...
510
+ import lib .output
441
511
"""
442
512
terminal main display
443
513
"""
@@ -502,7 +572,7 @@ def terminal_main_display(self, tokens, extra_commands=None, save_history=True):
502
572
self .do_quit_terminal (save_history = save_history )
503
573
elif any (c in choice for c in ("view" , "show" )):
504
574
self .do_view_gathered ()
505
- elif any (c in choice for c in ("ver" , " version" )):
575
+ elif any (c in choice for c in ("version" , )):
506
576
self .do_show_version_number ()
507
577
elif any (c in choice for c in ("clean" , "clear" )):
508
578
self .do_clean_hosts ()
@@ -625,9 +695,54 @@ def terminal_main_display(self, tokens, extra_commands=None, save_history=True):
625
695
self .do_token_reset (api , token , username )
626
696
else :
627
697
lib .output .error ("cannot reset {} API credentials" .format (choice ))
698
+ elif any (c in choice for c in ["nmap" , "mapper" , "mappy" ]):
699
+ try :
700
+ if "help" in choice_data_list :
701
+ print (self .do_nmap_scan .__doc__ )
702
+ except TypeError :
703
+ pass
704
+ target = choice_data_list [1 ]
705
+ try :
706
+ arguments = choice_data_list [2 ]
707
+ lib .output .warning (
708
+ "arguments that have a space in them most likely will not be processed correctly, "
709
+ "(IE --dns-servers 1.1.1.1 will most likely cause issues)"
710
+ )
711
+ except IndexError :
712
+ arguments = None
713
+ # don't know how im going to implement ports yet
714
+ # try:
715
+ # ports = choice_data_list[3]
716
+ # except IndexError:
717
+ # ports = None
718
+
719
+ self .do_nmap_scan (target , arguments )
628
720
self .history .append (choice )
629
721
self .__reload ()
630
722
except KeyboardInterrupt :
631
723
lib .output .warning ("use the `exit/quit` command to end terminal session" )
632
724
except IndexError :
633
- pass
725
+ pass
726
+ except Exception as e :
727
+ global stop_animation
728
+
729
+ stop_animation = True
730
+
731
+ import sys
732
+ import traceback
733
+ import lib .creation .issue_creator
734
+
735
+ print (
736
+ "\033 [31m[!] AutoSploit has hit an unhandled exception: '{}', "
737
+ "in order for the developers to troubleshoot and repair the "
738
+ "issue AutoSploit will need to gather your OS information, "
739
+ "current arguments, the error message, and a traceback. "
740
+ "None of this information can be used to identify you in any way\033 [0m" .format (str (e ))
741
+ )
742
+ error_traceback = '' .join (traceback .format_tb (sys .exc_info ()[2 ]))
743
+ error_class = str (e .__class__ ).split (" " )[1 ].split ("." )[1 ].strip (">" ).strip ("'" )
744
+ error_file = lib .settings .save_error_to_file (str (error_traceback ), str (e ), error_class )
745
+ lib .creation .issue_creator .request_issue_creation (error_file , lib .creation .issue_creator .hide_sensitive (), str (e ))
746
+ lib .output .info ("continuing terminal session" )
747
+ # this way if you're in the terminal already we won't quit out of it
748
+ continue
0 commit comments