Skip to content

Commit d1d56e9

Browse files
authored
Merge pull request #74 from NullArray/dev-beta
Dev beta
2 parents 22b5dcc + 13260b5 commit d1d56e9

36 files changed

+5976
-783
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!--
2+
In order for us to properly diagnose and troubleshoot your issue
3+
we will need you to follow this issue template
4+
-->
5+
6+
# Running information
7+
8+
<!-- Running detail, OS, arch, did you clone, etc -->
9+
- What branch did you download?
10+
- Clone, or docker run?
11+
- What OS are you running?
12+
13+
# Exploit module information
14+
15+
<!-- We will need this information to determine if it is a metasploit issue or not -->
16+
- What exploit was deployed?
17+
- Was a session generated for the target?
18+
- What version of metasploit are you running?
19+
20+
# Program information
21+
22+
<!-- Basic python information we will need -->
23+
- Python version number?
24+
- AutoSploit version number?
25+
- Any console output that is relevant to the issue:
26+
- Traceback (error) if any:
27+

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
*.pyc
22
.idea/*
33
api.p
4-
hosts.txt
4+
hosts.txt
5+
secret.p
6+
uid.p
7+
etc/tokens/*

Docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN apt update && apt install -y postgresql \
88
git \
99
metasploit-framework
1010

11-
RUN git clone https://github.com/NullArray/AutoSploit.git && pip install shodan blessings
11+
RUN git clone https://github.com/NullArray/AutoSploit.git && pip install requests psutil
1212
COPY database.yml /root/.msf4/database.yml
1313
WORKDIR AutoSploit
1414
EXPOSE 80 443 4444

Docker/README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Docker deployment instructions
2-
=====
1+
# Docker deployment instructions
32

43
## tl;dr
54

@@ -24,19 +23,19 @@ docker build -t autosploit .
2423
docker run -it --network haknet -p 80:80 -p 443:443 -p 4444:4444 autosploit
2524
```
2625

27-
2826
## Abstract
2927

30-
* Launching `Autosploit` as a Docker container makes it very easy to use the tool in a hosted cloud environment (AWS, Azure, ...)
31-
* Separate `postgres` database into individual service for data persistence and potential async updating of the database
32-
* Create a small bridge network ``haknet`` so the service discovery is automatic
33-
* Launch `postgres` and `Autosploit` container, both linked by `haknet`
34-
* Autosploit will automatically launch preconfigured `msfconsole` to the external `postgres` container through `haknet` transparent network
35-
* Total image size of Kali + Metasploit + Autosploit : 1.75GB
28+
- Launching `Autosploit` as a Docker container makes it very easy to use the tool in a hosted cloud environment (AWS, Azure, ...)
29+
- Separate `postgres` database into individual service for data persistence and potential async updating of the database
30+
- Create a small bridge network `haknet` so the service discovery is automatic
31+
- Launch `postgres` and `Autosploit` container, both linked by `haknet`
32+
- Autosploit will automatically launch preconfigured `msfconsole` to the external `postgres` container through `haknet` transparent network
33+
- Total image size of Kali + Metasploit + Autosploit : 1.75GB
3634

3735
## Deploy
3836

39-
##### Step 1 - Create bridge network
37+
### Step 1 - Create bridge network
38+
4039
This will enable the Metasploit Framework to talk to the `postgres` database using its hostname, making it abstract.
4140

4241
A Tor Socks Proxy can also be added to perform transparent proxy when launching exploits (not for reverse shells though, obviously).
@@ -45,22 +44,23 @@ A Tor Socks Proxy can also be added to perform transparent proxy when launching
4544
docker network create -d bridge haknet
4645
```
4746

48-
##### Step 2 - Launch services
47+
### Step 2 - Launch services
4948

5049
All automagically linked
5150

52-
53-
###### Step 2.1 - Launch postgres
51+
#### Step 2.1 - Launch postgres
5452

5553
Launch a vanilla `postgres` service, linked to `haknet`
54+
5655
```bash
5756
docker run --network haknet --name msfdb -e POSTGRES_PASSWORD=s3cr3t -d postgres
5857
```
59-
###### Step 2.2 - Launch Autosploit
58+
59+
#### Step 2.2 - Launch Autosploit
6060

6161
Launch `Autosploit`.
6262

63-
This Dockerfile will copy the default database config to ```~/.msf4/database.yml```. You can edit the configuration file `database.yml` to your liking before building.
63+
This Dockerfile will copy the default database config to `~/.msf4/database.yml`. You can edit the configuration file `database.yml` to your liking before building.
6464

6565
Please be aware that the first build will take some time (~10mn)
6666

Docker/database.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
development: &pgsql
2-
adapter: postgresql
3-
database: postgres
4-
username: postgres
5-
password: s3cr3t
6-
host: msfdb
7-
port: 5432
8-
pool: 200
9-
timeout: 5
2+
adapter: postgresql
3+
database: postgres
4+
username: postgres
5+
password: s3cr3t
6+
host: msfdb
7+
port: 5432
8+
pool: 200
9+
timeout: 5
1010

11-
production: &production
12-
<<: *pgsql
11+
production: &production
12+
<<: *pgsql

Docker/docker-compose.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
version: '3'
1+
version: '3'
22

33
services:
44
autosploit:
55
build:
6-
context: .
6+
context: .
77
ports:
88
- 80:80
99
- 443:433
@@ -13,7 +13,7 @@ services:
1313
depends_on:
1414
- postgres
1515
postgres:
16-
image: postgres
16+
image: postgres
1717
environment:
1818
- POSTGRES_PASSWORD=s3cr3t
1919
networks:
@@ -23,8 +23,7 @@ services:
2323

2424
networks:
2525
haknet:
26-
driver: bridge
26+
driver: bridge
2727

2828
volumes:
2929
db:
30-

README.md

Lines changed: 88 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,115 @@
11
# AutoSploit
22

3-
As the name might suggest AutoSploit attempts to automate the exploitation of remote hosts. Targets are collected automatically as well by employing the Shodan.io API. The program allows the user to enter their platform specific search query such as; `Apache`, `IIS`, etc, upon which a list of candidates will be retrieved.
4-
5-
After this operation has been completed the 'Exploit' component of the program will go about the business of attempting to exploit these targets by running a series of Metasploit modules against them. Which Metasploit modules will be employed in this manner is determined by programmatically comparing the name of the module to the initial search query. However, I have added functionality to run all available modules against the targets in a 'Hail Mary' type of attack as well.
6-
7-
The available Metasploit modules have been selected to facilitate Remote Code Execution and to attempt to gain Reverse TCP Shells and/or Meterpreter sessions. Workspace, local host and local port for MSF facilitated back connections are configured through the dialog that comes up before the 'Exploit' component is started.
3+
As the name might suggest AutoSploit attempts to automate the exploitation of remote hosts. Targets can be collected automatically through Shodan, Censys or Zoomeye. But options to add your custom targets and host lists have been included as well.
4+
The available Metasploit modules have been selected to facilitate Remote Code Execution and to attempt to gain Reverse TCP Shells and/or Meterpreter sessions. Workspace, local host and local port for MSF facilitated back connections are configured by filling out the dialog that comes up before the exploit component is started
85

96
**Operational Security Consideration**
107

118
Receiving back connections on your local machine might not be the best idea from an OPSEC standpoint. Instead consider running this tool from a VPS that has all the dependencies required, available.
129

10+
The new version of AutoSploit has a feature that allows you to set a proxy before you connect and a custom user-agent.
11+
1312
## Usage
1413

15-
Clone the repo. Or deploy via Docker. Details for which can be found [here](https://github.com/NullArray/AutoSploit/tree/master/Docker) Special thanks to [Khast3x](https://github.com/khast3x) for their contribution in this regard.
14+
Clone the repo. Or deploy via Docker. Details for which can be found [here](https://github.com/NullArray/AutoSploit/tree/master/Docker)
1615

1716
`git clone https://github.com/NullArray/AutoSploit.git`
1817

19-
After which it can be started from the terminal with `python autosploit.py`. After which you can select one of five actions. Please see the option summary below.
18+
Starting the program with `python autosploit.py` will open an AutoSploit terminal session. The options for which are as follows.
19+
2020
```
21-
+------------------+----------------------------------------------------+
22-
| Option | Summary |
23-
+------------------+----------------------------------------------------+
24-
|1. Usage | Display this informational message. |
25-
|2. Gather Hosts | Query Shodan for a list of platform specific IPs. |
26-
|3. View Hosts | Print gathered IPs/RHOSTS. |
27-
|4. Exploit | Configure MSF and Start exploiting gathered targets|
28-
|5. Quit | Exits AutoSploit. |
29-
+------------------+----------------------------------------------------+
21+
1. Usage And Legal
22+
2. Gather Hosts
23+
3. Custom Hosts
24+
4. Add Single Host
25+
5. View Gathered Hosts
26+
6. Exploit Gathered Hosts
27+
99. Quit
3028
```
31-
## Available Modules
32-
The Metasploit modules available with this tool are selected for RCE. You can find them in the `modules.txt` file that is included in this repo. Should you wish to add more or other modules please do so in the following format.
29+
30+
Choosing option `2` will prompt you for a platform specific search query. Enter `IIS` or `Apache` in example and choose a search engine. After doing so the collected hosts will be saved to be used in the `Exploit` component.
31+
32+
As of version 2.0 AutoSploit can be started with a number of command line arguments/flags as well. Type `python autosploit.py -h`
33+
to display all the options available to you. I've posted the options below as well for reference.
34+
3335
```
34-
use exploit/linux/http/netgear_wnr2000_rce;exploit -j;
36+
usage: python autosploit.py -[c|z|s|a] -[q] QUERY
37+
[-C] WORKSPACE LHOST LPORT [-e]
38+
[--ruby-exec] [--msf-path] PATH [-E] EXPLOIT-FILE-PATH
39+
[--rand-agent] [--proxy] PROTO://IP:PORT [-P] AGENT
40+
41+
optional arguments:
42+
-h, --help show this help message and exit
43+
44+
search engines:
45+
possible search engines to use
46+
47+
-c, --censys use censys.io as the search engine to gather hosts
48+
-z, --zoomeye use zoomeye.org as the search engine to gather hosts
49+
-s, --shodan use shodan.io as the search engine to gather hosts
50+
-a, --all search all available search engines to gather hosts
51+
52+
requests:
53+
arguments to edit your requests
54+
55+
--proxy PROTO://IP:PORT
56+
run behind a proxy while performing the searches
57+
--random-agent use a random HTTP User-Agent header
58+
-P USER-AGENT, --personal-agent USER-AGENT
59+
pass a personal User-Agent to use for HTTP requests
60+
-q QUERY, --query QUERY
61+
pass your search query
62+
63+
exploits:
64+
arguments to edit your exploits
65+
66+
-E PATH, --exploit-file PATH
67+
provide a text file to convert into JSON and save for
68+
later use
69+
-C WORKSPACE LHOST LPORT, --config WORKSPACE LHOST LPORT
70+
set the configuration for MSF (IE -C default 127.0.0.1
71+
8080)
72+
-e, --exploit start exploiting the already gathered hosts
73+
74+
misc arguments:
75+
arguments that don't fit anywhere else
76+
77+
--ruby-exec if you need to run the Ruby executable with MSF use
78+
this
79+
--msf-path MSF-PATH pass the path to your framework if it is not in your
80+
ENV PATH
3581
```
36-
With each new module on it's own line.
82+
3783

3884
## Dependencies
85+
3986
AutoSploit depends on the following Python2.7 modules.
87+
4088
```
41-
shodan
42-
blessings
89+
requests
90+
psutil
4391
```
92+
4493
Should you find you do not have these installed get them with pip like so.
94+
95+
```bash
96+
pip install requests psutil
4597
```
46-
pip install shodan
47-
pip install blessings
98+
99+
or
100+
101+
```bash
102+
pip install -r requirements.txt
48103
```
49-
Since the program invokes functionality from the Metasploit Framework you need to have this installed also.
50-
Get it from Rapid7 by clicking [here](https://www.rapid7.com/products/metasploit/).
104+
105+
Since the program invokes functionality from the Metasploit Framework you need to have this installed also. Get it from Rapid7 by clicking [here](https://www.rapid7.com/products/metasploit/).
106+
107+
## Acknowledgements
108+
109+
Special thanks to [Ekultek](https://github.com/Ekultek) without whoms contributions to the project version 2.0 would have been a lot less spectacular.
110+
111+
And thanks to [Khast3x](https://github.com/khast3x) for setting up Docker support.
112+
51113

52114

53115
### Active Development
@@ -60,7 +122,4 @@ that have expressed an interest in doing so. The new version will include extra
60122

61123
If you happen to encounter a bug please feel free to [Open a Ticket](https://github.com/NullArray/AutoSploit/issues).
62124

63-
If you wish to contribute to the development of this project please be sure to read [CONTRIBUTING.md](https://github.com/NullArray/AutoSploit/blob/master/CONTRIBUTING.md) before you get started as it contains our contribution guidelines.
64-
65125
Thanks in advance.
66-

api_calls/__init__.py

Whitespace-only changes.

api_calls/censys.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import requests
2+
3+
import lib.settings
4+
from lib.errors import AutoSploitAPIConnectionError
5+
from lib.settings import (
6+
HOST_FILE,
7+
API_URLS,
8+
write_to_file
9+
)
10+
11+
12+
class CensysAPIHook(object):
13+
14+
"""
15+
Censys API hook
16+
"""
17+
18+
def __init__(self, identity=None, token=None, query=None, proxy=None, agent=None, **kwargs):
19+
self.id = identity
20+
self.token = token
21+
self.query = query
22+
self.proxy = proxy
23+
self.user_agent = agent
24+
self.host_file = HOST_FILE
25+
26+
def censys(self):
27+
"""
28+
connect to the Censys API and pull all IP addresses from the provided query
29+
"""
30+
discovered_censys_hosts = set()
31+
try:
32+
lib.settings.start_animation("searching Censys with given query '{}'".format(self.query))
33+
req = requests.post(
34+
API_URLS["censys"], auth=(self.id, self.token),
35+
json={"query": self.query}, headers=self.user_agent,
36+
proxies=self.proxy
37+
)
38+
json_data = req.json()
39+
for item in json_data["results"]:
40+
discovered_censys_hosts.add(str(item["ip"]))
41+
write_to_file(discovered_censys_hosts, self.host_file)
42+
return True
43+
except Exception as e:
44+
raise AutoSploitAPIConnectionError(str(e))

0 commit comments

Comments
 (0)