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.
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.
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.
- The Help command (of course)
- Show payloads
- Show exploits
- Show options
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 listenernc -lnvp 3000 < server.txt
Open Metasploit and type: use scanner/TCPScanner
You 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.