Creating a simple port scanner using libnet and libpcap together

In Chapter 3, Using Libnet, we discussed how to use libnet to inject packets into the network. In this chapter, we discussed how to use libpcap to capture and analyze the incoming packets. The next logical question is, "How can we use libnet and libpcap to create some really awesome network security tools?" This recipe is written to show you how we can use libnet and libpcap together.

We will build a simple port scanner that scans a range of ports on a remote device and lists whether that port is open or closed. We will implement a SYN scan. This is a scan that sends a packet with the SYN flag set, and if the port is open, the remote device will respond with a packet that has the ...

Get iOS and OS X Network Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.