Port scanning

Nmap is a network port scanner, it's my favorite tools when it comes to port scanning.

Nmap can also be used to detect and exploit vulnerabilities thanks to the huge number of build-in scripts. In this section we will focus on the post popular switches for port scanning.

  • Scan all TCP ports of specific host with the nmap default scripts. the -p- lets you scan All 65,535 TCP ports while -p scans lets you scan a specific port. If you don't specify -p-, nmap will only scan the most common ports but will not scan all TPC ports. The -d switch shows the debug information's.

nmap –sC 192.168.1.120 -d -p-
  • Scan a specific UDP port.

nmap -p U:53 192.168.1.120
  • Scan all TCP and UDP ports.

nmap -p- -sA -sU -sV 192.168.1.120
  • Perform an Agressive scan on all ports, this options makes a lot of noises on the network and is not my favorite one. The -A switch enables additional advanced and aggressive options. Presently this enables OS detection (-O), version scanning (-sV), script scanning (-sC) and traceroute (--traceroute). The -oA scan --webxml allows you to export the scan results to all formats including the webxml.

nmap -p- -A 192.168.1.120 -oA <outputFileName> --webxml
  • Nmap does not offer the possibility to output the results directly to an HTML page, but it's possible to use XSLT to convert an Nmap XML file to an HTML file.

xsltproc -o <OutputFileName.html> /usr/share/nmap/nmap.xsl <nmapScan.xml>

Scan ports locally using Living Of The lands tools (Powershell) in Windows

# Check if TCP ports 1 to 1024 are open on srvfs01
foreach ($port in 1..1024) {
    If (($a=Test-NetConnection srvfs01 -Port $port -WarningAction SilentlyContinue).tcpTestSucceeded -eq $true) {
        "TCP port $port is open!"
    }
}

# Get local TCP connections on port 5000 along with the process name
Get-NetTCPConnection | where Localport -eq 5000 | Select-Object Localport,@{'Name' = 'ProcessName';'Expression'={(Get-Process -Id $_.OwningProcess).Name}}

ICMP and Network Scanning

ICMP File Transfer

OS/Banner Version Fingerprinting

Python Script for Banner Grabbing

Last updated