JustinTimperio / gomap

A fully self-contained Nmap like parallel port scanning module in pure Golang that supports SYN-ACK (Silent Scans)
MIT License
86 stars 19 forks source link

Unlikely to Support UDP Port Scan #14

Open cogitoergosumsw opened 2 years ago

cogitoergosumsw commented 2 years ago

Just a cursory look at the implementation of the code, I reckon the UDP port scan would not work just because of how UDP protocol works. If the the code dials the target with UDP protocol e.g. conn, err = net.Dial("udp", raddr), there will not be any error message from the target server just because UDP is connectionless. A server will only reply when a "meaningful" packet is sent to the UDP port on the target. For more info - https://serverfault.com/a/416269

By the current way of checking for open/close UDP port i.e. presence of error dialing the target, all UDP ports would be open. Which defeats the purpose of a port scan.

Alternatively, can refer to how nmap implements its UDP probe - https://nmap.org/book/scan-methods-udp-scan.html

cogitoergosumsw commented 2 years ago

I think to successfully do a UDP port scan, you may need a list of pre-determined list of services to probe for responses. First construct a UDP packet request with a byte array that is expected from the service running on the UDP port. Then listen for the corresponding response byte array to check if the port is open. Something like this - https://github.com/antelman107/net-wait-go#udp-library-usage-example

I understand this is a lot of work so I'm just putting this out there for reference. I don't think I can do this on my own :D

JustinTimperio commented 2 years ago

You are probably right with the UDP support. I honestly added it as a throwaway feature since:

  1. TCP scanning was the real priority when I wrote this
  2. The dial conn, err = net.Dial("udp", raddr) allows for calls other than TCP so I figured I would just expose it to the user to decide.