Skip to content

Commit 37cf7ab

Browse files
author
ekultek
committed
complete rewrite of terminal, now has history and commands along with the ability to run external commands, fixes all issues with bug tag
1 parent 4fa0e20 commit 37cf7ab

10 files changed

Lines changed: 563 additions & 350 deletions

File tree

README.md

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ sudo -s << EOF
4646
git clone https://github.com/NullArray/AutoSploit.git
4747
cd AutoSploit
4848
chmod +x install.sh
49-
./installsh
49+
./install.sh
5050
cd AutoSploit/Docker
5151
docker network create -d bridge haknet
5252
docker run --network haknet --name msfdb -e POSTGRES_PASSWORD=s3cr3t -d postgres
@@ -64,7 +64,7 @@ chmod +x install.sh
6464
./install.sh
6565
```
6666

67-
If you want to run AutoSploit on a macOS system, AutoSploit is compatible with macOS, however, you have to be inside a virtual environment for it to run successfully. To do this, do the following;
67+
AutoSploit is compatible with macOS, however, you have to be inside a virtual environment for it to run successfully. In order to accomplish this employ/perform the below operations via the terminal or in the form of a shell script.
6868

6969
```bash
7070
sudo -s << '_EOF'
@@ -149,21 +149,6 @@ misc arguments:
149149
--whitelist PATH only exploit hosts listed in the whitelist file
150150
```
151151

152-
If you want to run AutoSploit on a macOS system, AutoSploit is compatible with macOS, however, you have to be inside a virtual environment for it to run successfully. To do this, do the following;
153-
154-
```bash
155-
sudo -s << '_EOF'
156-
pip2 install virtualenv --user
157-
git clone https://github.com/NullArray/AutoSploit.git
158-
virtualenv <PATH-TO-YOUR-ENV>
159-
source <PATH-TO-YOUR-ENV>/bin/activate
160-
cd <PATH-TO-AUTOSPLOIT>
161-
pip2 install -r requirements.txt
162-
chmod +x install.sh
163-
./install.sh
164-
python autosploit.py
165-
_EOF
166-
```
167152

168153
## Dependencies
169154
_Note_: All dependencies should be installed using the above installation method, however, if you find they are not:
@@ -173,13 +158,12 @@ AutoSploit depends on the following Python2.7 modules.
173158
```
174159
requests
175160
psutil
176-
beautifulsoup4
177161
```
178162

179163
Should you find you do not have these installed get them with pip like so.
180164

181165
```bash
182-
pip install requests psutil beautifulsoup4
166+
pip install requests psutil
183167
```
184168

185169
or
@@ -192,9 +176,11 @@ Since the program invokes functionality from the Metasploit Framework you need t
192176

193177
## Acknowledgements
194178

195-
Special thanks to [Ekultek](https://github.com/Ekultek) without whoms contributions to the project version 2.0 would have been a lot less spectacular.
179+
Special thanks to [Ekultek](https://github.com/Ekultek) without whoms contributions to the project, version 2.0 would have been a lot less spectacular.
180+
181+
Thanks to [Khast3x](https://github.com/khast3x) for setting up Docker support.
196182

197-
And thanks to [Khast3x](https://github.com/khast3x) for setting up Docker support.
183+
Last but certainly not least. Thanks to all who have submitted Pull Requests, bug reports, useful and productive contributions in general.
198184

199185
### Active Development
200186

api_calls/censys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(self, identity=None, token=None, query=None, proxy=None, agent=None
2424
self.host_file = HOST_FILE
2525
self.save_mode = save_mode
2626

27-
def censys(self):
27+
def search(self):
2828
"""
2929
connect to the Censys API and pull all IP addresses from the provided query
3030
"""

api_calls/shodan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(self, token=None, query=None, proxy=None, agent=None, save_mode=Non
2525
self.host_file = HOST_FILE
2626
self.save_mode = save_mode
2727

28-
def shodan(self):
28+
def search(self):
2929
"""
3030
connect to the API and grab all IP addresses associated with the provided query
3131
"""

api_calls/zoomeye.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __get_auth(self):
5454
token = json.loads(req.content)
5555
return token
5656

57-
def zoomeye(self):
57+
def search(self):
5858
"""
5959
connect to the API and pull all the IP addresses that are associated with the
6060
given query

autosploit/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ def main():
117117
loaded_exploits = load_exploits(EXPLOIT_FILES_PATH)
118118
info("attempting to load API keys")
119119
loaded_tokens = load_api_keys()
120-
terminal = AutoSploitTerminal(loaded_tokens)
121-
terminal.terminal_main_display(loaded_exploits)
120+
terminal = AutoSploitTerminal(loaded_tokens, loaded_exploits)
121+
terminal.terminal_main_display(loaded_tokens)
122122
except Exception as e:
123123
import traceback
124124

etc/text_files/gen

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
usage of AutoSploit for attacking targets without prior mutual consent is illegal in pretty much every sense of the word. it is the end user's responsibility to obey all applicable local, state, and federal laws. developers assume no liability and are not responsible for any misuse or damage caused by this program. please take these considerations into mind:
2+
3+
- use AutoSploit on a VPS through a proxy or Tor
4+
- keep calm and wipe the logs or use tools to do so
5+
- never connect from your local IP address
6+
- keep a low profile, the point of hacking is not to get caught
7+
8+
we do not condone hacking of any sort, the above are tips to keep in mind for ethical purposes. having said that, knowledge is not illegal, and anybody that tells you learning is wrong is a fool. get as much out of this program as we got from writing it.

lib/banner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import random
33

4-
VERSION = "2.2.5"
4+
VERSION = "3.0"
55

66

77
def banner_1(line_sep="#--", space=" " * 30):

lib/cmdline/cmd.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,33 +187,33 @@ def single_run_args(opt, keys, loaded_modules):
187187
keys["censys"][1], keys["censys"][0],
188188
opt.searchQuery, proxy=headers[0], agent=headers[1],
189189
save_mode=search_save_mode
190-
).censys()
190+
).search()
191191
if opt.searchZoomeye:
192192
lib.output.info(single_search_msg.format("Zoomeye"))
193193
api_searches[0](
194194
opt.searchQuery, proxy=headers[0], agent=headers[1],
195195
save_mode=search_save_mode
196-
).zoomeye()
196+
).search()
197197
if opt.searchShodan:
198198
lib.output.info(single_search_msg.format("Shodan"))
199199
api_searches[1](
200200
keys["shodan"][0], opt.searchQuery, proxy=headers[0], agent=headers[1],
201201
save_mode=search_save_mode
202-
).shodan()
202+
).search()
203203
if opt.searchAll:
204204
lib.output.info("searching all search engines in order")
205205
api_searches[0](
206206
opt.searchQuery, proxy=headers[0], agent=headers[1],
207207
save_mode=search_save_mode
208-
).zoomeye()
208+
).search()
209209
api_searches[1](
210210
keys["shodan"][0], opt.searchQuery, proxy=headers[0], agent=headers[1],
211211
save_mode=search_save_mode
212-
).shodan()
212+
).search()
213213
api_searches[2](
214214
keys["censys"][1], keys["censys"][0], opt.searchQuery, proxy=headers[0], agent=headers[1],
215215
save_mode=search_save_mode
216-
).censys()
216+
).search()
217217
if opt.startExploit:
218218
hosts = open(lib.settings.HOST_FILE).readlines()
219219
if opt.whitelist:

lib/settings.py

Lines changed: 119 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import platform
77
import getpass
88
import tempfile
9+
import readline
910
import distutils.spawn
1011
from subprocess import (
1112
PIPE,
@@ -16,9 +17,56 @@
1617

1718
import lib.output
1819
import lib.banner
20+
import lib.jsonize
1921

22+
23+
class AutoSploitCompleter(object):
24+
25+
"""
26+
object to create an auto completer for the terminal
27+
"""
28+
29+
def __init__(self, opts):
30+
self.opts = sorted(opts)
31+
self.possibles = []
32+
33+
def complete_text(self, text, state):
34+
if state == 0:
35+
if text:
36+
self.possibles = [m for m in self.opts if m.startswith(text)]
37+
else:
38+
self.possibles = self.opts[:]
39+
try:
40+
return self.possibles[state]
41+
except IndexError:
42+
return None
43+
44+
45+
TERMINAL_HELP_MESSAGE = """
46+
COMMAND: SUMMARY:
47+
--------- --------
48+
view/show Show the already gathered hosts
49+
mem[ory]/history Display the command history
50+
exploit/run/attack Run the exploits on the already gathered hosts
51+
search/api/gather Search the API's for hosts
52+
exit/quit Exit the terminal session
53+
single Load a single host into the file
54+
tokens/reset Reset API tokens if needed
55+
help/? Display this help
56+
"""
57+
58+
# current directory
2059
CUR_DIR = "{}".format(os.getcwd())
2160

61+
# home
62+
HOME = "{}/.autosploit_home".format(os.path.expanduser("~"))
63+
64+
# backup the current hosts file
65+
HOST_FILE_BACKUP = "{}/backups".format(HOME)
66+
67+
# autosploit command history file path
68+
HISTORY_FILE_PATH = "{}/.history".format(HOME)
69+
2270
# path to the file containing all the discovered hosts
2371
HOST_FILE = "{}/hosts.txt".format(CUR_DIR)
2472
try:
@@ -49,7 +97,7 @@
4997
PLATFORM_PROMPT = "\n{}@\033[36mPLATFORM\033[0m$ ".format(getpass.getuser())
5098

5199
# the prompt that will be used most of the time
52-
AUTOSPLOIT_PROMPT = "\n\033[31m{}\033[0m@\033[36mautosploit\033[0m# ".format(getpass.getuser())
100+
AUTOSPLOIT_PROMPT = "\033[31m{}\033[0m@\033[36mautosploit\033[0m# ".format(getpass.getuser())
53101

54102
# all the paths to the API tokens
55103
API_KEYS = {
@@ -74,7 +122,7 @@
74122
TOKEN_PATH = "{}/etc/text_files/auth.key".format(CUR_DIR)
75123

76124
# location of error files
77-
ERROR_FILES_LOCATION = "{}/.autosploit_errors".format(os.path.expanduser("~"))
125+
ERROR_FILES_LOCATION = "{}/.autosploit_errors".format(HOME)
78126

79127
# terminal options
80128
AUTOSPLOIT_TERM_OPTS = {
@@ -83,14 +131,58 @@
83131
99: "quit"
84132
}
85133

134+
# global variable for the search animation
86135
stop_animation = False
87136

88137

89-
def validate_ip_addr(provided):
138+
def load_external_commands():
139+
"""
140+
create a list of external commands from provided directories
141+
"""
142+
paths = ["/bin", "/usr/bin"]
143+
loaded_externals = []
144+
for f in paths:
145+
for cmd in os.listdir(f):
146+
if not os.path.isdir("{}/{}".format(f, cmd)):
147+
loaded_externals.append(cmd)
148+
return loaded_externals
149+
150+
151+
def backup_host_file(current, path):
152+
"""
153+
backup the current hosts file
154+
"""
155+
import datetime
156+
import shutil
157+
158+
if not os.path.exists(path):
159+
os.makedirs(path)
160+
new_filename = "{}/hosts_{}_{}.txt".format(
161+
path,
162+
lib.jsonize.random_file_name(length=17),
163+
str(datetime.datetime.today()).split(" ")[0]
164+
)
165+
shutil.copyfile(current, new_filename)
166+
return new_filename
167+
168+
169+
def auto_completer(keywords):
170+
"""
171+
function to initialize the auto complete utility
172+
"""
173+
completer = AutoSploitCompleter(keywords)
174+
readline.set_completer(completer.complete_text)
175+
readline.parse_and_bind('tab: complete')
176+
177+
178+
def validate_ip_addr(provided, home_ok=False):
90179
"""
91180
validate an IP address to see if it is real or not
92181
"""
93-
not_acceptable = ("0.0.0.0", "127.0.0.1", "255.255.255.255")
182+
if not home_ok:
183+
not_acceptable = ("0.0.0.0", "127.0.0.1", "255.255.255.255")
184+
else:
185+
not_acceptable = ("255.255.255.255",)
94186
if provided not in not_acceptable:
95187
try:
96188
socket.inet_aton(provided)
@@ -186,7 +278,7 @@ def load_api_keys(unattended=False, path="{}/etc/tokens".format(CUR_DIR)):
186278
return api_tokens
187279

188280

189-
def cmdline(command):
281+
def cmdline(command, is_msf=True):
190282
"""
191283
send the commands through subprocess
192284
"""
@@ -200,7 +292,10 @@ def cmdline(command):
200292
stdout_buff = []
201293
for stdout_line in iter(proc.stdout.readline, b''):
202294
stdout_buff += [stdout_line.rstrip()]
203-
print("(msf)>> {}".format(stdout_line).rstrip())
295+
if is_msf:
296+
print("(msf)>> {}".format(stdout_line).rstrip())
297+
else:
298+
print("{}".format(stdout_line).rstrip())
204299

205300
return stdout_buff
206301

@@ -331,6 +426,9 @@ def save_error_to_file(error_info, error_message, error_class):
331426

332427

333428
def download_modules(link):
429+
"""
430+
download new module links
431+
"""
334432
import re
335433
import requests
336434
import tempfile
@@ -348,3 +446,18 @@ def download_modules(link):
348446
with open(storage_file.name, 'a+') as tmp:
349447
tmp.write(retval)
350448
return storage_file.name
449+
450+
451+
def find_similar(command, internal, external):
452+
"""
453+
find commands similar to the one provided
454+
"""
455+
retval = []
456+
first_char = command[0]
457+
for inter in internal:
458+
if inter.startswith(first_char):
459+
retval.append(inter)
460+
for exter in external:
461+
if exter.startswith(first_char):
462+
retval.append(exter)
463+
return retval

0 commit comments

Comments
 (0)