Scan TCP open ports on a server.
cc -o scan tcp_scan.c
scan IPV4_ADDRESS
Usage
$ ./scan -h
Usage: [-SC] <ip address>
-S default, scan with SYN packets
-C scan with connect(), i.e. the whole 3-way handshake procedure
NOTE
- Scanning with SYN packets (the default mode) only works on linux, since *BSD systems are not allowing applications to read packets through raw sockets for security issues.
- When you want to scan ports with SYN packets (on linux, of course), sudo priviledge may be required. Or, you can use the linux capbilities with
sudo setcap cap_net_admin,cap_net_raw=eip scan
, and then run it as normal.