Stealth Port Scanner question (recv())...

After sending a packet, I get a response...

1
2
3
int size = recv(socketDescriptor, buffer, sizeof(buffer), MSG_DONTWAIT);
cout << "received: " << size << endl;
cout << buffer << endl;


How do I decode the received chars so that I can see which flags are set/unset?
Last edited on
What flags? Do you mean the flags in the TCP header?
Yes, that is correct.

I'd like to know how to get the TCP flags (and IP flags if possible) and data content (if present).
Last edited on
You can't get them from the sockets library. It's job is to stop you worrying about such things.

You will need to packet capture in a seperate thread. The pcap (captured packets) will have all the commiunication info. You need to find the matching TCP packets and inspect them.

I've done this before. It's not as tricky as it sounds.
It seems odd that I need a sniffer thread to capture the packets instead of interpreting from the sockets library...
It's not odd if you understand the networking stack. When using a socket library, you are at the Application layer. TCP header information is in the Transport layer. The point of these layers is to separate out concern to only the relevant parties. As an application developer, you don't care about the transport information - you just care about application data. That is what a socket library will provide for you.
Topic archived. No new replies allowed.