2929
3030from lib .jsonize import load_exploits
3131from lib .cmdline .cmd import AutoSploitParser
32+ from lib .banner import banner_main
3233from lib .settings import (
3334 validate_ip_addr ,
35+ check_services ,
3436 PLATFORM_PROMPT ,
35- AUTOSPLOIT_PROMPT
37+ AUTOSPLOIT_PROMPT ,
38+ AUTOSPLOIT_TERM_OPTS
3639)
3740from lib .output import (
3841 info ,
5053local_host = ""
5154configured = False
5255toolbar_width = 60
53- version = "1.4.0"
5456usage_and_legal_path = "{}/etc/general" .format (os .getcwd ())
5557loaded_exploits = load_exploits ("{}/etc/json" .format (os .getcwd ()))
5658stop_animation = False
57- autosploit_opts = {
58- 1 : "usage and legal" , 2 : "gather hosts" , 3 : "custom hosts" ,
59- 4 : "add single host" , 5 : "view gathered hosts" , 6 : "exploit gathered hosts" ,
60- 99 : "quit"
61- }
6259
6360
6461def logo (line_sep = "#--" , space = " " * 30 ):
6562 """Logo."""
66- global version
67- print ("""\033 [1m\033 [36m{space_sep}_____ _ _____ _ _ _
68- {sep1}Author : Vector/NullArray | _ |_ _| |_ ___| __|___| |___|_| |_
69- {sep1}Twitter: @Real__Vector | | | | _| . |__ | . | | . | | _|
70- {sep1}Type : Mass Exploiter |__|__|___|_| |___|_____| _|_|___|_|_|
71- {sep1}Version: {v_num} |_|
72- ##############################################\033 [0m
73- """ .format (sep1 = line_sep , v_num = version , space_sep = space ))
63+ print banner_main ()
7464
7565
7666def animation (text ):
@@ -428,7 +418,6 @@ def main():
428418 global query
429419 global configured
430420 global api
431- global autosploit_opts
432421
433422 # TODO:/
434423 # commenting this out for now, guessing we need to create a retry function
@@ -453,8 +442,8 @@ def try_shodan():
453442 settings ()
454443
455444 info ("Welcome to AutoSploit. Please select an action." )
456- for i in autosploit_opts .keys ():
457- print ("{}. {}" .format (i , autosploit_opts [i ].title ()))
445+ for i in AUTOSPLOIT_TERM_OPTS .keys ():
446+ print ("{}. {}" .format (i , AUTOSPLOIT_TERM_OPTS [i ].title ()))
458447
459448 action = raw_input (AUTOSPLOIT_PROMPT )
460449
@@ -568,37 +557,46 @@ def try_shodan():
568557 info ("Initializing AutoSploit..." )
569558 info ("One moment please while we check the Postgresql and Apache services..." )
570559
571- postgresql = cmdline ("sudo service postgresql status | grep active" )
572- if "Active: inactive" in postgresql :
573- warning ("Warning. Heuristic tests have indicated PostgreSQL Service is offline" )
560+ # postgresql = cmdline("sudo service postgresql status | grep active")
561+ postgresql = check_services ("postgre" )
562+ if not postgresql :
563+
564+ def start_postgresql ():
565+ # we're going to import it here because we don't need it anywhere else
566+ from lib .settings import START_POSTGRESQL_PATH
574567
568+ cmd = shlex .split ("sudo sh {}" .format (START_POSTGRESQL_PATH ))
569+ cmdline (cmd )
570+
571+ warning ("Warning. Heuristic tests have indicated PostgreSQL Service is offline" )
575572 start_pst = prompt ("Start Postgresql Service? [Y]es/[N]o" )
576573 if start_pst == 'y' :
577- os .system ("sudo service postgresql start" )
578- info ("Postgresql Service Started..." )
579- time .sleep (1.5 )
580-
574+ start_postgresql ()
581575 elif start_pst == 'n' :
582576 error ("AutoSploit's MSF related operations require this service to be active." )
583577 error ("Aborted." )
584578 time .sleep (1.5 )
585579 sys .exit (0 )
586580 else :
587581 warning ("Unhandled Option. Defaulting to starting the service." )
588- os .system ("sudo service postgresql start" )
589-
590- info ("Postgresql Service Started..." )
582+ start_postgresql ()
591583 time .sleep (1.5 )
592584
593- apache = cmdline ("service apache2 status | grep active" )
594- if "Active: inactive" in apache :
585+ apache = check_services ("apache2" )
586+ if not apache :
587+
588+ def start_apache ():
589+ # same as above
590+ from lib .settings import START_APACHE_PATH
591+
592+ cmd = shlex .split ("sudo sh {}" .format (START_APACHE_PATH ))
593+ cmdline (cmd )
594+
595595 warning ("Warning. Heruistic tests indicated that Apache Service is offline" )
596596
597597 start_ap = prompt ("Start Apache Service? [Y]es/[N]o" )
598598 if start_ap == 'y' :
599- os .system ("sudo service apache2 start" )
600-
601- info ("[{}]Apache2 Service Started..." )
599+ start_apache ()
602600 time .sleep (1.5 )
603601
604602 elif start_ap == 'n' :
@@ -608,12 +606,7 @@ def try_shodan():
608606 sys .exit (0 )
609607 else :
610608 warning ("Unhandled Option. Defaulting to starting the service." )
611- os .system ("sudo service apache2 start" )
612- # TODO:/
613- # Should really add another check here to make sure it started,
614- # possible to use `psutils` to check the running tasks for autosploit
615-
616- info ("Apache2 Service Started..." )
609+ start_apache ()
617610 time .sleep (1.5 )
618611
619612 # We will check if the shodan api key has been saved before, if not we are going to prompt
@@ -636,4 +629,4 @@ def try_shodan():
636629 path = os .path .abspath ("api.p" )
637630 info ("Your API key was loaded from {}" .format (path ))
638631
639- main ()
632+ main ()
0 commit comments