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

Data Exfiltration

Data exfiltration (which can also be referred to as data extrusion or data theft) is an unauthorized data transfer from a computer. This can either be done by having physical access to the devices in the network or by remotely using automated scripts.

Advanced Persistent Threats (APTs) usually have data exfiltration as the main goal. The goal of an APT is to gain access to a network but remain undetected as it stealthily seeks out the most valuable data.

There may be cases in which the client wants to check both exploitation as well as data exfiltration. This makes the activity even more interesting as exfiltration of data without detection can sometimes be tricky.

In this chapter, we will cover the following topics:

  • Exfiltration basics
  • CloakifyFactory
  • Data exfiltration via DNS
  • Data exfiltration via Empire

Technical requirements

  • Metasploit Framework (MSF)
  • PGSQL (Postgres)
  • Oracle Java 1.7 or latest
  • Cobalt Strike
  • Empire
  • Armitage

Exfiltration basics

We have already covered some basic techniques in the reverse shell chapter. Let's do a quick revision of how these techniques can be used to transfer data from a victim machine to us.

Exfiltration via Netcat

As previously discussed, this is not the best way to transmit data as the data is transmitted in plaintext, which makes it easily detectable.

Exfiltration via OpenSSL

We also saw another way to transfer data via OpenSSL using commands, as shown by the following, to first generate the certificate and then use that certificate to transfer data...

CloakifyFactory

CloakifyFactory is developed by Joe Gervais (TryCatchHCF). This was presented at DEF CON24. This tool hides the data in plain sight—it bypassed data loss prevention (DLP), whitelisting controls, and antivirus (AV) detection. Blue team members already know what to look for when hunting for traces of attack in the memory or in the network traffic. Cloakify defeats them all by transforming any file type into simple strings using text-based steganography.

As mentioned by Souvik Roya and P.Venkateswaran in their white paper:

"Steganography is the art of hiding of a message within another so that the presence of a hidden message is indistinguishable. The key concept behind steganography is that a message to be transmitted is not detectable to the casual eye. This is also the advantage of steganography over cryptography. An unhidden encrypted message, no matter...

Data exfiltration via DNS

Data exfiltration can also be done over DNS to avoid detection. DNSteal is a great tool for this as it creates a fake DNS server, which listens for DNS requests while on the client; we can transfer the file data using simple for loops. This supports single as well as multiple file transfers.

The tool can be downloaded at the following link:

https://github.com/m57/dnsteal

Once downloaded, the tool can be run using the command shown as follows:

python dnsteal.py

This will start the server which will listen on port 53 for incoming connections.

The tool also gives us a command to be run on *nix-based systems. To exfiltrate data, we use that command and paste it in the client's shell as shown as follows:

This will send password.txt to our server and we will receive the file on our server as shown as follows.

Once the file transfer has completed, we...

Data exfiltration via Empire

We have already learned about getting reverse shells on Empire and using Empire to achieve persistence on the system. The next step is data exfiltration.

Empire has a built-in module which allows us to upload the data directly on to Dropbox. This is very useful in situations in which IP whitelisting is done, as Dropbox is one of the domains that generally allows employee access.

Let's take a look at an example of how this module is used. We interact with our agent and run the command as shown as follows:

usemodule exfiltration/exfil_dropbox

To view the details of the module, we type the info command:

This requires the path of the file we wish to transfer and the Dropbox API key, along with the target filename.

Once everything is set we execute the module as shown following, and the agent will then transfer the file to Dropbox using the...

Summary

In this chapter, we learned about data exfiltration and why it is needed. Then, we learned some basic ways of transferring data using simple tools like Netcat, OpenSSL, and PowerShell. Next, we jumped into transforming the data using text-based steganography to avoid detection, as well as looking at the usage of the CloakifyFactory tool. We also learned about extracting data via DNS from a victim machine to our server. Lastly, we explored how to exfiltrate data using Dropbox API to avoid detection, suspicion, and for bypassing firewalls.

Our journey with you ends here. We hope that you have enjoyed reading these chapters and that you have learned from them as well.

We would love to hear your feedback on this book. You can reach us on LinkedIn at the following links:

Questions

  1. Are there other ways to exfiltrate data? Are these techniques totally undetectable?
  2. What is a frequency analysis attack?
  3. What other tools can be used for Data exfiltration?
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