Skip to content

Instantly share code, notes, and snippets.

@CloudLinuxDeveloper
Created May 14, 2020 08:40
Show Gist options
  • Select an option

  • Save CloudLinuxDeveloper/0dd3470f770ce7a214c9662aa6cacd78 to your computer and use it in GitHub Desktop.

Select an option

Save CloudLinuxDeveloper/0dd3470f770ce7a214c9662aa6cacd78 to your computer and use it in GitHub Desktop.
How to install Metasploit Framework on Ubuntu
# Install metasploit
curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall
chmod 755 msfinstall
./msfinstall
# Create msf database.
msfdb init
# Launch msfconsole
msfconsole
# Verify database connectivity
db_status
# Updating Metasploit Framework
msfupdate
# Check version:
msfconsole --version
@xendaviour
Copy link

if you are okay using snap [ which i was not] you can use
sudo snap install metasploit-framework
or

sudo -i
# 0) Update package lists and install prerequisites
apt update
apt install -y curl gnupg2 gpg-agent dirmngr ca-certificates apt-transport-https

# 1) Remove any broken/old metasploit keyring that caused 'unsupported filetype' errors
rm -f /usr/share/keyrings/metasploit-framework.gpg

# 2) Download Rapid7 signing key and convert to apt keyring (dearmored binary format)
curl -fsSL https://apt.metasploit.com/metasploit-framework.gpg.key \
  | gpg --dearmor \
  | tee /usr/share/keyrings/metasploit-framework.gpg > /dev/null

# 3) Secure the key file permissions
chmod 644 /usr/share/keyrings/metasploit-framework.gpg
chown root:root /usr/share/keyrings/metasploit-framework.gpg

# 4) Ensure the apt source list exists and references the signed-by key
#    If you already have /etc/apt/sources.list.d/metasploit-framework.list from msfinstall, this will overwrite it with the correct line.
echo "deb [signed-by=/usr/share/keyrings/metasploit-framework.gpg] https://apt.metasploit.com/ lucid main" \
  | tee /etc/apt/sources.list.d/metasploit-framework.list

# 5) Update apt and install metasploit-framework via apt
apt update
apt install -y metasploit-framework

# 6) (Optional) If you prefer to use the msfinstall wrapper instead of direct apt:
#    Download the installer wrapper, make it executable and run it (msfinstall will add the repo + key itself)
curl -fsSL https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb -o msfinstall
chmod 755 msfinstall
./msfinstall

# 7) Create / initialize Metasploit DB (msfdb)
#    msfdb is a wrapper that sets up PostgreSQL + Metasploit DB
msfdb init

# 8) Launch msfconsole (interactive)
msfconsole

# 9) From inside msfconsole you can check DB status:
#    (after msfconsole starts, at msf > prompt)
db_status

# 10) Update Metasploit Framework (when needed)
msfupdate

# 11) Check msfconsole version
msfconsole --version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment