{"id":11455,"date":"2022-02-05T17:37:25","date_gmt":"2022-02-05T14:37:25","guid":{"rendered":"https:\/\/kifarunix.com\/?p=11455"},"modified":"2024-03-09T10:14:32","modified_gmt":"2024-03-09T07:14:32","slug":"install-metasploit-framework-on-ubuntu-22-04-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-metasploit-framework-on-ubuntu-22-04-ubuntu-20-04\/","title":{"rendered":"Install Metasploit Framework on Ubuntu 22.04\/Ubuntu 20.04"},"content":{"rendered":"\n<p>In this tutorial, you will learn how to install Metasploit Framework on Ubuntu 22.04\/Ubuntu 20.04 LTS. <a href=\"https:\/\/www.metasploit.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Metasploit Framework<\/a> provides a platform and tools for performing deep system security auditing as well as penetration testing to unearth, exploit and validate every other would-be vulnerability.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-metasploit-on-ubuntu-18-04-lts\">Install Metasploit Framework on Ubuntu 22.04\/Ubuntu 20.04<\/h2>\n\n\n\n<p>Metasploit is available in both the commercial and opensource version (thanks to Rapid 7 for teaming up with OSS community).<\/p>\n\n\n\n<p>In this tutorial, we will install the opensource version of Metasploit using the <a href=\"https:\/\/github.com\/rapid7\/metasploit-framework\/wiki\/Nightly-Installers\" target=\"_blank\" rel=\"noreferrer noopener\">Nightly build installers<\/a>. The Nightly installers ship with all the dependencies required for a successful installation and all you need to do the installation is just a simple script.<\/p>\n\n\n\n<p>Before you proceed, check the minimum system <a href=\"https:\/\/www.rapid7.com\/products\/metasploit\/system-requirements\/\" target=\"_blank\" rel=\"noreferrer noopener\">requirements<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"run-system-update\">RUn System Update<\/h3>\n\n\n\n<p>To begin with, update and upgrade your system.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update<\/code><\/pre>\n\n\n\n<pre id=\"block-5dd7b307-a371-471f-8219-5e4c78f7dce0\" class=\"wp-block-code\"><code>sudo apt upgrade -y<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-postgresql-metasploit-database-backend\">Install PostgreSQL Metasploit Database Backend;<\/h3>\n\n\n\n<p>Run the command below to install PostgreSQL database backend for Metasploit.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install postgresql postgresql-contrib -y<\/code><\/pre>\n\n\n\n<p>Next, run start and enable PostgreSQL service to run on boot;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl enable --now postgresql<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"download-metasploit-opensource-installer\">Download Metasploit Opensource Installer<\/h3>\n\n\n\n<p>If you want to install the Pro versions, installers are available on&nbsp;<a href=\"https:\/\/github.com\/rapid7\/metasploit-framework\/wiki\/Downloads-by-Version\" target=\"_blank\" rel=\"noreferrer noopener\">Metasploit framework wiki&#8217;s page<\/a> or <a href=\"https:\/\/www.metasploit.com\/download\" target=\"_blank\" rel=\"noreferrer noopener\">Metasploit Download&#8217;s page<\/a>.<\/p>\n\n\n\n<p>For our opensource versions, run the command below to download installer script.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl https:\/\/raw.githubusercontent.com\/rapid7\/metasploit-omnibus\/master\/config\/templates\/metasploit-framework-wrappers\/msfupdate.erb &gt; msfinstall<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-metasploit-framework-on-ubuntu-22-04-ubuntu-20-04\">Install Metasploit Framework on Ubuntu<\/h3>\n\n\n\n<p>Once the download completes, make the installer executable by running the command below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod +x msfinstall<\/code><\/pre>\n\n\n\n<p>Next, launch the Metasploit installer.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo .\/msfinstall<\/code><\/pre>\n\n\n\n<p>The command will create Metasploit Framework repository from where Metasploit can be installed.<\/p>\n\n\n\n<p>According to the Wiki&#8217;s page;<\/p>\n\n\n\n<blockquote class=\"wp-block-quote td_quote_box td_box_center is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Once installed, you can launch msfconsole as&nbsp;<code>\/opt\/metasploit-framework\/bin\/msfconsole<\/code>&nbsp;from a terminal window, or depending on your environment, it may already be in your path and you can just run it directly. On first run, a series of prompts will help you setup a database and add Metasploit to your local PATH if it is not already.<\/p>\n\n\n\n<p>These packages integrate into your package manager and can be updated with the&nbsp;<code>msfupdate<\/code>&nbsp;command, or with your package manager. On first start, these packages will automatically setup the database or use your existing database.<\/p>\n<\/blockquote>\n\n\n\n<p>Sample installation command output;<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>Adding metasploit-framework to your repository list..OK\nUpdating package cache..OK\nChecking for and installing update..\nReading package lists... Done\nBuilding dependency tree       \nReading state information... Done\nThe following NEW packages will be installed:\n  metasploit-framework\n0 upgraded, 1 newly installed, 0 to remove and 142 not upgraded.\nNeed to get 266 MB of archives.\nAfter this operation, 655 MB of additional disk space will be used.\nGet:1 http:\/\/downloads.metasploit.com\/data\/releases\/metasploit-framework\/apt lucid\/main amd64 metasploit-framework amd64 6.1.29+20220206112545~1rapid7-1 [266 MB]\nFetched 266 MB in 6min 22s (696 kB\/s)                                                                                                                                      \nSelecting previously unselected package metasploit-framework.\n(Reading database ... 71317 files and directories currently installed.)\nPreparing to unpack ...\/metasploit-framework_6.1.29+20220206112545~1rapid7-1_amd64.deb ...\nUnpacking metasploit-framework (6.1.29+20220206112545~1rapid7-1) ...\nSetting up metasploit-framework (6.1.29+20220206112545~1rapid7-1) ...\nupdate-alternatives: using \/opt\/metasploit-framework\/bin\/msfbinscan to provide \/usr\/bin\/msfbinscan (msfbinscan) in auto mode\nupdate-alternatives: using \/opt\/metasploit-framework\/bin\/msfconsole to provide \/usr\/bin\/msfconsole (msfconsole) in auto mode\nupdate-alternatives: using \/opt\/metasploit-framework\/bin\/msfd to provide \/usr\/bin\/msfd (msfd) in auto mode\nupdate-alternatives: using \/opt\/metasploit-framework\/bin\/msfdb to provide \/usr\/bin\/msfdb (msfdb) in auto mode\nupdate-alternatives: using \/opt\/metasploit-framework\/bin\/msfelfscan to provide \/usr\/bin\/msfelfscan (msfelfscan) in auto mode\nupdate-alternatives: using \/opt\/metasploit-framework\/bin\/msfmachscan to provide \/usr\/bin\/msfmachscan (msfmachscan) in auto mode\nupdate-alternatives: using \/opt\/metasploit-framework\/bin\/msfpescan to provide \/usr\/bin\/msfpescan (msfpescan) in auto mode\nupdate-alternatives: using \/opt\/metasploit-framework\/bin\/msfrop to provide \/usr\/bin\/msfrop (msfrop) in auto mode\nupdate-alternatives: using \/opt\/metasploit-framework\/bin\/msfrpc to provide \/usr\/bin\/msfrpc (msfrpc) in auto mode\nupdate-alternatives: using \/opt\/metasploit-framework\/bin\/msfrpcd to provide \/usr\/bin\/msfrpcd (msfrpcd) in auto mode\nupdate-alternatives: using \/opt\/metasploit-framework\/bin\/msfupdate to provide \/usr\/bin\/msfupdate (msfupdate) in auto mode\nupdate-alternatives: using \/opt\/metasploit-framework\/bin\/msfvenom to provide \/usr\/bin\/msfvenom (msfvenom) in auto mode\nRun msfconsole to get started\n<\/code><\/pre>\n\n\n\n<p>When the installation is done, all binary files related to Metasploit should now be under your path;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -1 \/bin\/msf*<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n\/bin\/msfbinscan\n\/bin\/msfconsole\n\/bin\/msfd\n\/bin\/msfdb\n\/bin\/msfelfscan\n\/bin\/msfmachscan\n\/bin\/msfpescan\n\/bin\/msfrop\n\/bin\/msfrpc\n\/bin\/msfrpcd\n\/bin\/msfupdate\n\/bin\/msfvenom\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"initialize-metasploit-database\">Initialize Metasploit Database<\/h3>\n\n\n\n<p>Your Metasploit is now ready.<\/p>\n\n\n\n<p>Create and initialize the msf database as well create the MSF web service. As non root user, run the command below<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>msfdb init<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n[?] Would you like to init the webservice? (Not Required) [no]: yes\n====================================================================\nRunning the 'init' command for the database:\nCreating database at \/home\/kifarunix\/.msf4\/db\nStarting database at \/home\/kifarunix\/.msf4\/db...success\nCreating database users\nWriting client authentication configuration file \/home\/kifarunix\/.msf4\/db\/pg_hba.conf\nStopping database at \/home\/kifarunix\/.msf4\/db\nStarting database at \/home\/kifarunix\/.msf4\/db...success\nCreating initial database schema\n====================================================================\n\n====================================================================\nRunning the 'init' command for the webservice:\n[?] Initial MSF web service account username? [kifarunix]: \n[?] Initial MSF web service account password? (Leave blank for random password): \nGenerating SSL key and certificate for MSF web service\nAttempting to start MSF web service...success\nMSF web service started and online\nCreating MSF web service user kifarunix\n\n    ############################################################\n    ##              MSF Web Service Credentials               ##\n    ##                                                        ##\n    ##        Please store these credentials securely.        ##\n    ##    You will need them to connect to the webservice.    ##\n    ############################################################\n\nMSF web service username: kifarunix\nMSF web service password: password\nMSF web service user API token: 2906c3a503f549528b725187f283254af87554e86fc8897b875883db3b3e6a62665cc715a583fb72\n\n\nMSF web service configuration complete\nThe web service has been configured as your default data service in msfconsole with the name \"local-https-data-service\"\n\nIf needed, manually reconnect to the data service in msfconsole using the command:\ndb_connect --name local-https-data-service --token 2906c3a503f549528b725187f283254af87554e86fc8897b875883db3b3e6a62665cc715a583fb72 --cert \/home\/kifarunix\/.msf4\/msf-ws-cert.pem --skip-verify https:\/\/localhost:5443\n\nThe username and password are credentials for the API account:\nhttps:\/\/localhost:5443\/api\/v1\/auth\/account\n\nPersisting http web data service credentials in msfconsole\n====================================================================\n\n<\/code><\/pre>\n\n\n\n<p>You can see other command options by running;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>msfdb<\/code><\/pre>\n\n\n\n<p>Check database\/web service status;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>msfdb status<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n====================================================================\nRunning the 'status' command for the database:\nDatabase started\n====================================================================\n\n====================================================================\nRunning the 'status' command for the webservice:\nMSF web service is running as PID 83935\n====================================================================\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"launch-msfconsole-on-ubuntu\">Launch Msfconsole on Ubuntu<\/h3>\n\n\n\n<p>The Metasploit Framework is available on command line. To launch it, just execute the command below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>msfconsole<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n ______________________________________________________________________________\n|                                                                              |\n|                   METASPLOIT CYBER MISSILE COMMAND V5                        |\n|______________________________________________________________________________|\n      \\                                  \/                      \/\n       \\     .                          \/                      \/            x\n        \\                              \/                      \/\n         \\                            \/          +           \/\n          \\            +             \/                      \/\n           *                        \/                      \/\n                                   \/      .               \/\n    X                             \/                      \/            X\n                                 \/                     ###\n                                \/                     # % #\n                               \/                       ###\n                      .       \/\n     .                       \/      .            *           .\n                            \/\n                           *\n                  +                       *\n\n                                       ^\n####      __     __     __          #######         __     __     __        ####\n####    \/    \\ \/    \\ \/    \\      ###########     \/    \\ \/    \\ \/    \\      ####\n################################################################################\n################################################################################\n# WAVE 5 ######## SCORE 31337 ################################## HIGH FFFFFFFF #\n################################################################################\n                                                           https:\/\/metasploit.com\n\n\n       =[ metasploit v6.1.29-dev-                         ]\n+ -- --=[ 2197 exploits - 1164 auxiliary - 400 post       ]\n+ -- --=[ 596 payloads - 45 encoders - 11 nops            ]\n+ -- --=[ 9 evasion                                       ]\n\nMetasploit tip: View a module's description using \ninfo, or the enhanced version in your browser with \ninfo -d\n\nmsf6 >\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"run-example-port-scan-on-msfconsole\">Run Example Port Scan on msfconsole<\/h3>\n\n\n\n<p>For Example to launch TCP Scans;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>List available scanners<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>search portscan<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nmsf6 > search portscan\n\nMatching Modules\n================\n\n   #  Name                                              Disclosure Date  Rank    Check  Description\n   -  ----                                              ---------------  ----    -----  -----------\n   0  auxiliary\/scanner\/portscan\/ftpbounce                               normal  No     FTP Bounce Port Scanner\n   1  auxiliary\/scanner\/natpmp\/natpmp_portscan                           normal  No     NAT-PMP External Port Scanner\n   2  auxiliary\/scanner\/sap\/sap_router_portscanner                       normal  No     SAPRouter Port Scanner\n   3  auxiliary\/scanner\/portscan\/xmas                                    normal  No     TCP \"XMas\" Port Scanner\n   4  auxiliary\/scanner\/portscan\/ack                                     normal  No     TCP ACK Firewall Scanner\n   5  auxiliary\/scanner\/portscan\/tcp                                     normal  No     TCP Port Scanner\n   6  auxiliary\/scanner\/portscan\/syn                                     normal  No     TCP SYN Port Scanner\n   7  auxiliary\/scanner\/http\/wordpress_pingback_access                   normal  No     WordPress Pingback Locator\n\n\nInteract with a module by name or index. For example info 7, use 7 or use auxiliary\/scanner\/http\/wordpress_pingback_access\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>info 5<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n\n       Name: TCP Port Scanner\n     Module: auxiliary\/scanner\/portscan\/tcp\n    License: Metasploit Framework License (BSD)\n       Rank: Normal\n\nProvided by:\n  hdm <x@hdm.io>\n  kris katterjohn <katterjohn@gmail.com>\n\nCheck supported:\n  No\n\nBasic options:\n  Name         Current Setting  Required  Description\n  ----         ---------------  --------  -----------\n  CONCURRENCY  10               yes       The number of concurrent ports to check per host\n  DELAY        0                yes       The delay between connections, per thread, in milliseconds\n  JITTER       0                yes       The delay jitter factor (maximum value by which to +\/- DELAY) in milliseconds.\n  PORTS        1-10000          yes       Ports to scan (e.g. 22-25,80,110-900)\n  RHOSTS                        yes       The target host(s), see https:\/\/github.com\/rapid7\/metasploit-framework\/wiki\/Using-Metasploit\n  THREADS      1                yes       The number of concurrent threads (max one per host)\n  TIMEOUT      1000             yes       The socket connect timeout in milliseconds\n\nDescription:\n  Enumerate open TCP services by performing a full TCP connect on each \n  port. This does not need administrative privileges on the source \n  machine, which may be useful if pivoting.\n\nmsf6 >\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Launch TCP Scans;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>use 5<\/code><\/pre>\n\n\n\n<p>Define the hosts range to scan;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>set RHOST 192.168.59.23<\/code><\/pre>\n\n\n\n<p>Sets the&nbsp;number&nbsp;of concurrent&nbsp;threads to&nbsp;use while scanning;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>set THREADS 10<\/code><\/pre>\n\n\n\n<p>Run the scan;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>run<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nmsf6 auxiliary(scanner\/portscan\/tcp) > set RHOST 192.168.59.23\nRHOST => 192.168.59.23\nmsf6 auxiliary(scanner\/portscan\/tcp) > set THREADS 10\nTHREADS => 10\nmsf6 auxiliary(scanner\/portscan\/tcp) > run\n\n[+] 192.168.59.23:        - 192.168.59.23:22 - TCP OPEN\n[+] 192.168.59.23:        - 192.168.59.23:80 - TCP OPEN\n[+] 192.168.59.23:        - 192.168.59.23:443 - TCP OPEN\n[*] 192.168.59.23:        - Scanned 1 of 1 hosts (100% complete)\n[*] Auxiliary module execution completed\nmsf6 auxiliary(scanner\/portscan\/tcp) >\n<\/code><\/pre>\n\n\n\n<p>And there you go. That is all on how to install Metasploit Framework on Ubuntu.<\/p>\n\n\n\n<p>Happy pentesting\u2026<\/p>\n\n\n\n<p>Read More on <a href=\"https:\/\/github.com\/rapid7\/metasploit-framework\/wiki\/Metasploit-Web-Service#getting-started\" target=\"_blank\" rel=\"noreferrer noopener\">Getting started page<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"other-tutorials\">Other Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/installing-metasploit-on-ubuntu-18-04-lts\/\" target=\"_blank\" rel=\"noreferrer noopener\">Installing Metasploit on Ubuntu 18.04 LTS<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-metasploit-framework-on-fedora-29\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Metasploit Framework on Fedora 29<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to install Metasploit Framework on Ubuntu 22.04\/Ubuntu 20.04 LTS. Metasploit Framework provides a platform and tools for performing<\/p>\n","protected":false},"author":3,"featured_media":9713,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,34],"tags":[4564,4563,4556,4557,4560,4559,4562,4561,1200,4412,4558],"class_list":["post-11455","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-security","tag-install-metasploit-on-ubuntu-20-04","tag-install-metasploit-on-ubuntu-22-04","tag-install-metasploit-ubuntu","tag-metasploit-framework","tag-metasploit-port-scan","tag-msfconsole","tag-msfdb-delete","tag-msfdb-init","tag-ubuntu-20-04","tag-ubuntu-22-04","tag-ubuntu-metasploit","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/11455"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=11455"}],"version-history":[{"count":14,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/11455\/revisions"}],"predecessor-version":[{"id":20409,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/11455\/revisions\/20409"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/9713"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=11455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=11455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=11455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}