Skip to content

Commit 52f95c7

Browse files
authored
Merge pull request #65 from NullArray/more-updates
Updates
2 parents f792e27 + 3d777f2 commit 52f95c7

File tree

8 files changed

+133
-46
lines changed

8 files changed

+133
-46
lines changed

autosploit.py

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@
2929

3030
from lib.jsonize import load_exploits
3131
from lib.cmdline.cmd import AutoSploitParser
32+
from lib.banner import banner_main
3233
from lib.settings import (
3334
validate_ip_addr,
35+
check_services,
3436
PLATFORM_PROMPT,
35-
AUTOSPLOIT_PROMPT
37+
AUTOSPLOIT_PROMPT,
38+
AUTOSPLOIT_TERM_OPTS
3639
)
3740
from lib.output import (
3841
info,
@@ -50,27 +53,14 @@
5053
local_host = ""
5154
configured = False
5255
toolbar_width = 60
53-
version = "1.4.0"
5456
usage_and_legal_path = "{}/etc/general".format(os.getcwd())
5557
loaded_exploits = load_exploits("{}/etc/json".format(os.getcwd()))
5658
stop_animation = False
57-
autosploit_opts = {
58-
1: "usage and legal", 2: "gather hosts", 3: "custom hosts",
59-
4: "add single host", 5: "view gathered hosts", 6: "exploit gathered hosts",
60-
99: "quit"
61-
}
6259

6360

6461
def logo(line_sep="#--", space=" " * 30):
6562
"""Logo."""
66-
global version
67-
print("""\033[1m\033[36m{space_sep}_____ _ _____ _ _ _
68-
{sep1}Author : Vector/NullArray | _ |_ _| |_ ___| __|___| |___|_| |_
69-
{sep1}Twitter: @Real__Vector | | | | _| . |__ | . | | . | | _|
70-
{sep1}Type : Mass Exploiter |__|__|___|_| |___|_____| _|_|___|_|_|
71-
{sep1}Version: {v_num} |_|
72-
##############################################\033[0m
73-
""".format(sep1=line_sep, v_num=version, space_sep=space))
63+
print banner_main()
7464

7565

7666
def animation(text):
@@ -428,7 +418,6 @@ def main():
428418
global query
429419
global configured
430420
global api
431-
global autosploit_opts
432421

433422
# TODO:/
434423
# commenting this out for now, guessing we need to create a retry function
@@ -453,8 +442,8 @@ def try_shodan():
453442
settings()
454443

455444
info("Welcome to AutoSploit. Please select an action.")
456-
for i in autosploit_opts.keys():
457-
print("{}. {}".format(i, autosploit_opts[i].title()))
445+
for i in AUTOSPLOIT_TERM_OPTS.keys():
446+
print("{}. {}".format(i, AUTOSPLOIT_TERM_OPTS[i].title()))
458447

459448
action = raw_input(AUTOSPLOIT_PROMPT)
460449

@@ -568,37 +557,46 @@ def try_shodan():
568557
info("Initializing AutoSploit...")
569558
info("One moment please while we check the Postgresql and Apache services...")
570559

571-
postgresql = cmdline("sudo service postgresql status | grep active")
572-
if "Active: inactive" in postgresql:
573-
warning("Warning. Heuristic tests have indicated PostgreSQL Service is offline")
560+
# postgresql = cmdline("sudo service postgresql status | grep active")
561+
postgresql = check_services("postgre")
562+
if not postgresql:
563+
564+
def start_postgresql():
565+
# we're going to import it here because we don't need it anywhere else
566+
from lib.settings import START_POSTGRESQL_PATH
574567

568+
cmd = shlex.split("sudo sh {}".format(START_POSTGRESQL_PATH))
569+
cmdline(cmd)
570+
571+
warning("Warning. Heuristic tests have indicated PostgreSQL Service is offline")
575572
start_pst = prompt("Start Postgresql Service? [Y]es/[N]o")
576573
if start_pst == 'y':
577-
os.system("sudo service postgresql start")
578-
info("Postgresql Service Started...")
579-
time.sleep(1.5)
580-
574+
start_postgresql()
581575
elif start_pst == 'n':
582576
error("AutoSploit's MSF related operations require this service to be active.")
583577
error("Aborted.")
584578
time.sleep(1.5)
585579
sys.exit(0)
586580
else:
587581
warning("Unhandled Option. Defaulting to starting the service.")
588-
os.system("sudo service postgresql start")
589-
590-
info("Postgresql Service Started...")
582+
start_postgresql()
591583
time.sleep(1.5)
592584

593-
apache = cmdline("service apache2 status | grep active")
594-
if "Active: inactive" in apache:
585+
apache = check_services("apache2")
586+
if not apache:
587+
588+
def start_apache():
589+
# same as above
590+
from lib.settings import START_APACHE_PATH
591+
592+
cmd = shlex.split("sudo sh {}".format(START_APACHE_PATH))
593+
cmdline(cmd)
594+
595595
warning("Warning. Heruistic tests indicated that Apache Service is offline")
596596

597597
start_ap = prompt("Start Apache Service? [Y]es/[N]o")
598598
if start_ap == 'y':
599-
os.system("sudo service apache2 start")
600-
601-
info("[{}]Apache2 Service Started...")
599+
start_apache()
602600
time.sleep(1.5)
603601

604602
elif start_ap == 'n':
@@ -608,12 +606,7 @@ def try_shodan():
608606
sys.exit(0)
609607
else:
610608
warning("Unhandled Option. Defaulting to starting the service.")
611-
os.system("sudo service apache2 start")
612-
# TODO:/
613-
# Should really add another check here to make sure it started,
614-
# possible to use `psutils` to check the running tasks for autosploit
615-
616-
info("Apache2 Service Started...")
609+
start_apache()
617610
time.sleep(1.5)
618611

619612
# We will check if the shodan api key has been saved before, if not we are going to prompt
@@ -636,4 +629,4 @@ def try_shodan():
636629
path = os.path.abspath("api.p")
637630
info("Your API key was loaded from {}".format(path))
638631

639-
main()
632+
main()

etc/scripts/start_apache.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
sudo service apache2 start > /dev/null 2>&1

etc/scripts/start_postgre.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
sudo service postgresql start > /dev/null 2>&1

lib/banner.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import random
2+
3+
VERSION = "1.4.0"
4+
5+
6+
def banner_1(line_sep="#--", space=" " * 30):
7+
print("""\033[1m\033[36m{space_sep}_____ _ _____ _ _ _
8+
{sep1}Author : Vector/NullArray | _ |_ _| |_ ___| __|___| |___|_| |_
9+
{sep1}Twitter: @Real__Vector | | | | _| . |__ | . | | . | | _|
10+
{sep1}Type : Mass Exploiter |__|__|___|_| |___|_____| _|_|___|_|_|
11+
{sep1}Version: {v_num} |_|
12+
##############################################\033[0m
13+
""".format(sep1=line_sep, v_num=VERSION, space_sep=space))
14+
15+
16+
def banner_2():
17+
print(r"""
18+
{blue}--+{end} {red}Graffiti the world with exploits{end} {blue}+--{end}
19+
{blue}--+{end} __ ____ {blue}+--{end}
20+
{blue}--+{end} / _\ / ___) {blue}+--{end}
21+
{blue}--+{end} / \\___ \ {blue}+--{end}
22+
{blue}--+{end} \_/\_/(____/ {blue}+--{end}
23+
{blue}--+{end} {red}AutoSploit{end} {blue}+--{end}
24+
{blue}--+{end} NullArray/Eku {blue}+--{end}
25+
{blue}--+{end} v({red}{vnum}{end}) {blue}+--{end}
26+
""".format(vnum=VERSION, blue="\033[36m", red="\033[31m", end="\033[0m"))
27+
28+
29+
def banner_3():
30+
print(r'''#SploitaSaurus Rex{green}
31+
O_
32+
/ >
33+
- > ^\
34+
/ > ^ /
35+
(O) > ^ / / / /
36+
_____ | \\|//
37+
/ __ \ _/ / / _/
38+
/ / | | / / / /
39+
_/ |___/ / / ------_/ /
40+
==_| \____/ _/ / ______/
41+
\ \ __/ |\
42+
| \_ ____/ / \ _
43+
\ \________/ |\ \----/_V
44+
\_ / \_______ V
45+
\__ / \ / V
46+
\ \ \
47+
\______ \_ \
48+
\__________\_ \
49+
/ / \_ |
50+
| _/ \ |
51+
/ _/ \ |
52+
| / | |
53+
\ \__ | \__
54+
/\____=\ /\_____=\{end} v({vnum})'''''.format(
55+
green="\033[1m\033[32m", end="\033[0m", vnum=VERSION
56+
))
57+
58+
59+
def banner_main():
60+
"""
61+
grab a random banner each run
62+
"""
63+
banners = [
64+
banner_3, banner_2, banner_1
65+
]
66+
return random.choice(banners)()

lib/cmdline/cmd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def single_run_args(opt):
3636
ethics_file = "{}/etc/text_files/ethics.lst".format(os.getcwd())
3737
with open(ethics_file) as ethics:
3838
ethic = random.choice(ethics.readlines()).strip()
39-
print("Your ethic for the day:\n\n{}".format(ethic))
39+
print("Here we have an ethical lesson for you:\n\n{}".format(ethic))
4040
sys.exit(0)
4141
if opt.exploitList:
4242
try:

lib/output.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
def info(text):
22
print(
3-
"\n[\033[1m\033[32m+\033[0m] {}".format(
3+
"[\033[1m\033[32m+\033[0m] {}".format(
44
text
55
)
66
)
77

88

99
def prompt(text, lowercase=True):
1010
question = raw_input(
11-
"\n[\033[1m\033[36m?\033[0m] {}: ".format(
11+
"[\033[1m\033[36m?\033[0m] {}: ".format(
1212
text
1313
)
1414
)
@@ -19,15 +19,15 @@ def prompt(text, lowercase=True):
1919

2020
def error(text):
2121
print(
22-
"\n[\033[1m\033[31m!\033[0m] {}".format(
22+
"[\033[1m\033[31m!\033[0m] {}".format(
2323
text
2424
)
2525
)
2626

2727

2828
def warning(text):
2929
print(
30-
"\n[\033[1m\033[33m-\033[0m] {}".format(
30+
"[\033[1m\033[33m-\033[0m] {}".format(
3131
text
3232
)
3333
)

lib/settings.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
1+
import os
12
import socket
23
import getpass
34

5+
import psutil
46

7+
8+
START_POSTGRESQL_PATH = "{}/etc/scripts/start_postgre.sh".format(os.getcwd())
9+
START_APACHE_PATH = "{}/etc/scripts/start_apache.sh".format(os.getcwd())
510
PLATFORM_PROMPT = "\n{}@\033[36mPLATFORM\033[0m$ ".format(getpass.getuser())
611
AUTOSPLOIT_PROMPT = "\n\033[31m{}\033[0m@\033[36mautosploit\033[0m# ".format(getpass.getuser())
12+
AUTOSPLOIT_TERM_OPTS = {
13+
1: "usage and legal", 2: "gather hosts", 3: "custom hosts",
14+
4: "add single host", 5: "view gathered hosts", 6: "exploit gathered hosts",
15+
99: "quit"
16+
}
717

818

919
def validate_ip_addr(provided):
1020
try:
1121
socket.inet_aton(provided)
1222
return True
1323
except:
14-
return False
24+
return False
25+
26+
27+
def check_services(service_name):
28+
all_processes = set()
29+
for pid in psutil.pids():
30+
running_proc = psutil.Process(pid)
31+
all_processes.add(" ".join(running_proc.cmdline()).strip())
32+
for proc in list(all_processes):
33+
if service_name in proc:
34+
return True
35+
return False

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
shodan==1.7.7
22
requests==2.18.4
3+
psutil==5.3.0

0 commit comments

Comments
 (0)