{
	"id": "e999ae1b-29cd-42f3-bf5f-a547b39a57b9",
	"created_at": "2023-01-12T14:58:57.783338Z",
	"updated_at": "2026-11-18T02:07:52.094105Z",
	"deleted_at": null,
	"sha1_hash": "0aa59e3404b4fb91065a87f1049eb9f0fb5ab6d3",
	"title": "2021-02-01 - Relay Attacks via Cobalt Strike Beacons",
	"llm_title": "2021-02-01 - Relay Attacks via Cobalt Strike Beacons",
	"authors": "",
	"file_creation_date": "2022-05-28T04:05:18Z",
	"file_modification_date": "2022-05-28T04:05:18Z",
	"file_size": 149664,
	"plain_text": "1/5\r\nFebruary 1, 2020\r\nRelay Attacks via Cobalt Strike Beacons\r\npkb1s.github.io/Relay-attacks-via-Cobalt-Strike-beacons/\r\n6 minute read\r\nIntroduction\r\nBack in 2018, Will Shroeder, Lee Christensen and Matt Nelson shared their awesome\r\nresearch around Active Directory trusts at DerbyCon. During the last part of their\r\npresentation they showed how we can abuse the Print Spooler service in order to force a\r\ncomputer to authenticate against another computer. Lee also released a tool that allows us\r\nto do this easily called SpoolSample. If you are not familiar with this attack I highly\r\nrecommend reading the following blog posts:\r\nMost of the abuses I have seen so far are using the SpoolSample tool along with\r\ncompromising a server with Unconstrained Delegation enabled. This allows the attacker to\r\nforce a computer authenticate back to the attacker using Kerberos and since Unconstrained\r\nDelegetation is enabled on the compromised server, the victim also sends their TGT within\r\nthe TGS. However, there is another way to compromise computers.\r\nIf we run the SpoolSample tool with IP addresses as arguments instead of domain names,\r\nthe target computer will initiate an authentication attempt using Net-NTLM and it is known for\r\nmany years that Net-NTLM authentication is vulnerable to relay attacks. This means that we\r\ncan use SpoolSample to make a computer object authenticate back to a computer we control\r\nand relay this authentication to another host.\r\nThe scenario where this is useful is the following:\r\nOK, lets put this attack aside for now and we will come back to it later.\r\nAnother scenario that we find very often when reviewing AD environments is when a user\r\nobject has rights such as GenericAll or GenericWrite on another user object similar to\r\nthe following:\n\n2/5\r\nIf we have compromised Alice then we can do the following:\r\nUse a targeted Kerberoasting attack against Bob by setting an SPN and requesting a\r\nTGS\r\nForce a password change for Bob\r\nHowever, both of these attacks have limitations. For targeted kerberoasting the user must be\r\nconfigured with a weak password in order to crack it. As for changing Bob’s password it\r\nmight be something that you don’t want to do during a red team operation to avoid disruption\r\nor raising suspicion.\r\nSo I started looking at the different attributes a user has and another option is to modify one\r\nof the following use attributes:\r\nhomeDirectory - Specifies the home directory of the account and it can be a UNC path.\r\nprofilePath - Specifies a path to the user’s profile and it can also be a UNC path.\r\nBy modifying any of these attributes, we can point them to a UNC path of a computer under\r\nyour control and perform an SMB relay attack.\r\nSomething you might be wondering so far is this - You have been telling me these ways of\r\nexploiting AD objects based on ACL misconfigurations and SMB relay attacks but you\r\nhaven’t told me how to perform a relay attack if all I have is a Cobalt Strike beacon.\r\nKeep reading and your question will be answered ;)\r\nRelay Attacks\r\nSo far I have mentioned relay attacks, and specifically SMB relays. This kind of attack has\r\nbeen known for many years. If you want to learn more about SMB relay you can read the\r\nfollowing posts:\r\nhttps://byt3bl33d3r.github.io/practical-guide-to-ntlm-relaying-in-2017-aka-getting-a-foothold-in-under-5-minutes.html\r\nhttps://www.sans.org/blog/smb-relay-demystified-and-ntlmv2-pwnage-with-python/\n\n3/5\r\nThe rest of this post is based on the reader’s basic understanding of relay attacks so make\r\nsure you have read the above posts.\r\nOK, I understand how SMB relay attacks work. Now what?\r\nWhen I performed relay attacks in the past I was always doing an internal pentest and I had\r\nphysical access to the target network. But, why not use these powerful attacks while on a red\r\nteam operation and you have to do everything through a Cobalt Strike beacon?\r\nIt looks like there is a way to do this! Actually this is possible for a few years now thanks to\r\nthe very cool divertTCPconn and hwfwbypass projects.\r\nDivertTCPconn is based on hwfwbypass and both are written in C++. It is using the\r\namazingly complicated WinDivert project written by Basil:\r\nhttps://github.com/basil00/Divert\r\nHow does it work?\r\nAccording to it’s description, WinDivert is a kernel driver that allows for user-mode packet\r\ninterception and modification. The user needs to specify a filter and any packets that match\r\nthis filter will be intercepted and can be modified.\r\nThe WinDivert.sys driver is installed below the Windows network stack. The\r\nfollowing actions occur:\r\n(1) A new packet enters the network stack and is intercepted by WinDivert.sys\r\n(2a) If the packet matches the PROGRAM-defined filter, it is diverted. The\r\n PROGRAM can then read the packet using a call to WinDivertRecv().\r\n(2b) If the packet does not match the filter, the packet continues as normal.\r\n(3) PROGRAM either drops, modifies, or re-injects the packet. PROGRAM can\r\n re-inject the (modified) using a call to WinDivertSend().\r\nThe most important thing that WinDivert allows us to do is to intercept traffic going to an open\r\nWindows port and redirect it to another port by modifying the TCP source and destination\r\nports of each packet, recalculating the TCP checksums and reinjecting the packets into the\r\nnetwork stack.\r\nHow does this help us?\r\nOn Windows, port 445 is always running by default. I won’t go into detail about the process\r\nusing port 445 because this is already analysed in the following post, so please go ahead\r\nand read it:\r\nhttps://diablohorn.com/2018/08/25/remote-ntlm-relaying-through-meterpreter-on-windows-port-445/\n\n4/5\r\nAs mentioned in the above post, it also contains another interesting idea. Using WinDivert to\r\nperform an SMB relay attack via Metasploit. You can upload a few DLLs and a driver file to\r\nthe target host along with the divertTCPconn.exe and execute them. I found this attack to be\r\nawesome, but what I didn’t like was that you had to upload multiple DLLs on the target host.\r\nSo my goal was to do the same attack by dropping the minimum amount of files on disk and\r\nalso executing the attack through Cobalt Strike.\r\nSMB Relay through Cobalt Strike\r\nFirst of all, I wanted to make use of Cobalt Strike’s execute-assembly function so I\r\ndecided to write my code using the .NET framework. My initial thought would be to re-write\r\ndivertTCPconn in C# and then everything would work. It turns out that this was very\r\ncomplicated. Fortunately, I found the following NuGet package by TechnikEmpire:\r\nhttps://github.com/TechnikEmpire/WinDivertSharp\r\nUsing WinDivertSharp, I was able to write a tool called SharpRelay to communicate with the\r\nWinDivert driver and perform any packet modification I wanted. The only requirement for this\r\nattack to work is to have a beacon with local administrator privileges or with the ability to load\r\ndrivers. The attack using SharpRelay works as follows:\r\nUpload the signed WinDivert driver into any folder on the compromised host\r\nRun SharpRelay to modify the destination port of the incoming packets on port 445 and\r\nredirect them to another port (e.g. 8445)\r\nFrom our beacon run the Cobalt Strike’s rportfwd command to forward port 8445 of\r\nthe compromised host to our teamserver’s port 445.\r\nStart a socks server to forward the relayed traffic back to the victim network\r\nRun Impacket’s ntlmrelayx with proxychains to do the SMB relay\r\nWhen a victim tries to access port 445 of the compromised host the NTLM\r\nauthentication will be forwarded to our teamserver and relayed to another machine\r\nThe code of SharpRelay can be found here:\r\nhttps://github.com/pkb1s/SharpRelay\r\nAlso, a big part of the code I used for the packet interception was taken from this project by\r\nTechnikEmpire:\r\nhttps://github.com/TechnikEmpire/CitadelCore\r\nShow me a video or it didn’t happen\r\nTo demonstrate the attacks I described in the beginning of the post, I made the following\r\nvideos.\n\n5/5\r\nSpoolSample to SMB Relay\r\nAs mentioned earlier we have the following scenario:\r\nThe following video demonstrates how we can use the SpoolSample tool to compromise a\r\ncomputer object via an SMB relay attack:\r\nAbusing weak ACLs on a User Object\r\nAs shown earlier, the scenario we are going to abuse it the following:\r\nHaving a local administrator beacon running as Alice, we will modify Bob’s homeDirectory\r\nattribute and point it to the workstation where we have our beacon running (10.1.1.20). Next\r\ntime Bob logs in to his workstation he will try to authenticate against the compromised host\r\nand we will perform our SMB relay attack:",
	"extraction_quality": 1,
	"language": "EN",
	"sources": [
		"VXUG"
	],
	"origins": [
		"pdf"
	],
	"references": [
		"https://papers.vx-underground.org/papers/Malware Defense/Malware Analysis 2021/2021-02-01 - Relay Attacks via Cobalt Strike Beacons.pdf"
	],
	"report_names": [
		"2021-02-01 - Relay Attacks via Cobalt Strike Beacons.pdf"
	],
	"threat_actors": [],
	"ts_created_at": 1673535537,
	"ts_updated_at": 1794967672,
	"ts_creation_date": 1653710718,
	"ts_modification_date": 1653710718,
	"files": {
		"pdf": "https://archive.orkl.eu/0aa59e3404b4fb91065a87f1049eb9f0fb5ab6d3.pdf",
		"text": "https://archive.orkl.eu/0aa59e3404b4fb91065a87f1049eb9f0fb5ab6d3.txt",
		"img": "https://archive.orkl.eu/0aa59e3404b4fb91065a87f1049eb9f0fb5ab6d3.jpg"
	}
}