Skip to content

Commit 1112ab5

Browse files
committed
MS-9451 Update Documentation
Updating the documentation to set up the developer environment using Docker.
1 parent 1264fe4 commit 1112ab5

File tree

1 file changed

+77
-21
lines changed

1 file changed

+77
-21
lines changed

docs/metasploit-framework.wiki/dev/Setting-Up-a-Metasploit-Development-Environment.md

Lines changed: 77 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This guide has details for setting up both **Linux** and **Windows**.
2222

2323
### Linux
2424

25-
1. Open a terminal on your Linux host and set up Git, build tools, and Ruby dependencies:
25+
* Open a terminal on your Linux host and set up Git, build tools, and Ruby dependencies:
2626

2727
```bash
2828
sudo apt update && sudo apt install -y git autoconf build-essential libpcap-dev libpq-dev zlib1g-dev libsqlite3-dev
@@ -32,9 +32,9 @@ sudo apt update && sudo apt install -y git autoconf build-essential libpcap-dev
3232

3333
If you are running a Windows machine
3434

35-
1. Install [chocolatey](https://chocolatey.org/)
36-
2. Install [Ruby x64 with DevKit](https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.0.3-1/rubyinstaller-devkit-3.0.3-1-x64.exe)
37-
3. Install pcaprub dependencies from your cmd.exe terminal:
35+
* Install [chocolatey](https://chocolatey.org/)
36+
* Install [Ruby x64 with DevKit](https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.0.3-1/rubyinstaller-devkit-3.0.3-1-x64.exe)
37+
* Install pcaprub dependencies from your cmd.exe terminal:
3838

3939
```
4040
powershell -Command "[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} ; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object System.Net.WebClient).DownloadFile('https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip', 'C:\Windows\Temp\WpdPack_4_1_2.zip')"
@@ -43,7 +43,7 @@ choco install 7zip
4343
7z x "C:\Windows\Temp\WpdPack_4_1_2.zip" -o"C:\"
4444
```
4545

46-
4. Install a version of PostgreSQL:
46+
Install a version of PostgreSQL:
4747

4848
```
4949
choco install postgresql12
@@ -53,9 +53,8 @@ choco install postgresql12
5353

5454
You will need to use Github to create a fork for your contributions and receive the latest updates from our repository.
5555

56-
1. Login to Github and click the "Fork" button in the top-right corner of the [metasploit-framework] repository.
57-
58-
2. Create a `git` directory in your home folder and clone your fork to your local machine:
56+
* Login to Github and click the "Fork" button in the top-right corner of the [metasploit-framework] repository.
57+
* Create a `git` directory in your home folder and clone your fork to your local machine:
5958

6059
```bash
6160
export GITHUB_USERNAME=YOUR_USERNAME_FOR_GITHUB
@@ -66,25 +65,24 @@ git clone [email protected]:$GITHUB_USERNAME/metasploit-framework
6665
cd ~/git/metasploit-framework
6766
```
6867

69-
3. If you encounter a "permission denied" error on the above command, research the error message. If there isn't an explicit reason given, confirm that your [Github SSH key is configured correctly][github-ssh-instructions]. You will need to associate your [public SSH key][ssh-key] with your GitHub account, otherwise if you set up a SSH key and don't associate it with your GitHub account, you will receive this "permission denied" error.
70-
71-
4. To receive updates, you will create an `upstream-master` branch to track the Rapid7 remote repository, alongside your `master` branch which will point to your personal repository's fork:
68+
* If you encounter a "permission denied" error on the above command, research the error message. If there isn't an explicit reason given, confirm that your [Github SSH key is configured correctly][github-ssh-instructions]. You will need to associate your [public SSH key][ssh-key] with your GitHub account, otherwise if you set up a SSH key and don't associate it with your GitHub account, you will receive this "permission denied" error.
69+
* To receive updates, you will create an `upstream-master` branch to track the Rapid7 remote repository, alongside your `master` branch which will point to your personal repository's fork:
7270

7371
```bash
7472
git remote add upstream [email protected]:rapid7/metasploit-framework.git
7573
git fetch upstream
7674
git checkout -b upstream-master --track upstream/master
7775
```
7876

79-
5. Configure your Github username, email address, and username. Ensure your `user.email` matches the email address you registered with your Github account.
77+
* Configure your Github username, email address, and username. Ensure your `user.email` matches the email address you registered with your Github account.
8078

8179
```bash
8280
git config --global user.name "$GITHUB_USERNAME"
8381
git config --global user.email "$GITHUB_EMAIL"
8482
git config --global github.user "$GITHUB_USERNAME"
8583
```
8684

87-
6. Set up [msftidy] to run before each `git commit` and after each `git merge` to quickly identify potential issues with your contributions:
85+
* Set up [msftidy] to run before each `git commit` and after each `git merge` to quickly identify potential issues with your contributions:
8886

8987
```bash
9088
cd ~/git/metasploit-framework
@@ -129,27 +127,83 @@ Congratulations! You have now set up a development environment and the latest ve
129127

130128
## Optional: Set up the REST API and PostgreSQL database
131129

132-
The following optional section describes how to manually install PostgreSQL and set up the Metasploit database. Alternatively, use our Omnibus installer which handles this more reliably.
130+
Installing the REST API and PostgreSQL is optional, and can be done in two ways.
131+
Recommended is to use the Docker approach, and fairly simple to do once you have docker installed on your
132+
system, [Docker Desktop][docker-desktop] is recommended, but not mandatory.
133+
On Linux systems, simply having docker-cli is sufficient.
134+
135+
### Docker Installation
136+
137+
**Make sure, you have docker available on your system: [Docker Installation Guide][docker-installation]**
133138

134-
1. Confirm that the PostgreSQL server and client are installed:
139+
**Note**: Depending on your environment, these commands might require `sudo`
140+
141+
* Pull the Docker container: `docker pull postgres:14`
142+
* Start the container:
143+
144+
```bash
145+
docker run --rm -p 127.0.0.1:5432:5432 -e POSTGRESS_PASSWORD="mysecretpassword" postgres:14
146+
```
147+
148+
Wait till the container is fully running.
149+
We need to make some changes in the container to be able to connect to it remotely using the `psql` client.
150+
151+
* Open a shell to the running container: `docker exec -it "postgres" bash`
152+
* Install an editor: `sudo apt update && sudo apt install -y nano`
153+
* Edit `/var/lib/postgresql/data/postgresql.conf` and uncomment: `# password_encryption = scram-sha-256 # scram-sha-256 or md5`
154+
* Exit the shell on the container
155+
* Ensure the postgres client is installed on your host system
156+
* connect to the running container (the password is `mysecretpassword`): `psql -h 127.0.0.1 -U postgres`
157+
158+
After this you should be able to connect with the `postgres` user using the password from the commands.
159+
We highly recommend to use the same credentials and use the `database.yml` below as example.
160+
With this approach you do not require the `./msfdb init` command. The standard Rails commands for creating
161+
the database are sufficient: `bundle exec rails db:create db:migrate db:seed`
162+
163+
### database.yml
164+
165+
```yaml
166+
development: &defaults
167+
adapter: postgresql
168+
database: metasploit_pro_development
169+
username: postgres
170+
password: mysecretpassword
171+
host: 127.0.0.1
172+
port: 5432
173+
pool: 200
174+
timeout: 5
175+
176+
production:
177+
<<: *defaults
178+
database: metasploit_pro_production
179+
180+
test:
181+
<<: *defaults
182+
database: metasploit_pro_test
183+
```
184+
185+
### Manual Installation
186+
187+
The following optional section describes how to manually install PostgreSQL and set up the Metasploit database.
188+
Alternatively, use our Omnibus installer which handles this more reliably.
189+
190+
* Confirm that the PostgreSQL server and client are installed:
135191
136192
```bash
137193
sudo apt update && sudo apt-get install -y postgresql postgresql-client
138194
sudo service postgresql start && sudo update-rc.d postgresql enable
139195
```
140196

141-
2. Ensure that you are not running as the root user.
142-
143-
3. Initialize the Metasploit database:
197+
* Ensure that you are not running as the root user.
198+
* Initialize the Metasploit database:
144199

145200
```bash
146201
cd ~/git/metasploit-framework
147202
./msfdb init
148203
```
149204

150-
4. If you receive an error about a component not being installed, confirm that the binaries shown are in your path using the [which] and [find] commands, then modifying your [$PATH] environment variable. If it was something else, open a [new issue] to let us know what happened.
151-
152-
5. If the `msfdb init` command succeeds, then confirm that the database is accessible to Metasploit:
205+
* If you receive an error about a component not being installed, confirm that the binaries shown are in your path using the [which] and [find] commands, then modifying your [$PATH] environment variable. If it was something else, open a [new issue] to let us know what happened.
206+
* If the `msfdb init` command succeeds, then confirm that the database is accessible to Metasploit:
153207

154208
```bash
155209
$ ./msfconsole -qx "db_status; exit"
@@ -272,3 +326,5 @@ Finally, we welcome your feedback on this guide, so feel free to reach out to us
272326
[@ffmike]:https://github.com/ffmike
273327

274328
[BetterSpecs.org]:https://www.betterspecs.org/
329+
[docker-desktop]:https://www.docker.com/products/docker-desktop/
330+
[docker-installation]:https://www.docker.com/get-started/

0 commit comments

Comments
 (0)