Reader small image

You're reading from  Hands-On Red Team Tactics

Product typeBook
Published inSep 2018
Publisher
ISBN-139781788995238
Edition1st Edition
Tools
Right arrow
Authors (2):
Himanshu Sharma
Himanshu Sharma
author image
Himanshu Sharma

Himanshu Sharma, 23, has already achieved fame for finding security loopholes and vulnerabilities in Apple, Google, Microsoft, Facebook, Adobe, Uber, AT&T, Avira, and many more with hall of fame listings as proofs. He has gained worldwide recognition through his hacking skills and contribution to the hacking community. He has helped celebrities such as Harbhajan Singh in recovering their hacked accounts, and also assisted an international singer in tracking down his hacked account and recovering it. He was a speaker at the international conference Botconf '13, held in Nantes, France. He also spoke at IEEE Conference in California and Malaysia as well as for TedX. Currently, he is the cofounder of BugsBounty, a crowd-sourced security platform for ethical hackers and companies interested in cyber services.
Read more about Himanshu Sharma

Harpreet Singh
Harpreet Singh
author image
Harpreet Singh

Harpreet is a professional with 8+ years of experience in the field of Ethical Hacking, Penetration Testing, Vulnerability Research & Red Teaming. He is the author of "Hands-On: Web Penetration Testing with Metasploit" and "Hands-On: Red Team Tactics" published by Packt Publishing. He's also an OSCP, OSWP, CRTP certified professional. Over the years of his experience, Harpreet has acquired the Offensive & Defensive skill set. He is a professional who specializes in Wireless & network exploitation including but not limited to Mobile exploitation, Web Application exploitation and he has also performed few Red Team Engagements in Banks & Financial Groups.
Read more about Harpreet Singh

View More author details
Right arrow

Foreplay - Metasploit Basics

Metasploit is the first tool that comes to mind whenever we think about pentesting or exploitation. The Metasploit framework is a sub-project of the Metasploit project. This helps us by providing information about vulnerabilities, as well as helping us with penetration testing.

Metasploit first came out in 2003. It was developed by H.D. Moore but was later ported to Ruby by 2007. By October 2009, Rapid 7 acquired the Metasploit project. After this, Rapid 7 added Metasploit Express and Metasploit Pro, commercial versions of the product, and then the evolution of the Metasploit framework began.

The Metasploit framework is still an open source framework that allows us to write, test, and execute exploit code. It can also be considered a collection of tools for pentesting and exploitation.

In this chapter, we will cover the basics of installing and using...

Technical requirements

  • Metasploit Framework (MSF)
  • Postgres (PGSQL)
  • Oracle Java 1.7 or later
  • Armitage

Installing Metasploit

Before proceeding with the usage, let's take a look at a quick installation guide. Windows and macOS already have installers available for Metasploit that are available here:

https://github.com/rapid7/metasploit-framework/wiki/Nightly-Installers

Installing on Linux is easy and can be done by using the following command:

curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && \ 
chmod 755 msfinstall && \ 
./msfinstall 

Running Metasploit

Once the installation is done, running Metasploit is pretty simple. To do this, we type the following command in the Terminal:

msfconsole  

After doing this, we should see that the Metasploit framework is up and running. When the msfconsole is loaded for the first time, it asks and automatically creates a database using PostgreSQL for use. This database is used to store the data collected from our scans, exploits, and so on. Every week, new exploits and other modules get added to Metasploit, so it's best that we update it every fortnight. This can be done by using the following command:

 msfupdate 

We now run the help command to see the different features and its usage. Let's go through the basic terminology of Metasploit.

Auxiliaries

...

Armitage and team server

We are all used to the console of msfconsole, which is extremely powerful as it is. However, let's make this even more efficient by using Armitage. This is a Java-based GUI built around Metasploit, which first came out in 2013. Being built on Java makes it cross-platform.

Armitage comes pre-installed in Kali and can easily be downloaded and installed. Before we jump into setting up and using these tools, let's get an understanding of team server and its purpose.

Team server allows us to manage our red-team activity in a single workspace. It acts as a server that connects and communicates with Metasploit and multiple Armitage clients can connect to it. This is handy when a team is doing a red-team activity, as all of the members can have the Armitage client running on their system and can connect to a single workspace in order to perform the activity...

Metasploit with slack

In this section, we will learn about a module called ShellHerder. This plugin is used to monitor all Metasploit/Meterpreter sessions. It was created with a basic idea in mind: to easily monitor new incoming sessions. In a red-team activity, this is useful as it can be used to monitor live phishing campaigns or a Rubber Ducky attack.

This plugin uses session subscriptions to monitor activity and send alerts to slack. Let's take a look at how to set it up.

We clone ShellHerder and copy it to our Metasploit plugins directory using the following commands. In our case, we saved the file as notify.rb in the destination folder:

 git clone https://github.com/chrismaddalena/ShellHerder.git
cp ShellHerder/ShellHerder.rb /opt/metasploit-framework/embedded/framework/plugins/notify.rb

We will then register an account on https://slack.com.

At this point, we choose...

Armitage and Cortana scripts

Cortana is a scripting language that is built into Armitage and Cobalt Strike. This is based on Sleep Scripting Language (http://sleep.dashnine.org/ ). We can find a lot of Cortana scripts built by different people on the internet. These scripts can be used to automate different tasks in Armitage. Running Cortana scripts is extremely easy. We will use the scripts hosted on GitHub by rsmudge, found here at https://github.com/rsmudge/cortana-scripts.

We then download the scripts on our computer and go to Armitage | Scripts... to run them:

In the window which opens, we choose Load and select the script we downloaded:

We will then try to run the icon script. This script identifies the services running and displays icons according to them:

Once the script is loaded, we then do the exploitation. When a new Meterpreter connection comes, this script will...

Summary

At the beginning of this chapter, we did a quick tour of the Metasploit framework, its features, and its usage. We then learned about team server and the Armitage client, including the setup and usage of Armitage. We also looked at integrating Metasploit/Armitage with slack so that it keeps us up to date about every new connection via slack notifications.

Finally, we covered the basics of Cortana scripting and its usage.

Questions

  1. What version of Metasploit is best to use?
  2. Is slack integration really necessary?
  3. Can we make our own Cortana scripts?
  4. Can we set up team server on Windows?
  5. Is Metasploit free?

Further reading

For more information on the topics discussed in this chapter, please visit the following links:

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On Red Team Tactics
Published in: Sep 2018Publisher: ISBN-13: 9781788995238
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Himanshu Sharma

Himanshu Sharma, 23, has already achieved fame for finding security loopholes and vulnerabilities in Apple, Google, Microsoft, Facebook, Adobe, Uber, AT&T, Avira, and many more with hall of fame listings as proofs. He has gained worldwide recognition through his hacking skills and contribution to the hacking community. He has helped celebrities such as Harbhajan Singh in recovering their hacked accounts, and also assisted an international singer in tracking down his hacked account and recovering it. He was a speaker at the international conference Botconf '13, held in Nantes, France. He also spoke at IEEE Conference in California and Malaysia as well as for TedX. Currently, he is the cofounder of BugsBounty, a crowd-sourced security platform for ethical hackers and companies interested in cyber services.
Read more about Himanshu Sharma

author image
Harpreet Singh

Harpreet is a professional with 8+ years of experience in the field of Ethical Hacking, Penetration Testing, Vulnerability Research & Red Teaming. He is the author of "Hands-On: Web Penetration Testing with Metasploit" and "Hands-On: Red Team Tactics" published by Packt Publishing. He's also an OSCP, OSWP, CRTP certified professional. Over the years of his experience, Harpreet has acquired the Offensive & Defensive skill set. He is a professional who specializes in Wireless & network exploitation including but not limited to Mobile exploitation, Web Application exploitation and he has also performed few Red Team Engagements in Banks & Financial Groups.
Read more about Harpreet Singh