1

I am developing a simple port scanner using Python, Scapy, nmap module. I want to detect if the host which I apply the port scan is a router or not. How can I identify or guess if the host is a router?

  • nmap host fingerprinting might tell you what OS is running on the host. If it's Windows, chances you're dealing with a router are low. If it's Cisco IOS, you can be fairly sure it is some kind of router. – Pascal Nov 29 '16 at 13:43
  • nmap.org/book/vscan.html – Stone True Nov 29 '16 at 17:45
  • Routers don't necessarily have open ports. Port scanning may not help you here – ARau Nov 30 '16 at 16:42
1

You cannot detect a router using a port scan since not all routers expose ports. Routers are used for routing IP packets at Layer 3 of the OSI model and are used to bridge two different computer networks.

You can detect a router by doing what the traceroute command does.

Assuming you know what the IP address of the target router is then you would Send a ICMP Echo message with a TTL value of one to a destination IP that you suspect is on the other side of the network as the target router. If you get a ICMP Time Exceeded reply back from the IP of the target router, then you know it is a router. You might need to do this with some trial and error as you might not know the IP addresses on the other side of the router.

You can easily test this using the traceroute command against a target router then mimic the same behavior using the Scapy API to send ICMP Echo messages with TTL of one and test it out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.