199 字
1 分钟
Installing Metasploit in WSL

https://mirrors.tuna.tsinghua.edu.cn/help/debian/Tsinghua’s Debian domestic mirror

Change the system language to Chinese#

Terminal window
sudo dpkg-reconfigure locales
#勾上zh_CN GB2312 zh_CN.GBK GBK zh_CN.UTF-8 UTF-8
#重启生效

Install metasploit-framework#

Terminal window
sudo nano /etc/apt/sources.list
#加入下面这一行
deb http://mirrors.aliyun.com/kali kali-rolling main non-free contrib
Terminal window
sudo wget -q -O - https://archive.kali.org/archive-key.asc | sudo apt-key add
sudo apt update
sudo apt install metasploit-framework

Connect to the database#

Connecting metasploit to a database in WSL is a bit troublesome. If you follow the normal procedure, you’ll get the error below.

Terminal window
msfconsole
>db_status
postgresql selected,no connect
>msfdb init
System has not been booted with systemd as init system (PID 1). Can't operate.

The reason is that WSL doesn’t have systemd when it starts.

Solution#

Start the database service

Terminal window
msfdb init
sudo service postgresql start
sudo service postgresql status

Manually create the database user and database

Terminal window
#
cd /etc/postgresql/13/main
sudo -u postgres psql
alter user postgres password 'root';
create user msf with password 'metasploit' createdb;
create database msf with owner=msf;
quit

Connect in metasploit

Terminal window
msfconsole
#db_connect 数据库用户名:数据库密码@数据库ip[:数据库端口]/数据库名
db_connect msf:metasploit@127.0.0.1:5958/msf
db_status

Set up automatic connection

Terminal window
sudo nano /usr/share/metasploit-framework/config/database.yml

Change username and password inside to the ones you set.

Installing Metasploit in WSL
https://tski.uk/blog/en/wsl-metasploit-config/
作者
Tokisaki Galaxy
发布于
2020-10-25
许可协议
CC BY