Skip to content

Commit e2b26d4

Browse files
author
ekultek
committed
starting compatibility with macos
1 parent c2d808d commit e2b26d4

2 files changed

Lines changed: 44 additions & 28 deletions

File tree

autosploit/main.py

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from lib.output import (
88
info,
99
warning,
10-
error,
1110
prompt,
1211
misc_info
1312
)
@@ -16,11 +15,9 @@
1615
load_api_keys,
1716
check_services,
1817
cmdline,
18+
close,
1919
EXPLOIT_FILES_PATH,
20-
START_APACHE_PATH,
21-
START_APACHE_OSX_PATH,
22-
START_POSTGRESQL_PATH,
23-
START_POSTGRESQL_OSX_PATH
20+
START_SERVICES_PATH
2421
)
2522
from lib.jsonize import load_exploits
2623

@@ -31,12 +28,12 @@ def main():
3128

3229
logo()
3330
info("welcome to autosploit, give us a little bit while we configure")
31+
misc_info("checking your running platform")
32+
platform_running = platform.system()
3433
misc_info("checking for disabled services")
35-
# according to ps aux, postgre and apache2 are the names of the services
36-
37-
if platform.system() == "Darwin":
38-
service_names = ("postgres","httpd")
39-
elif platform.system() == "Linux":
34+
# according to ps aux, postgre and apache2 are the names of the services on Linux systems
35+
service_names = ("postgres", "apache2")
36+
if "darwin" in platform_running.lower():
4037
service_names = ("postgres", "apache2")
4138

4239
for service in list(service_names):
@@ -48,22 +45,12 @@ def main():
4845
)
4946
if choice.lower().startswith("y"):
5047
try:
51-
if "postgre" in service:
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)
48+
if "darwin" in platform_running.lower():
49+
cmdline("{} darwin".format(START_SERVICES_PATH))
50+
elif "linux" in platform_running.lower():
51+
cmdline("{} linux".format(START_SERVICES_PATH))
5952
else:
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)
53+
close("your platform is not supported by AutoSploit at this time", status=2)
6754

6855
# moving this back because it was funky to see it each run
6956
info("services started successfully")
@@ -72,13 +59,12 @@ def main():
7259
except psutil.NoSuchProcess:
7360
pass
7461
else:
75-
error(
62+
close(
7663
"service {} is required to be started for autosploit to run successfully (you can do it manually "
7764
"by using the command `sudo service {} start`), exiting".format(
7865
service.title(), service
7966
)
8067
)
81-
sys.exit(1)
8268

8369
if len(sys.argv) > 1:
8470
info("attempting to load API keys")

etc/scripts/start_services.sh

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,31 @@
1-
#!/usr/bin/env bash
1+
#!/bin/bash
2+
3+
function startApacheLinux () {
4+
sudo service apache2 start > /dev/null 2>&1
5+
}
6+
7+
function startPostgreSQLLinux () {
8+
sudo service postgresql start > /dev/null 2>&1
9+
}
10+
11+
function startApacheOSX () {
12+
sudo apachectl start > /dev/null 2>&1
13+
}
14+
15+
function startPostgreSQLOSX () {
16+
brew services restart postgresql > /dev/null 2>&1
17+
}
18+
19+
function main () {
20+
if [ $1 == "linux" ]; then
21+
startApacheLinux;
22+
startPostgreSQLLinux;
23+
elif [ $1 == "darwin" ]; then
24+
startApacheOSX;
25+
startPostgreSQLOSX;
26+
else
27+
echo "[*} invalid operating system";
28+
fi
29+
}
30+
31+
main $@;

0 commit comments

Comments
 (0)