콘텐츠로 이동

nbtscan

Overview

nbtscan is a command-line utility that scans IP networks for NetBIOS name information. It queries the NetBIOS Name Service (port 137/UDP) to enumerate Windows hosts, retrieve computer names, workgroup/domain memberships, and identify logged-in users. Essential for network reconnaissance and Windows environment discovery.

Installation

Linux / Debian-based

# Debian/Ubuntu
sudo apt-get update
sudo apt-get install nbtscan

# Or from source
wget http://www.inetcat.net/software/nbtscan-1.5.1.tar.gz
tar xzf nbtscan-1.5.1.tar.gz
cd nbtscan-1.5.1
./configure && make && sudo make install

Kali Linux

# Pre-installed in Kali
which nbtscan

# Or update
sudo apt-get install nbtscan

macOS

brew install nbtscan

Windows

# Download from inetcat.net or use WSL
# Or use nmblookup (Samba suite) as alternative
nmblookup -A <IP>

Basic Syntax

CommandDescription
nbtscan <IP>Scan single IP address
nbtscan <CIDR>Scan CIDR range (e.g., 192.168.1.0/24)
nbtscan <start>-<end>Scan IP range (e.g., 192.168.1.1-192.168.1.255)
nbtscan -hDisplay help menu
nbtscan -VShow version information

Essential Options

OptionDescriptionExample
-rTargeting by hostname (resolve names)nbtscan -r hostname.txt
-AAdapter to use (specify interface)nbtscan -A eth0 192.168.1.0/24
-t <ms>Timeout in millisecondsnbtscan -t 1000 192.168.1.0/24
-vVerbose output (detailed info)nbtscan -v 192.168.1.0/24
-fFilename for output filenbtscan -f results.txt 192.168.1.0/24
-mShow MAC addressesnbtscan -m 192.168.1.0/24
-sSeparator character for outputnbtscan -s ':' 192.168.1.0/24

Output Formats

Human-Readable (Default)

nbtscan 192.168.1.0/24
# Output:
# IP ADDR         NETBIOS NAME     LOGGED IN USER      MAC ADDRESS
# -----------------------------------------------------------------------
# 192.168.1.10    WORKSTATION1     DOMAIN\admin        aa:bb:cc:dd:ee:01
# 192.168.1.11    SERVER1          <unknown>           aa:bb:cc:dd:ee:02

CSV Format

nbtscan -s ',' 192.168.1.0/24 > results.csv
# Output: IP,NETBIOS_NAME,USER,MAC_ADDRESS

Tab-Separated Values

nbtscan -s '\t' 192.168.1.0/24 > results.tsv
# Output with tab separators

Custom Delimiter

nbtscan -s '|' 192.168.1.0/24
# Output: 192.168.1.10|WORKSTATION1|DOMAIN\admin|aa:bb:cc:dd:ee:01

Verbose Mode

Detailed Output

nbtscan -v 192.168.1.10
# Shows:
# IP: 192.168.1.10
# Netbios Name:  WORKSTATION1         Workstation Service
# Netbios Name:  DOMAIN               Domain Name
# Netbios Name:  ADMIN                Messenger Service
# MAC Address:   aa:bb:cc:dd:ee:01

Verbose with File Output

nbtscan -v -f scan_results.txt 192.168.1.0/24
# Detailed results saved to file

Timeout Settings

Default Timeout (1000ms)

nbtscan 192.168.1.0/24
# Standard operation, waits 1 second per response

Quick Scan (Low Timeout)

nbtscan -t 500 192.168.1.0/24
# Timeout after 500ms (faster but may miss slow hosts)

Patient Scan (High Timeout)

nbtscan -t 3000 192.168.1.0/24
# Timeout after 3 seconds (catches slow/distant hosts)

Network Conditions

# LAN environment (fast network)
nbtscan -t 500 192.168.1.0/24

# WAN/slower networks
nbtscan -t 2000 10.0.0.0/16

# Through VPN/tunnels
nbtscan -t 5000 172.16.0.0/12

Common Usage Scenarios

Basic Network Enumeration

# Scan entire subnet
nbtscan 192.168.1.0/24

# Output shows all Windows hosts and logged-in users
# Useful for quick host discovery

Identify Active Users

# Find who is logged in across network
nbtscan -v 192.168.1.0/24 | grep -i "logged"

# Output displays DOMAIN\username for each host

MAC Address Collection

# Gather MAC addresses during reconnaissance
nbtscan -m 192.168.1.0/24

# Useful for tracking devices, bypass prevention

Large Network Scan

# Scan with extended timeout for reliability
nbtscan -t 2000 10.0.0.0/16 > network_hosts.txt

# Suitable for larger environments

Single Host Verification

# Check specific computer
nbtscan 192.168.1.100

# Verify hostname and logged-in user

Export and Analysis

Save to Text File

nbtscan 192.168.1.0/24 > hosts.txt
cat hosts.txt

Save to CSV for Spreadsheet

nbtscan -s ',' 192.168.1.0/24 > hosts.csv
# Import into Excel or Google Sheets

Save Verbose Output

nbtscan -v 192.168.1.0/24 > detailed_scan.txt
# Complete host information including services

Filter Results

# Show only specific domain
nbtscan 192.168.1.0/24 | grep "DOMAIN"

# Show only hosts with logged-in users
nbtscan -v 192.168.1.0/24 | grep -i "logged in user"

# Exclude specific hosts
nbtscan 192.168.1.0/24 | grep -v "192.168.1.254"

NetBIOS Codes and Services

CodeServiceDescription
<20>File ServerSMB/CIFS service running
<00>WorkstationComputer name (general service)
<03>MessengerMessenger/popup service
<1B>Domain MasterPrimary Domain Controller
<1C>Domain ControllersList of DCs in domain
<1D>Master BrowserNetwork browse master
<1E>Browser ElectionBrowser service
<1F>NetDDENetwork DDE service

Interpreting Results

# WORKSTATION1<20> = File Server (SMB enabled)
# WORKSTATION1<00> = Workstation service
# DOMAIN<1B> = Domain Master (Primary DC)
# DOMAIN<1C> = Domain Controllers

Integration with Other Tools

Combine with nmap

# Find open NetBIOS ports first
nmap -sU -p 137 192.168.1.0/24

# Then scan with nbtscan
nbtscan 192.168.1.0/24

Feed Results to Other Scanners

# Extract IPs from nbtscan
nbtscan 192.168.1.0/24 | awk '{print $1}' > ips.txt

# Use with nmap
nmap -iL ips.txt -sV

Samba Integration

# Use nmblookup for NetBIOS queries (Samba)
nmblookup -A 192.168.1.10

# Similar functionality to nbtscan

Wireshark Analysis

# Capture NetBIOS traffic
sudo tcpdump -i eth0 'port 137' -w netbios.pcap

# Analyze in Wireshark
wireshark netbios.pcap

Reconnaissance Workflow

Step 1: Discover Active Hosts

nbtscan 192.168.1.0/24 > active_hosts.txt

Step 2: Identify Domain Structure

nbtscan -v 192.168.1.0/24 | grep -i "domain"
# Identify domain name and controllers

Step 3: Find Logged-In Users

nbtscan 192.168.1.0/24 | grep -v "<unknown>" | awk '{print $3}'
# List active user accounts

Step 4: Enumerate Services

nbtscan -v 192.168.1.0/24 | grep -i "service"
# Find file servers, printers, etc.

Step 5: Follow-Up Enumeration

# For each discovered host, run deeper scans
nmap -sV -p 139,445 192.168.1.100
# Check SMB versions and services

Batch Operations

Scan Multiple Subnets

#!/bin/bash
for subnet in 192.168.{1..5}.0/24; do
  echo "Scanning $subnet..."
  nbtscan -t 1000 $subnet >> all_results.txt
done

Scan from List

# Create ranges.txt with IP ranges
192.168.1.0/24
192.168.2.0/24
10.0.0.0/25

# Scan all
for range in $(cat ranges.txt); do
  nbtscan $range >> output.txt
done

Continuous Monitoring

# Periodic scan for changes
while true; do
  nbtscan -s ',' 192.168.1.0/24 > "scan_$(date +%s).csv"
  sleep 3600  # Scan every hour
done

Performance Tuning

ScenarioCommandNotes
Fast LAN scannbtscan -t 500 192.168.1.0/24Low timeout, assumes fast network
Typical networknbtscan 192.168.1.0/24Default 1000ms timeout
Slow/WAN networknbtscan -t 2000 10.0.0.0/16Higher timeout for reliability
Large subnetsnbtscan -t 1500 10.0.0.0/8Balance speed and reliability
High packet lossnbtscan -t 5000 172.16.0.0/12Very patient for unreliable networks

Troubleshooting

IssueSolution
”No response”Verify network connectivity, check firewall
Timeout errorsIncrease timeout with -t option
Permission deniedRun with sudo for raw socket access
No results returnedTarget may not support NetBIOS, try nmap
MAC address unknownSome hosts don’t respond to NetBIOS queries
Slow scansReduce timeout (-t 500) or scan smaller ranges

Security Considerations

Information Disclosure

# nbtscan reveals sensitive information
# - Computer names
# - Domain names
# - Logged-in users
# - Service types

# Should be restricted network-side

Defense Against nbtscan

# Disable NetBIOS on systems not requiring it
# Restrict port 137/UDP at firewall
# Use NPS (Network Policy Server) for access control
# Disable unnecessary services

Privacy in Results

# Results may contain:
# - Employee usernames
# - System names
# - Admin account identifiers

# Handle results securely and confidentially

Alternative Tools

ToolUse CaseDifference
nmblookupSamba suite alternativeMore features, slower
nmapComprehensive scanningMore detailed, larger scans
getentActive Directory queriesRequires authentication
nbtstat (Windows)Windows-native NetBIOS toolPlatform-specific
masscanUltra-fast port scanningUses different protocol

Advanced Examples

Aggressive Enumeration

# Fast scan with verbose output and MAC addresses
nbtscan -v -m -t 800 192.168.1.0/24

Domain Discovery

# Find domain structure
nbtscan -v 192.168.0.0/16 | grep -E "Domain|1B|1C"

User Identification

# Extract unique users from scan
nbtscan 192.168.1.0/24 | awk '{print $3}' | sort | uniq -c

Service Mapping

# Identify services across network
nbtscan -v 192.168.1.0/24 | grep "Service"

Post-Scan Processing

# Save and analyze results
nbtscan -v 192.168.1.0/24 > raw_results.txt
grep "File Server" raw_results.txt | awk '{print $2}' > smb_hosts.txt
nmap -sV -p 445 -iL smb_hosts.txt