Skip to content

Instantly share code, notes, and snippets.

@Nygosaki
Last active April 17, 2023 18:49
Show Gist options
  • Save Nygosaki/02932c3448d2966fb25f0fddd926c662 to your computer and use it in GitHub Desktop.
Save Nygosaki/02932c3448d2966fb25f0fddd926c662 to your computer and use it in GitHub Desktop.
Setting up Metasploit on a non-Kali system, or a VPS.

Prerequisites

In order to get Metasploit Framework working, your machine or VPS has to have at least 2GB of RAM. If you want to setup a database, 4GB is reccomended.
If you do not have a machine with this much RAM, or are renting a VPS, you should search how to do Paging, although please note that your RAM will be extremely slow.

Not Enough RAM - Setting Up Paging

Getting the Paging file ready

If you have enough ram, feel free to skip this section.
By setting up Paging, we are repurposing your storage and using it as very slow RAM.
Please note, that if you are not running as root, you will need to have sudo before most of these commands. If it says Permissions Denied or something similiar, add sudo. For example, instead of touch swap.img, write sudo touch swap.img.

  1. Run free in order to see how much RAM you currently have.
    image
  2. Run the commands cd /var which sets your directory to /var/.
    image
  3. Then run touch swap.img which creates our paging file in the /var/ directory.
    image
  4. After this we want to set the correct permissions for the swap.img file by running chmod 600 swap.img.
    image

Configuring the Paging

  1. We will now run dd if=/dev/zero of=/var/swap.img bs=1024k count=1000 in order to allocate the storage for paging. This specific command allocates 1GB, but if you need more eddit the command as appropriate.
    image
  2. After this, run the command mkswap /var/swap.img
    image
  3. and swapon /var/swap.img in order to setup the paging.
    image
  4. Now run free again in order to compare the RAM difference.
    image
  5. Restart your device before proceeding.

Initial Setup - Setting up Ruby

First of all, we have to setup Ruby. Feel free to skip this part if ruby is already working on your device.

Installing RVM

  1. first we want to install rvm by running \curl -L https://get.rvm.io | bash -s stable. If you get a message that tells you that the keys could not be verified, run all the commands it instructs you to run, restart your device, and then try this command again.
  2. Restart your device

Installing Rubi & Setup

  1. Download the appropriate Ruby version. I personally want to insteall Ruby 1.9.3, so I ran rvm install 1.9.3 but I reccomend installing 2 versions bellow the newest version. YOu can find out what the newest version is by going to Ruby's website. For example, If the newest version is 3.2.3, I reccomend installing Ruby 3.2.1.
    image
  2. Next, we will create a gemset with the command rvm gemset create rails3.
    image
  3. Now we will use the Ruby version you downlaoded as a defualt for the Gemset. As I downloaded 1.9.3, I will run the command rvm use 1.9.3@rails3 --default. image
  4. Now, as the last step, wil will download rails with gem install rails --pre --no-document.
  5. Restart your device.

Installing Metaspoit-franework

Now, the final part is installing metasploit itself. This is suprisingly easy.

  1. Run sudo snap install metasploit-framework. Although the Snap version of metasploit is outdated most of the time, it is the easiest way of installing Metasploit on non-kali machines, and the only functioning way I have found. I think that it is well worth the trade off.
  2. Run msfconsole and enjoy your Metasploit!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment