|
6 | 6 |
|
7 | 7 | from lib.cmdline.cmd import AutoSploitParser |
8 | 8 | from lib.term.terminal import AutoSploitTerminal |
| 9 | +from lib.creation.issue_creator import ( |
| 10 | + request_issue_creation, |
| 11 | + hide_sensitive |
| 12 | +) |
9 | 13 | from lib.output import ( |
10 | 14 | info, |
11 | 15 | warning, |
|
19 | 23 | cmdline, |
20 | 24 | close, |
21 | 25 | EXPLOIT_FILES_PATH, |
22 | | - START_SERVICES_PATH |
| 26 | + START_SERVICES_PATH, |
| 27 | + save_error_to_file, |
23 | 28 | ) |
24 | 29 | from lib.jsonize import ( |
25 | 30 | load_exploits, |
|
28 | 33 |
|
29 | 34 |
|
30 | 35 | def main(): |
31 | | - |
32 | 36 | try: |
33 | | - is_admin = os.getuid() == 0 |
34 | | - except AttributeError: |
35 | | - # we'll make it cross platform because it seems like a cool idea |
36 | | - is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0 |
37 | 37 |
|
38 | | - if not is_admin: |
39 | | - close("must have admin privileges to run") |
| 38 | + try: |
| 39 | + is_admin = os.getuid() == 0 |
| 40 | + except AttributeError: |
| 41 | + # we'll make it cross platform because it seems like a cool idea |
| 42 | + is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0 |
40 | 43 |
|
41 | | - opts = AutoSploitParser().optparser() |
| 44 | + if not is_admin: |
| 45 | + close("must have admin privileges to run") |
42 | 46 |
|
43 | | - logo() |
44 | | - info("welcome to autosploit, give us a little bit while we configure") |
45 | | - misc_info("checking your running platform") |
46 | | - platform_running = platform.system() |
47 | | - misc_info("checking for disabled services") |
48 | | - # according to ps aux, postgre and apache2 are the names of the services on Linux systems |
49 | | - service_names = ("postgres", "apache2") |
50 | | - if "darwin" in platform_running.lower(): |
51 | | - service_names = ("postgres", "apachectl") |
| 47 | + opts = AutoSploitParser().optparser() |
52 | 48 |
|
53 | | - for service in list(service_names): |
54 | | - while not check_services(service): |
55 | | - choice = prompt( |
56 | | - "it appears that service {} is not enabled, would you like us to enable it for you[y/N]".format( |
57 | | - service.title() |
58 | | - ) |
59 | | - ) |
60 | | - if choice.lower().startswith("y"): |
61 | | - try: |
62 | | - if "darwin" in platform_running.lower(): |
63 | | - cmdline("{} darwin".format(START_SERVICES_PATH)) |
64 | | - elif "linux" in platform_running.lower(): |
65 | | - cmdline("{} linux".format(START_SERVICES_PATH)) |
66 | | - else: |
67 | | - close("your platform is not supported by AutoSploit at this time", status=2) |
| 49 | + logo() |
| 50 | + info("welcome to autosploit, give us a little bit while we configure") |
| 51 | + misc_info("checking your running platform") |
| 52 | + platform_running = platform.system() |
| 53 | + misc_info("checking for disabled services") |
| 54 | + # according to ps aux, postgre and apache2 are the names of the services on Linux systems |
| 55 | + service_names = ("postgres", "apache2") |
| 56 | + if "darwin" in platform_running.lower(): |
| 57 | + service_names = ("postgres", "apachectl") |
68 | 58 |
|
69 | | - # moving this back because it was funky to see it each run |
70 | | - info("services started successfully") |
71 | | - # this tends to show up when trying to start the services |
72 | | - # I'm not entirely sure why, but this fixes it |
73 | | - except psutil.NoSuchProcess: |
74 | | - pass |
75 | | - else: |
76 | | - process_start_command = "`sudo service {} start`" |
77 | | - if "darwin" in platform_running.lower(): |
78 | | - process_start_command = "`brew services start {}`" |
79 | | - close( |
80 | | - "service {} is required to be started for autosploit to run successfully (you can do it manually " |
81 | | - "by using the command {}), exiting".format( |
82 | | - service.title(), process_start_command.format(service) |
| 59 | + for service in list(service_names): |
| 60 | + while not check_services(service): |
| 61 | + choice = prompt( |
| 62 | + "it appears that service {} is not enabled, would you like us to enable it for you[y/N]".format( |
| 63 | + service.title() |
83 | 64 | ) |
84 | 65 | ) |
| 66 | + if choice.lower().startswith("y"): |
| 67 | + try: |
| 68 | + if "darwin" in platform_running.lower(): |
| 69 | + cmdline("{} darwin".format(START_SERVICES_PATH)) |
| 70 | + elif "linux" in platform_running.lower(): |
| 71 | + cmdline("{} linux".format(START_SERVICES_PATH)) |
| 72 | + else: |
| 73 | + close("your platform is not supported by AutoSploit at this time", status=2) |
85 | 74 |
|
86 | | - if len(sys.argv) > 1: |
87 | | - info("attempting to load API keys") |
88 | | - loaded_tokens = load_api_keys() |
89 | | - AutoSploitParser().parse_provided(opts) |
| 75 | + # moving this back because it was funky to see it each run |
| 76 | + info("services started successfully") |
| 77 | + # this tends to show up when trying to start the services |
| 78 | + # I'm not entirely sure why, but this fixes it |
| 79 | + except psutil.NoSuchProcess: |
| 80 | + pass |
| 81 | + else: |
| 82 | + process_start_command = "`sudo service {} start`" |
| 83 | + if "darwin" in platform_running.lower(): |
| 84 | + process_start_command = "`brew services start {}`" |
| 85 | + close( |
| 86 | + "service {} is required to be started for autosploit to run successfully (you can do it manually " |
| 87 | + "by using the command {}), exiting".format( |
| 88 | + service.title(), process_start_command.format(service) |
| 89 | + ) |
| 90 | + ) |
90 | 91 |
|
91 | | - if not opts.exploitFile: |
| 92 | + if len(sys.argv) > 1: |
| 93 | + info("attempting to load API keys") |
| 94 | + loaded_tokens = load_api_keys() |
| 95 | + AutoSploitParser().parse_provided(opts) |
| 96 | + |
| 97 | + if not opts.exploitFile: |
| 98 | + misc_info("checking if there are multiple exploit files") |
| 99 | + loaded_exploits = load_exploits(EXPLOIT_FILES_PATH) |
| 100 | + else: |
| 101 | + loaded_exploits = load_exploit_file(opts.exploitFile) |
| 102 | + misc_info("Loaded {} exploits from {}.".format( |
| 103 | + len(loaded_exploits), |
| 104 | + opts.exploitFile)) |
| 105 | + |
| 106 | + AutoSploitParser().single_run_args(opts, loaded_tokens, loaded_exploits) |
| 107 | + else: |
| 108 | + warning( |
| 109 | + "no arguments have been parsed, defaulting to terminal session. " |
| 110 | + "press 99 to quit and help to get help" |
| 111 | + ) |
92 | 112 | misc_info("checking if there are multiple exploit files") |
93 | 113 | loaded_exploits = load_exploits(EXPLOIT_FILES_PATH) |
94 | | - else: |
95 | | - loaded_exploits = load_exploit_file(opts.exploitFile) |
96 | | - misc_info("Loaded {} exploits from {}.".format( |
97 | | - len(loaded_exploits), |
98 | | - opts.exploitFile)) |
| 114 | + info("attempting to load API keys") |
| 115 | + loaded_tokens = load_api_keys() |
| 116 | + terminal = AutoSploitTerminal(loaded_tokens) |
| 117 | + terminal.terminal_main_display(loaded_exploits) |
| 118 | + except Exception as e: |
| 119 | + import traceback |
| 120 | + |
| 121 | + print( |
| 122 | + "\033[31m[!] AutoSploit has hit an unhandled exception: '{}', " |
| 123 | + "in order for the developers to troubleshoot and repair the " |
| 124 | + "issue AutoSploit will need to gather your OS information, metasploit version, " |
| 125 | + "current arguments, the error message, and a traceback. " |
| 126 | + "None of this information can be used to identify you in any way\033[0m".format(str(e)) |
| 127 | + ) |
| 128 | + error_traceback = ''.join(traceback.format_tb(sys.exc_info()[2])) |
| 129 | + error_file = save_error_to_file(str(error_traceback)) |
| 130 | + request_issue_creation(error_file, hide_sensitive(), str(e)) |
99 | 131 |
|
100 | | - AutoSploitParser().single_run_args(opts, loaded_tokens, loaded_exploits) |
101 | | - else: |
102 | | - warning("no arguments have been parsed, defaulting to terminal session. press 99 to quit and help to get help") |
103 | | - misc_info("checking if there are multiple exploit files") |
104 | | - loaded_exploits = load_exploits(EXPLOIT_FILES_PATH) |
105 | | - info("attempting to load API keys") |
106 | | - loaded_tokens = load_api_keys() |
107 | | - terminal = AutoSploitTerminal(loaded_tokens) |
108 | | - terminal.terminal_main_display(loaded_exploits) |
|
0 commit comments