Skip to content

Commit ce02fb7

Browse files
ehlewisEkultek
authored andcommitted
Added platform detection and support for OSX in service check and start (#101)
* Added platform detection and support for OSX in service check and start * Moved brew start command into bash file * Moved apache start to bash file and removed a sudo
1 parent 8bb2a22 commit ce02fb7

4 files changed

Lines changed: 37 additions & 5 deletions

File tree

autosploit/main.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
2-
32
import psutil
3+
import platform
44

55
from lib.cmdline.cmd import AutoSploitParser
66
from lib.term.terminal import AutoSploitTerminal
@@ -18,7 +18,9 @@
1818
cmdline,
1919
EXPLOIT_FILES_PATH,
2020
START_APACHE_PATH,
21-
START_POSTGRESQL_PATH
21+
START_APACHE_OSX_PATH,
22+
START_POSTGRESQL_PATH,
23+
START_POSTGRESQL_OSX_PATH
2224
)
2325
from lib.jsonize import load_exploits
2426

@@ -31,7 +33,12 @@ def main():
3133
info("welcome to autosploit, give us a little bit while we configure")
3234
misc_info("checking for disabled services")
3335
# according to ps aux, postgre and apache2 are the names of the services
34-
service_names = ("postgres", "apache2")
36+
37+
if platform.system() == "Darwin":
38+
service_names = ("postgres","httpd")
39+
elif platform.system() == "Linux":
40+
service_names = ("postgres", "apache2")
41+
3542
for service in list(service_names):
3643
while not check_services(service):
3744
choice = prompt(
@@ -42,9 +49,22 @@ def main():
4249
if choice.lower().startswith("y"):
4350
try:
4451
if "postgre" in service:
45-
cmdline("sudo bash {}".format(START_POSTGRESQL_PATH))
52+
if platform.system() == "Linux":
53+
cmdline("sudo bash {}".format(START_POSTGRESQL_PATH))
54+
elif platform.system() == "Darwin":
55+
cmdline("sudo bash {}".format(START_POSTGRESQL_OSX_PATH))
56+
else:
57+
error("Currently not supporting windows")
58+
sys.exit(1)
4659
else:
47-
cmdline("sudo bash {}".format(START_APACHE_PATH))
60+
if platform.system() == "Linux":
61+
cmdline("sudo bash {}".format(START_APACHE_PATH))
62+
elif platform.system() == "Darwin":
63+
cmdline("sudo bash {}".format(START_APACHE_OSX_PATH))
64+
else:
65+
error("Currently not supporting windows")
66+
sys.exit(1)
67+
4868
# moving this back because it was funky to see it each run
4969
info("services started successfully")
5070
# this tends to show up when trying to start the services

etc/scripts/start_apache_osx.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
sudo apachectl start

etc/scripts/start_postgre_osx.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
brew services restart postgresql

lib/settings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,15 @@
2727
# path to the bash script to stack the PostgreSQL service
2828
START_POSTGRESQL_PATH = "{}/etc/scripts/start_postgre.sh".format(CUR_DIR)
2929

30+
# path to the bash script to stack the PostgreSQL service on OSX
31+
START_POSTGRESQL_OSX_PATH = "{}/etc/scripts/start_postgre_osx.sh".format(CUR_DIR)
32+
3033
# path to the bash script to start the Apache service
3134
START_APACHE_PATH = "{}/etc/scripts/start_apache.sh".format(CUR_DIR)
3235

36+
# path to the bash script to start the Apache service on OSX
37+
START_APACHE_PATH = "{}/etc/scripts/start_apache_osx.sh".format(CUR_DIR)
38+
3339
# path to the file that will contain our query
3440
QUERY_FILE_PATH = tempfile.NamedTemporaryFile(delete=False).name
3541

0 commit comments

Comments
 (0)