Guides · 4 of 8
Find what a server runs and exposes
What listens on the network is what an attacker can reach, so those are the services to have in Dawnsentry first. These commands list them on a server, with the program, the package it came from and its version. They only read; they change nothing. Run them as root or administrator, or you won't see other users' processes.
Linux: Ubuntu, Debian, Red Hat, Rocky, Alma, SUSE
All listening TCP and UDP ports, with the program behind each:
sudo ss -tulpn
The same, with each program's package and version (Debian and Ubuntu use dpkg; Red Hat, Rocky, Alma and SUSE use rpm):
sudo bash -c '
ss -Htlnup | while read -r proto state recvq sendq local peer proc; do
pid=$(grep -oP "pid=\K[0-9]+" <<<"$proc" | head -1)
[ -n "$pid" ] || continue
exe=$(readlink -f "/proc/$pid/exe")
if command -v dpkg-query >/dev/null; then
pkg=$(dpkg -S "$exe" 2>/dev/null || dpkg -S "${exe#/usr}" 2>/dev/null); pkg=${pkg%%:*}
ver=$(dpkg-query -W -f="\${Version}" "$pkg" 2>/dev/null)
else
pkg=$(rpm -qf --qf "%{NAME}" "$exe" 2>/dev/null)
ver=$(rpm -qf --qf "%{VERSION}-%{RELEASE}" "$exe" 2>/dev/null)
fi
printf "%-4s %-24s %-30s %-20s %s\n" "$proto" "$local" "$exe" "${pkg:-?}" "${ver:-?}"
done | sort -u'A line for each listening port, for example:
tcp 0.0.0.0:443 /usr/sbin/nginx nginx-core 1.24.0-2ubuntu7.1 tcp 0.0.0.0:22 /usr/sbin/sshd openssh-server 1:9.6p1-3ubuntu13.5 tcp 127.0.0.1:5432 /usr/lib/postgresql/16/bin/... postgresql-16 16.4-0ubuntu0.24.04.2
- Which address it listens on tells you who can reach it:
0.0.0.0or[::]is every network the server is on,127.0.0.1is the server itself only. - The version to enter in Dawnsentry is the upstream part:
1.24.0for nginx above,9.6p1for OpenSSH. The rest is the distribution's own patch number. Distributions backport fixes into old versions, which is why Dawnsentry asks for the operating system and kernel as items too. - On Red Hat Enterprise Linux, Rocky Linux and AlmaLinux, enter the whole version and release instead, as rpm prints it:
9.16.23-24.el9_5.3for BIND, and put the item on the RHEL, Rocky or Alma item with Runs on. Dawnsentry then compares it with the build Red Hat names as the fix for each CVE, so the fixes Red Hat backported count. - A "?" in the package column means the program wasn't installed from a package: a download in
/opt, a container, a Java app. Ask the program itself, as below.
The operating system, kernel and hardware:
cat /etc/os-release # distribution and release uname -r # kernel, exactly as Dawnsentry wants it sudo dmidecode -s system-product-name; sudo dmidecode -s bios-version sudo ipmitool mc info | grep -i firmware # iDRAC, iLO or other BMC firmware, if ipmitool is installed pveversion # Proxmox VE
Asking a program its version
nginx -v apache2 -v httpd -v ssh -V psql --version mysqld --version redis-server --version php -v java -version node -v python3 -V docker version zabbix_agent2 -V openssl version
Containers listen through Docker, so the port shows docker-proxy. List what runs and which image version:
docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Ports}}"Windows Server and Windows (PowerShell, as administrator)
Every listening TCP port with its program, the services inside it, and the program's product name and version:
Get-NetTCPConnection -State Listen |
Where-Object { $_.LocalAddress -notin '127.0.0.1', '::1' } |
Sort-Object LocalPort -Unique |
ForEach-Object {
$p = Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue
$v = if ($p.Path) { (Get-Item $p.Path).VersionInfo }
[pscustomobject]@{
Port = $_.LocalPort
Address = $_.LocalAddress
Program = $p.ProcessName
Services = (Get-CimInstance Win32_Service -Filter "ProcessId=$($_.OwningProcess)").Name -join ', '
Product = $v.ProductName
Version = $v.ProductVersion
}
} | Format-Table -AutoSizeUDP ports: replace the first line with Get-NetUDPEndpoint | and leave out the sort. Ports owned by System (process 4) are Windows itself: SMB on 445, HTTP.sys on 80 and 443 for IIS and others.
The Windows build, in the form Dawnsentry uses:
$v = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' "$($v.ProductName) $($v.DisplayVersion) 10.0.$($v.CurrentBuild).$($v.UBR)"
Installed programs and their versions:
Get-ItemProperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' |
Where-Object DisplayName | Sort-Object DisplayName |
Select-Object DisplayName, DisplayVersion, Publisher | Format-Table -AutoSizeFrom the outside: what the network sees
The commands above show what a server listens on; a firewall in between decides what's actually reachable. A scan from another machine shows that, with the version each service announces. Scan only networks you're responsible for.
nmap -sV --top-ports 1000 192.0.2.10 # one server nmap -sV -p- 192.0.2.10 # every port (slower) nmap -sV --open 192.0.2.0/24 # a subnet, open ports only
A service that answers from outside should be in Dawnsentry as internet-facing if the scan came from the internet. And a port you didn't expect is worth a look before it's worth an item.
Network equipment
Firewalls, switches and access points tell their version on their dashboard and on the command line: show version on Cisco, Arista and Juniper, FortiGate get system status, Palo Alto show system info, MikroTik/system resource print). With many devices, an import from Zabbix or PRTG does the reading for you.
Next: Import from Zabbix, PRTG, NetBox or a spreadsheet · Questions? info@dawnsentry.com