title: Extract files from packet payload
body: <p>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 <em>save these files so I can view them</em>. 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 <em>write my own one</em>.
  <strong>The question is: how do I extract files from pcap capture file?</strong></p>
  
  <p>C code will be much appreciated.</p>
  
  <p><strong>Notice:</strong> WinPcap is OK, but it would be better if the code was multiplatform. </p>