Metasploit Fundamentals

  • Basic commands of Metasploit
  • Payload types
  • Generating payloads in Metasploit

Basic Commands of Metasploit

In this article we will be talking about the very basics of Metasploit and the Metasploit commands used in the command line interface.

Before Knowing the commands of metasploit first be aware about your system updates, These are some necessary commands to update your OS.
apt-get update

apt-get upgrade

apt-get dist-upgrade

Dont ever try to update metasploit with the command Msfupdate whithout knowing what you are going to do.

You can open metasploit by using the terminal command msfconsole which will open up with a metasploit banner as belowmsfconsole

Now we are in msfconole which can be nicknamed as metasploit terminal or console,
every command related to metasplot should be executed here.
list of some commands and what they do.

*every command will be bold and Italic [ command ] in this blog


You can further refine your searches by using the built-in keyword


The ‘set’ command allows you to configure Framework options and parameters for the current module you are working with.



Executing ‘show auxiliary’ will display a listing of all of the available auxiliary modules within Metasploit. As mentioned earlier, auxiliary modules include scanners, denial of service modules, fuzzers, and more.



Naturally, ‘show exploits’ will be the command you are most interested in running since at its core, Metasploit is all about exploitation. Run ‘show exploits’ to get a listing of all exploits contained in the framework.



Running ‘show payloads’ will display all of the different payloads for all platforms available within Metasploit.



The ‘use’ command changes your context to a specific module, exposing type-specific commands.



This command takes back to your root terminal or the default terminal.


These are some basic commands.

Now how to use an exploit in metasploit, assuming we know what exploit we want to use. In further we will discuss what are the very useful and commonly used exploits.

use  exploit/windows/smb/ms09_050_smb2_negotiate_func_index 

This is the exploit and use the command ‘use’ to select it then you can see some considerable changes in the msfconsole in a way that a particular exploit was selected.

followed by these commands to clear if any necessary and set them with the set command

show targets : provides you the info about what type of machine can be attacked

show payload : Show you the list of payloads that will be valid for this chosen exploit

Now set  the required payload with the set command from the list of shown payloads from the command show payload . 

exset payload windows/meterpreter/reverse_tcp          where “windows/meterpreter/reverse_tcp” is one of the payloads in the list of show payload.

show options : After setting the payload, this command will provide you the info about the necessary details required to fill the variable that are present in our selected payload.

ex : If “x” is a variable that should be fulfilled our payload before execution,                  show options will provide you a info about “x” by using this you will never struck in an error before executing the code.

show advanced : Similar to show options but some advanced, but without setting this will not lead to any error.

show evasion ; Similar to show options.

  • Payload types.

There are many types of payload

  1. Inline (Non Staged)
  2. Staged
  3. Meterpreter
  4. PassiveX
  5. NoNX
  6. Ord
  7. Ipv6
  8. Reflection Dll Injection

All these types are not necessary to explain now, But if someone is interested you can contact me.

For now we will just concentrate with the Meterpreter type payloads.

 Meterpreter :The short form of Meta-Interpreter is an advanced, multi-faceted payload that operates via dll injection. The Meterpreter resides completely in the memory of the remote host and leaves no traces on the hard drive, making it very difficult to detect with conventional forensic techniques. Scripts and plugins can be loaded and unloaded dynamically as required.

  • Generating Payloads in Metasploit

Payloads can be generated in Metasploit by the following commands from your root terminal

  1. msfconsole  : Takes us to metasploit termnal from root terminal
  2. search payload : Lists us a lot of payload and select a useful payload for your attack, you can learn about payloads later, for now we are using some random payload.
  3. use payload/windows/shell_bind_tcp : After selecting a payload select it by using the command ‘use’
  4. generate : Which will generate you a raw code which can be even generated in many ways by using the command below.
  5. By using tags of generate -h which will list you a lot of external tags similar to “-h”

You can even generate payloads in many ways,you can use socialengineeringtoolkit, the command for that is setoolkit in root terminal, but the way we generate is a bit different.

There are many other external ways too,

like Veilevasion, this is on of the greatest way to create an antivirus undetected payload, we will look about these in detail later.

I guess for now you are able to create your own payload given the name of the payload, remember some payloads need to be filled with the necessary variables, so never forget to use the command show options after selecting the payload, In the previous generated payload by us there are no any predefined variables so, I never checked it.

After a lot of practice and usage you will be capable of selecting a payload just with the situation and you will be aware of the variables too.

My contact details.


For any doubts and suggestions comment below.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s