Ir al contenido

Nbtscan

Nbtscan queries NetBIOS names and resolves hostnames from IP addresses on Windows networks. Used for host discovery and OS fingerprinting.

Installation

# Debian/Ubuntu
sudo apt install nbtscan

# Kali Linux (pre-installed)
which nbtscan

# macOS
brew install nbtscan

# Build from source
git clone https://github.com/Konrad2221/nbtscan
cd nbtscan && make && sudo make install

Basic Scanning

CommandDescription
nbtscan targetScan single IP
nbtscan 192.168.1.0/24Scan subnet
nbtscan -r 192.168.1.1 192.168.1.254Scan range
nbtscan -f hostfile.txtScan from file
nbtscan -hShow help

Single Host Queries

# Query single IP
nbtscan 192.168.1.100

# Verbose output
nbtscan -v 192.168.1.100

# Show all names
nbtscan -a 192.168.1.100

# Show IP and hostname
nbtscan 192.168.1.100

Network Scanning

# Scan entire subnet
nbtscan 192.168.1.0/24

# Scan range of IPs
nbtscan -r 192.168.1.1 192.168.1.254

# Scan with specific range
nbtscan 192.168.1.10-20

# Custom timeout (ms)
nbtscan -t 100 192.168.1.0/24

# Increased timeout for slow networks
nbtscan -t 1000 192.168.1.0/24

Output Filtering

# Save results to file
nbtscan 192.168.1.0/24 > nbtscan_results.txt

# Only show hostnames
nbtscan 192.168.1.0/24 | grep -v '<00>' | sort -u

# Extract machine names
nbtscan 192.168.1.0/24 | awk '{print $1, $2}' | sort -u

# Find workstations
nbtscan 192.168.1.0/24 | grep '<00>'

# Find domain controllers
nbtscan 192.168.1.0/24 | grep '<1c>'

# Find file servers
nbtscan 192.168.1.0/24 | grep '<20>'

NetBIOS Name Service Codes

CodeTypeDescription
<00>WORKSTATIONWorkstation or server name
<01>MESSENGERBrowser election service
<03>MESSENGERMessenger service
<06>RASRAS server
<1B>NETDDEDomain master browser
<1C>INTERNETGROUPDomain controller group
<1D>MASTERMaster browser
<1E>BROWSERBrowser service elections
<20>SERVERFile server service
<21>RASRAS client service
<22>EXCHANGEExchange message handling system
<23>EXCHANGEExchange store
<24>EXCHANGEExchange directory services
<30>MODEMModem sharing server
<31>MODEMModem sharing client
<43>SNASNA gateway
<44>SNASNA server
<45>TCPIPTCP/IP NetBIOS gateway
<46>TCPIPTCP/IP NetBIOS name server
<4B>NETDDEDistributed file system
<87>PROXYProxy server
<BE>NETLOGONNetwork logon service
<BF>NETLOGONLogon server cluster
<C0>SRVLOCServer location service
<FB>FILESERVERFile server service cluster
<FF>DOMAINDomain name (master browsers)

Advanced Scanning

# Very verbose output
nbtscan -v -v 192.168.1.0/24

# Suppress errors
nbtscan -s 192.168.1.0/24

# Original output format
nbtscan -r 192.168.1.0/24

# Show only active systems
nbtscan 192.168.1.0/24 | grep -v 'Timed out'

Host Discovery Workflow

# Step 1: Scan subnet for active hosts
nbtscan 192.168.1.0/24 > hosts.txt

# Step 2: Extract unique hostnames
cat hosts.txt | awk '{print $2}' | sort -u > hostnames.txt

# Step 3: Identify domain controllers
grep '<1c>' hosts.txt

# Step 4: Identify domain names
grep '<1d>' hosts.txt

# Step 5: Identify master browser
grep '<1e>' hosts.txt

Domain Enumeration

# Find all domain names
nbtscan 192.168.1.0/24 | grep '<00>' | awk '{print $2}' | sort -u

# Find domain controllers
nbtscan 192.168.1.0/24 | grep '<1c>'

# Find master browser
nbtscan 192.168.1.0/24 | grep '<1b>'

# Extract domain name (last field when <1c> present)
nbtscan 192.168.1.0/24 | grep '<1c>' | awk '{print $3}'

Bulk Scanning

# Scan from file list
nbtscan -f /path/to/ips.txt

# Create IP list for scanning
nmap -sL 192.168.1.0/24 | grep 'Nmap scan' | awk '{print $5}' > ips.txt
nbtscan -f ips.txt

# Parallel scanning with xargs
cat ips.txt | xargs -P 4 -I {} nbtscan {}

Integration with Other Tools

# Combine with nmap
nmap -p 139 192.168.1.0/24 -oG - | awk '{print $2}' | xargs nbtscan

# Combine with masscan
masscan 192.168.1.0/24 -p 139 | awk '{print $4}' | sort -u | xargs nbtscan

# Parse nbtscan output for further enumeration
nbtscan 192.168.1.0/24 | grep '<00>' | awk '{print $1}' | xargs -I {} smbclient -L \\\\{} -N

Troubleshooting

# Increase timeout for unresponsive systems
nbtscan -t 500 192.168.1.100

# Check if port 139 is open
nmap -p 139 192.168.1.100

# Send broadcast query
nbtscan -b 255.255.255.255

Last updated: March 2026