Skip to content

Commit 76f4d65

Browse files
author
ekultek
committed
updated the services check
1 parent e2dd4c3 commit 76f4d65

1 file changed

Lines changed: 29 additions & 11 deletions

File tree

autosploit/main.py

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import sys
22

3+
import psutil
4+
35
from lib.cmdline.cmd import AutoSploitParser
46
from lib.term.terminal import AutoSploitTerminal
57
from lib.output import (
68
info,
79
warning,
810
error,
9-
prompt
11+
prompt,
12+
misc_info
1013
)
1114
from lib.settings import (
1215
logo,
@@ -26,32 +29,47 @@ def main():
2629

2730
logo()
2831
info("welcome to autosploit, give us a little bit while we configure")
29-
info("checking for services")
32+
misc_info("checking for disabled services")
3033
# according to ps aux, postgre and apache2 are the names of the services
3134
service_names = ("postgres", "apache2")
3235
for service in list(service_names):
3336
while not check_services(service):
34-
choice = prompt("it appears that service {} is not enabled, would you like us to enable it for you[y/N]".format(service))
37+
choice = prompt(
38+
"it appears that service {} is not enabled, would you like us to enable it for you[y/N]".format(
39+
service.title()
40+
)
41+
)
3542
if choice.lower().startswith("y"):
36-
if "postgre" in service:
37-
cmdline("sudo bash {}".format(START_POSTGRESQL_PATH))
38-
else:
39-
cmdline("sudo bash {}".format(START_APACHE_PATH))
43+
try:
44+
if "postgre" in service:
45+
cmdline("sudo bash {}".format(START_POSTGRESQL_PATH))
46+
else:
47+
cmdline("sudo bash {}".format(START_APACHE_PATH))
48+
# moving this back because it was funky to see it each run
49+
info("services started successfully")
50+
# this tends to show up when trying to start the services
51+
# I'm not entirely sure why, but this fixes it
52+
except psutil.NoSuchProcess:
53+
pass
4054
else:
41-
error("service {} is required to be started for autosploit to run, exiting".format(service.title()))
55+
error(
56+
"service {} is required to be started for autosploit to run successfully (you can do it manually "
57+
"by using the command `sudo service {} start`), exiting".format(
58+
service.title(), service
59+
)
60+
)
4261
sys.exit(1)
43-
info("services started successfully")
4462

4563
if len(sys.argv) > 1:
4664
info("attempting to load API keys")
4765
loaded_tokens = load_api_keys()
4866
AutoSploitParser().parse_provided(opts)
49-
info("checking if there are multiple exploit files")
67+
misc_info("checking if there are multiple exploit files")
5068
loaded_exploits = load_exploits(EXPLOIT_FILES_PATH)
5169
AutoSploitParser().single_run_args(opts, loaded_tokens, loaded_exploits)
5270
else:
5371
warning("no arguments have been parsed, defaulting to terminal session. press 99 to quit and help to get help")
54-
info("checking if there are multiple exploit files")
72+
misc_info("checking if there are multiple exploit files")
5573
loaded_exploits = load_exploits(EXPLOIT_FILES_PATH)
5674
info("attempting to load API keys")
5775
loaded_tokens = load_api_keys()

0 commit comments

Comments
 (0)