I'm working on a port scanner that uses Linux connect
system call and when I'm scanning localhost, sometimes I get false positives due to kernel allocating me the source port for the connection that is equal to the destination port. Is there a way to tell if the connection I established was made to an ephemeral port?
You can use getsockname
to find out the local port the kernel assigned. Alternatively, you could use bind
to pick the port yourself.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.