While executing the following command from my Mac OSX:
nmap -PN server.com
It reports the following:
Starting Nmap 7.70 ( https://nmap.org ) at 2019-04-18 16:14 EDT
Nmap scan report for server.com (9.9.9.9)
Host is up (0.020s latency).
Not shown: 997 filtered ports
PORT STATE SERVICE
80/tcp open http
443/tcp open https
8080/tcp open http-proxy
The http and https are fine, but I'm befuddled by the http-proxy
. We have nothing running on port 8080 on this server:
# sudo ss -lnp | grep :8080
#
And netstat output:
# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 12378/mysqld
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2441/nginx: master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 2441/nginx: master
tcp6 0 0 :::80 :::* LISTEN 2441/nginx: master
tcp6 0 0 :::443 :::* LISTEN 2441/nginx: master
This is an Nginx server with no proxying back to anything else, it's just Nginx. What can we do to "close" this non-open port. Is this a bug with Nmap or am I misunderstanding something?
Nmap reports an open TCP port when it receives a SYN/ACK response to a SYN probe on that port, or (in TCP Connect mode,
-sT
) when a TCP connection to the port is successful. There are several cases where the output of netstat/ss and Nmap may differ:--reason
option and looking for differences in the TTL of response packets from known-good ports versus the questionable ones. You could also compare the responses in a packet capture, since other parts of the reply could be different (TCP options, primarily).--reason
option and other comparisons suggested above will work to detect this. Another approach is to use theqscan
NSE script to compare timing of replies to determine if some ports experience a delay due to the additional routing. This can also detect interference like in number 1.masscan
uses, which uses packet capture to inspect inbound traffic and raw sockets to generate replies.netstat
andss
binaries may have been overwritten, or a kernel module may be intercepting the system calls and filtering the return values to hide the port. It would be very unusual to find this on a common port like 8080. Nmap is often used to detect this kind of interference since it reports the actual behavior of the target instead of the internal accounting that the rootkit is falsifying. You have to make sure nothing else is interfering with the scan, though.