-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Docker refactor #660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Docker refactor #660
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,17 @@ | ||
FROM kalilinux/kali-linux-docker | ||
FROM phocean/msf | ||
|
||
RUN apt update \ | ||
&& apt install -y \ | ||
apache2 \ | ||
build-essential \ | ||
git \ | ||
metasploit-framework \ | ||
postgresql \ | ||
python-dev \ | ||
python-pip | ||
COPY "entrypoint.sh" . | ||
|
||
RUN git clone https://github.com/NullArray/AutoSploit.git \ | ||
&& pip install -r AutoSploit/requirements.txt | ||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
git \ | ||
python-dev \ | ||
python-pip \ | ||
apache2 | ||
|
||
COPY database.yml /root/.msf4/database.yml | ||
|
||
WORKDIR AutoSploit | ||
|
||
EXPOSE 80 443 4444 | ||
|
||
ENTRYPOINT ["python", "autosploit.py"] | ||
# ENTRYPOINT ["bash"] | ||
RUN chmod +x entrypoint.sh && \ | ||
git clone https://github.com/NullArray/AutoSploit.git && \ | ||
pip install -r AutoSploit/requirements.txt | ||
|
||
EXPOSE 4444 | ||
CMD [ "./entrypoint.sh" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,19 @@ | ||
# Docker deployment instructions | ||
|
||
## tl;dr | ||
|
||
Using [docker-compose](https://docs.docker.com/compose/install/): | ||
## From Dockerhub | ||
|
||
```bash | ||
git clone https://github.com/NullArray/AutoSploit.git | ||
cd Autosploit/Docker | ||
docker-compose run --rm autosploit | ||
> docker run -it battlecl0ud/autosploit | ||
``` | ||
|
||
Using just Docker: | ||
*Ideally this is to be replaced by project author's dockerhub account* | ||
|
||
```bash | ||
git clone https://github.com/NullArray/AutoSploit.git | ||
cd Autosploit/Docker | ||
# If you wish to edit default postgres service details, edit database.yml. Should work out of the box | ||
# nano database.yml | ||
docker network create -d bridge haknet | ||
docker run --network haknet --name msfdb -e POSTGRES_PASSWORD=s3cr3t -d postgres | ||
docker build -t autosploit . | ||
docker run -it --network haknet -p 80:80 -p 443:443 -p 4444:4444 autosploit | ||
``` | ||
|
||
## Abstract | ||
|
||
- Launching `Autosploit` as a Docker container makes it very easy to use the tool in a hosted cloud environment (AWS, Azure, ...) | ||
- Separate `postgres` database into individual service for data persistence and potential async updating of the database | ||
- Create a small bridge network `haknet` so the service discovery is automatic | ||
- Launch `postgres` and `Autosploit` container, both linked by `haknet` | ||
- Autosploit will automatically launch preconfigured `msfconsole` to the external `postgres` container through `haknet` transparent network | ||
- Total image size of Kali + Metasploit + Autosploit : 1.75GB | ||
|
||
## Deploy | ||
|
||
### Step 1 - Create bridge network | ||
|
||
This will enable the Metasploit Framework to talk to the `postgres` database using its hostname, making it abstract. | ||
|
||
A Tor Socks Proxy can also be added to perform transparent proxy when launching exploits (not for reverse shells though, obviously). | ||
|
||
```bash | ||
docker network create -d bridge haknet | ||
``` | ||
|
||
### Step 2 - Launch services | ||
|
||
All automagically linked | ||
|
||
#### Step 2.1 - Launch postgres | ||
|
||
Launch a vanilla `postgres` service, linked to `haknet` | ||
|
||
```bash | ||
docker run --network haknet --name msfdb -e POSTGRES_PASSWORD=s3cr3t -d postgres | ||
``` | ||
|
||
#### Step 2.2 - Launch Autosploit | ||
|
||
Launch `Autosploit`. | ||
|
||
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. | ||
|
||
Please be aware that the first build will take some time (~10mn) | ||
|
||
Building will be faster if done on a hosted server as it benefits from the -grade bandwidth | ||
## Build it yourself | ||
|
||
```bash | ||
git clone https://github.com/NullArray/AutoSploit.git | ||
cd Autosploit/Docker | ||
nano database.yml # Exemple configuration should work fine | ||
docker build -t autosploit . | ||
docker run -it --network haknet -p 80:80 -p 443:443 -p 4444:4444 autosploit | ||
> git clone https://github.com/NullArray/AutoSploit.git | ||
> cd Autosploit/Docker | ||
> docker build -t autosploit . | ||
> docker run -it autosploit | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
/etc/init.d/postgresql start | ||
/etc/init.d/apache2 start | ||
cd AutoSploit/ | ||
|
||
python autosploit.py |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably reflect the changes in the main README.md as well. Or at least leave a reference to the readme that currently lives in the docker directory.
Wiki entry might be appropriate as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright i did the main README.md for now. Just wanted to post that here.