Sniffing out a Foothold
LLMNR/NBT-NS Poisoning - from Linux
This section and the next will cover a common way to gather credentials and gain an initial foothold during an assessment: a Man-in-the-Middle attack on Link-Local Multicast Name Resolution (LLMNR) and NetBIOS Name Service (NBT-NS) broadcasts.
Depending on the network, this attack may provide low-privileged or administrative level password hashes that can be cracked offline or even cleartext credentials.
LLMNR & NBT-NS Primer
Link-Local Multicast Name Resolution (LLMNR) and NetBIOS Name Service (NBT-NS) are Microsoft Windows components that serve as alternate methods of host identification that can be used when DNS fails.
If a machine attempts to resolve a host but DNS resolution fails, typically, the machine will try to ask all other machines on the local network for the correct host address via LLMNR. LLMNR is based upon the Domain Name System (DNS) format and allows hosts on the same local link to perform name resolution for other hosts. It uses port 5355
over UDP natively. If LLMNR fails, the NBT-NS will be used. NBT-NS identifies systems on a local network by their NetBIOS name. NBT-NS utilizes port 137
over UDP.
The kicker here is that when LLMNR/NBT-NS are used for name resolution, ANY host on the network can reply. This is where we come in with Responder
to poison these requests.
If the requested host requires name resolution or authentication actions, we can capture the NetNTLM hash and subject it to an offline brute force attack in an attempt to retrieve the cleartext password.
The captured authentication request can also be relayed to access another host or used against a different protocol (such as LDAP) on the same host. LLMNR/NBNS spoofing combined with a lack of SMB signing can often lead to administrative access on hosts within a domain.
TTPs (tactics, techniques and procedures)
Several tools can be used to attempt LLMNR & NBT-NS poisoning:
Tool
Description
Responder is a purpose-built tool to poison LLMNR, NBT-NS, and MDNS, with many different functions.
Inveigh is a cross-platform MITM platform that can be used for spoofing and poisoning attacks.
Metasploit has several built-in scanners and spoofing modules made to deal with poisoning attacks.
Responder In Action
Some common options we'll typically want to use are -wf
; this will start the WPAD rogue proxy server, while -f
will attempt to fingerprint the remote host operating system and version. We can use the -v
flag for increased verbosity if we are running into issues, but this will lead to a lot of additional data printed to the console. Other options such as -F
and -P
can be used to force NTLM or Basic authentication and force proxy authentication, but may cause a login prompt, so they should be used sparingly.
The use of the -w
flag utilizes the built-in WPAD proxy server. This can be highly effective, especially in large organizations, because it will capture all HTTP requests by any users that launch Internet Explorer if the browser has Auto-detect settings enabled.
With this configuration shown above, Responder will listen and answer any requests it sees on the wire. If you are successful and manage to capture a hash, Responder will print it out on screen and write it to a log file per host located in the /usr/share/responder/logs
directory.
Hashes are saved in the format (MODULE_NAME)-(HASH_TYPE)-(CLIENT_IP).txt
ashes are also stored in a SQLite database that can be configured in the Responder.conf
config file, typically located in /usr/share/responder
unless we clone the Responder repo directly from GitHub.
We must run the tool with sudo privileges or as root and make sure the following ports are available on our attack host for it to function best:
Any of the rogue servers (i.e., SMB) can be disabled in the Responder.conf
file.
If Responder successfully captured hashes, as seen above, we can find the hashes associated with each host/protocol in their own text file
We can kick off a Responder session rather quickly:
Typically we should start Responder and let it run for a while in a tmux window while we perform other enumeration tasks to maximize the number of hashes that we can obtain.
Once we are ready, we can pass these hashes to Hashcat using hash mode 5600
for NTLMv2 hashes that we typically obtain with Responder.
We may at times obtain NTLMv1 hashes and other types of hashes and can consult the Hashcat example hashes page to identify them and find the proper hash mode.
If we ever obtain a strange or unknown hash, this site is a great reference to help identify it.
Once we have enough, we need to get these hashes into a usable format for us right now. NetNTLMv2 hashes are very useful once cracked, but cannot be used for techniques such as pass-the-hash, meaning we have to attempt to crack them offline. We can do this with tools such as Hashcat and John.
LLMNR/NBT-NS Poisoning - from Windows
This section will explore the tool Inveigh and attempt to capture another set of credentials.
Inveigh can listen to IPv4 and IPv6 and several other protocols, including LLMNR
, DNS, mDNS
, NBNS, DHCPv6
, ICMPv6, HTTP
, HTTPS, SMB
, LDAP, WebDAV
, and Proxy Auth.
We can get started with the PowerShell version as follows and then list all possible parameters. There is a wiki that lists all parameters and usage instructions.
Let's start Inveigh with LLMNR and NBNS spoofing, and output to the console and write to a file. We will leave the rest of the defaults, which can be seen here.
C# Inveigh (InveighZero)
The PowerShell version of Inveigh is the original version and is no longer updated. The tool author maintains the C# version, which combines the original PoC C# code and a C# port of most of the code from the PowerShell version.
Let's go ahead and run the C# version with the defaults and start capturing hashes.
We can also see the message Press ESC to enter/exit interactive console
, which is very useful while running the tool.
The console gives us access to captured credentials/hashes, allows us to stop Inveigh, and more.
We can quickly view unique captured hashes by typing GET NTLMV2UNIQUE
.
We can type in GET NTLMV2USERNAMES
and see which usernames we have collected.
Remediation
Mitre ATT&CK lists this technique as ID: T1557.001, Adversary-in-the-Middle: LLMNR/NBT-NS Poisoning and SMB Relay
.
There are a few ways to mitigate this attack. To ensure that these spoofing attacks are not possible, we can disable LLMNR and NBT-NS. As a word of caution, it is always worth slowly testing out a significant change like this to your environment carefully before rolling it out fully.
As penetration testers, we can recommend these remediation steps, but should clearly communicate to our clients that they should test these changes heavily to ensure that disabling both protocols does not break anything in the network.
We can disable LLMNR in Group Policy by going to Computer Configuration --> Administrative Templates --> Network --> DNS Client and enabling "Turn OFF Multicast Name Resolution."
NBT-NS cannot be disabled via Group Policy but must be disabled locally on each host. We can do this by opening Network and Sharing Center
under Control Panel
, clicking on Change adapter settings
, right-clicking on the adapter to view its properties, selecting Internet Protocol Version 4 (TCP/IPv4)
, and clicking the Properties
button, then clicking on Advanced
and selecting the WINS
tab and finally selecting Disable NetBIOS over TCP/IP
.
While it is not possible to disable NBT-NS directly via GPO, we can create a PowerShell script under Computer Configuration --> Windows Settings --> Script (Startup/Shutdown) --> Startup with something like the following:
In the Local Group Policy Editor, we will need to double click on Startup
, choose the PowerShell Scripts
tab, and select "For this GPO, run scripts in the following order" to Run Windows PowerShell scripts first
, and then click on Add
and choose the script. For these changes to occur, we would have to either reboot the target system or restart the network adapter.
To push this out to all hosts in a domain, we could create a GPO using Group Policy Management
on the Domain Controller and host the script on the SYSVOL share in the scripts folder and then call it via its UNC path such as:
\\inlanefreight.local\SYSVOL\INLANEFREIGHT.LOCAL\scripts
Other mitigations include filtering network traffic to block LLMNR/NetBIOS traffic and enabling SMB Signing to prevent NTLM relay attacks.
Network intrusion detection and prevention systems can also be used to mitigate this activity, while network segmentation can be used to isolate hosts that require LLMNR or NetBIOS enabled to operate correctly.
Detection
It is not always possible to disable LLMNR and NetBIOS, and therefore we need ways to detect this type of attack behavior. One way is to use the attack against the attackers by injecting LLMNR and NBT-NS requests for non-existent hosts across different subnets and alerting if any of the responses receive answers which would be indicative of an attacker spoofing name resolution responses. This blog post explains this method more in-depth.
Furthermore, hosts can be monitored for traffic on ports UDP 5355 and 137, and event IDs 4697 and 7045 can be monitored for. Finally, we can monitor the registry key HKLM\Software\Policies\Microsoft\Windows NT\DNSClient
for changes to the EnableMulticast
DWORD value. A value of 0
would mean that LLMNR is disabled.
Last updated