Metasploit: Advanced Penetration Testing

December 31, 2015 | Views: 9015

Begin Learning Cyber Security for FREE Now!

FREE REGISTRATIONAlready a Member Login Here

Metasploit Advanced Penetration Testing

Cyber risks: a severe and present danger that everything is under attack.

Did you know: “The annual cost of cybercrime to the global economy ranges from $375 billion to as much as $575 billion”?


Are you ready to defend Hackers? First, let’s define “Hackers?”

Hackers are intelligent individuals with: excellent computer skills and abilities to create and explore computer software and hardware.

For some hackers, hacking is a hobby to see how many computers they can compromise. Their intention can either be to gain knowledge or to poke around to do illegal things.


Classes of Hackers

Black Hat Hackers: Individuals with extraordinary computing skills who often engage in malicious or destructive activities. Also known as Crackers.

White Hat Hackers: Individuals professing hacker skills and using them for defensive purposes. Also known as Security Analysts.

Grey Hat Hackers: Individuals who work both offensively and defensively at various times.


Hacking Phases



Penetration Testing (or Pentesting)

Pentesting is an evaluation process of the security of an IT structure. It’s based on a simple premise: if you want to defend hackers you need to think like hackers.

If you know the enemy and know yourself, you need not fear the result of a hundred battles.  Sun Tzu


Introduction to Metasploit

Metasploit Framework is an open source penetration testing tools developed by HD Moore. It was coded in Perl. Later, it was shifted to Ruby with a lots of features.


Metasploit Architecture


Starting Metasploit

Note: For the demonstration, I’m using Kali Linux, Version 1.0.6.

To start Metasploit, open the shell and enter: msfconsole


In this case, I’m using the console Mode (msfconsole). Metasploit has other interfaces like: MSFcli (it’s like MSFconsole but not interactive), MSFGUI (the graphic version) and ARMITAGE (a powerful GUI interface)





Before diving into Metasploit Powerful commands, let’s check the MSFramework components:

MSFPayload: is the script that you want to run on the target machine after the exploitation

MSFEncode: is an amazing utility to avoid the detection of the payload

MSFVenom: is like a combination between the two previous utilities. It’s a new feature in Metasploit.


Metasploit Commands

  • The Help command (of course)
  • Show payloads
  • Show exploits
  • Show options
  • MSFupdate
  • Use
  • Search
  • Exploit

And many other commands…


PS: You can also do an Nmap scan using Metasploit, exporting the results and importing them later from the database (MS uses Postgresql database).

Msf> nmap [target] -oX [output]


Write Your Own Metasploit Module

As mentioned above, a White Hat Hacker should know how to write their own tools and scripts. So, let’s see how to create a simple Metasploit module. In this demonstration, we’ll use Ruby as a programming language and we’ll build a TCP Scanner.

First, create a Ruby file:



Now, save it at: usr/share/metasploit-framework/modules/auxiliary/scanner

To test the response, create a text file called server.txt and setup a netcat listener

nc -lnvp 3000 < server.txt



Open Metasploit and type: use scanner/TCPScanner


8You can report the results by including: include Msf::Auxiliary::Report

Use this method (example):

results ( :host => rhost,  :data => data )


That’s it! If you want to ask anything or correct something, please don’t hesitate to contact me.

Share with Friends
Use Cybytes and
Tip the Author!
Share with Friends
Ready to share your knowledge and expertise?
  1. good information testing point of view

Page 3 of 3«123
Comment on This

You must be logged in to post a comment.

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Support Cybrary

Donate Here to Get This Month's Donor Badge


We recommend always using caution when following any link

Are you sure you want to continue?