Libpcap helps to capture network packets and save them in '.pcap' files. I know how to do this but how to extract files from the payload? I want to analyze pcap file, extract files (maybe using 'magic numbers' ?), guess their extension and save these files so I can view them. If someone downloaded a PNG image I want to get image.png on my computer. I know I can use Wireshark or any other sniffer but my aim is to write my own one. The question is: how do I extract files from pcap capture file?
C code will be much appreciated.
Notice: WinPcap is OK, but it would be better if the code was multiplatform.