From fe06e813d3cf1f1c96ffc4ff6819b8e3db4ba30c Mon Sep 17 00:00:00 2001 From: Evan Lewis Date: Thu, 22 Mar 2018 15:46:53 -0400 Subject: [PATCH 1/3] Added platform detection and support for OSX in service check and start --- autosploit/main.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/autosploit/main.py b/autosploit/main.py index 58e7694..5f00d42 100644 --- a/autosploit/main.py +++ b/autosploit/main.py @@ -2,6 +2,8 @@ import psutil +import platform + from lib.cmdline.cmd import AutoSploitParser from lib.term.terminal import AutoSploitTerminal from lib.output import ( @@ -31,7 +33,12 @@ def main(): info("welcome to autosploit, give us a little bit while we configure") misc_info("checking for disabled services") # according to ps aux, postgre and apache2 are the names of the services - service_names = ("postgres", "apache2") + + if platform.system() == "Darwin": + service_names = ("postgres","httpd") + elif platform.system() == "Linux": + service_names = ("postgres", "apache2") + for service in list(service_names): while not check_services(service): choice = prompt( @@ -42,9 +49,22 @@ def main(): if choice.lower().startswith("y"): try: if "postgre" in service: - cmdline("sudo bash {}".format(START_POSTGRESQL_PATH)) + if platform.system() == "Linux": + cmdline("sudo bash {}".format(START_POSTGRESQL_PATH)) + elif platform.system() == "Darwin": + cmdline("brew services start postgresql") + else: + error("Currently not supporting windows") + sys.exit(1) else: - cmdline("sudo bash {}".format(START_APACHE_PATH)) + if platform.system() == "Linux": + cmdline("sudo bash {}".format(START_APACHE_PATH)) + elif platform.system() == "Darwin": + cmdline("sudo apachectl start") + else: + error("Currently not supporting windows") + sys.exit(1) + # moving this back because it was funky to see it each run info("services started successfully") # this tends to show up when trying to start the services From 33b481f111f5b3d808ac98262728b2365b3e33bc Mon Sep 17 00:00:00 2001 From: Evan Lewis Date: Fri, 23 Mar 2018 02:42:22 -0400 Subject: [PATCH 2/3] Moved brew start command into bash file --- autosploit/main.py | 6 +++--- etc/scripts/start_postgre_osx.sh | 3 +++ lib/settings.py | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 etc/scripts/start_postgre_osx.sh diff --git a/autosploit/main.py b/autosploit/main.py index 5f00d42..58cc25d 100644 --- a/autosploit/main.py +++ b/autosploit/main.py @@ -1,7 +1,5 @@ import sys - import psutil - import platform from lib.cmdline.cmd import AutoSploitParser @@ -20,7 +18,8 @@ cmdline, EXPLOIT_FILES_PATH, START_APACHE_PATH, - START_POSTGRESQL_PATH + START_POSTGRESQL_PATH, + START_POSTGRESQL_OSX_PATH ) from lib.jsonize import load_exploits @@ -52,6 +51,7 @@ def main(): if platform.system() == "Linux": cmdline("sudo bash {}".format(START_POSTGRESQL_PATH)) elif platform.system() == "Darwin": + #cmdline("sudo bash {}".format(START_POSTGRESQL_OSX_PATH)) cmdline("brew services start postgresql") else: error("Currently not supporting windows") diff --git a/etc/scripts/start_postgre_osx.sh b/etc/scripts/start_postgre_osx.sh new file mode 100644 index 0000000..bcf4ba2 --- /dev/null +++ b/etc/scripts/start_postgre_osx.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sudo brew services restart postgresql diff --git a/lib/settings.py b/lib/settings.py index ba136c6..318d310 100644 --- a/lib/settings.py +++ b/lib/settings.py @@ -27,6 +27,9 @@ # path to the bash script to stack the PostgreSQL service START_POSTGRESQL_PATH = "{}/etc/scripts/start_postgre.sh".format(CUR_DIR) +# path to the bash script to stack the PostgreSQL service on OSX +START_POSTGRESQL_OSX_PATH = "{}/etc/scripts/start_postgre_osx.sh".format(CUR_DIR) + # path to the bash script to start the Apache service START_APACHE_PATH = "{}/etc/scripts/start_apache.sh".format(CUR_DIR) From e5426961cad09427cc297743b5c1405648fd27fc Mon Sep 17 00:00:00 2001 From: Evan Lewis Date: Fri, 23 Mar 2018 02:48:09 -0400 Subject: [PATCH 3/3] Moved apache start to bash file and removed a sudo --- autosploit/main.py | 6 +++--- etc/scripts/start_apache_osx.sh | 3 +++ etc/scripts/start_postgre_osx.sh | 2 +- lib/settings.py | 3 +++ 4 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 etc/scripts/start_apache_osx.sh diff --git a/autosploit/main.py b/autosploit/main.py index 58cc25d..83b4ae9 100644 --- a/autosploit/main.py +++ b/autosploit/main.py @@ -18,6 +18,7 @@ cmdline, EXPLOIT_FILES_PATH, START_APACHE_PATH, + START_APACHE_OSX_PATH, START_POSTGRESQL_PATH, START_POSTGRESQL_OSX_PATH ) @@ -51,8 +52,7 @@ def main(): if platform.system() == "Linux": cmdline("sudo bash {}".format(START_POSTGRESQL_PATH)) elif platform.system() == "Darwin": - #cmdline("sudo bash {}".format(START_POSTGRESQL_OSX_PATH)) - cmdline("brew services start postgresql") + cmdline("sudo bash {}".format(START_POSTGRESQL_OSX_PATH)) else: error("Currently not supporting windows") sys.exit(1) @@ -60,7 +60,7 @@ def main(): if platform.system() == "Linux": cmdline("sudo bash {}".format(START_APACHE_PATH)) elif platform.system() == "Darwin": - cmdline("sudo apachectl start") + cmdline("sudo bash {}".format(START_APACHE_OSX_PATH)) else: error("Currently not supporting windows") sys.exit(1) diff --git a/etc/scripts/start_apache_osx.sh b/etc/scripts/start_apache_osx.sh new file mode 100644 index 0000000..1e74ae7 --- /dev/null +++ b/etc/scripts/start_apache_osx.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sudo apachectl start diff --git a/etc/scripts/start_postgre_osx.sh b/etc/scripts/start_postgre_osx.sh index bcf4ba2..8812af6 100644 --- a/etc/scripts/start_postgre_osx.sh +++ b/etc/scripts/start_postgre_osx.sh @@ -1,3 +1,3 @@ #!/bin/bash -sudo brew services restart postgresql +brew services restart postgresql diff --git a/lib/settings.py b/lib/settings.py index 318d310..7e28523 100644 --- a/lib/settings.py +++ b/lib/settings.py @@ -33,6 +33,9 @@ # path to the bash script to start the Apache service START_APACHE_PATH = "{}/etc/scripts/start_apache.sh".format(CUR_DIR) +# path to the bash script to start the Apache service on OSX +START_APACHE_PATH = "{}/etc/scripts/start_apache_osx.sh".format(CUR_DIR) + # path to the file that will contain our query QUERY_FILE_PATH = tempfile.NamedTemporaryFile(delete=False).name