How to extract files from HTTP traffic in a PCAP and hash them
When a host downloads something over plain HTTP, the whole file crosses the wire and the capture holds every byte. Rebuilding it lets you hash it, compare it with known-bad lists and hand it to malware analysis, without going back to the server it came from.
PCAPNG Analyzer Pro rebuilds every file sent or received over plain HTTP for you, decoded and hashed. It marks uploads and incomplete files, and checks every hash against your threat-intel lists. One click copies a hash or downloads the file.
Try it free on your own computer →1. What can be recovered
Only clear-text transfers can be rebuilt from a capture alone. In practice that means:
- Plain HTTP, on port 80 or any other port. Malware stagers, software updates, scripts and documents still travel this way more often than you might expect.
- Uploads as well as downloads. A form post or file upload carries a body too, and it is where data leaves the network.
- Other clear-text protocols, such as SMB without encryption, TFTP and email. Wireshark can export those too.
Files fetched over HTTPS are encrypted. Without the session keys, recorded at capture time (for example via a browser's SSLKEYLOGFILE), they can't be recovered from the capture, however complete it is.
2. Export objects in Wireshark
Choose File → Export Objects → HTTP. Wireshark reassembles each HTTP conversation and lists every body it found, with the packet, host name, content type, size and file name. Type in the filter box to narrow the list, then Save one object or Save All.
If HTTP runs on an unusual port and nothing is listed, right-click a packet in that conversation and use Decode As to treat the port as HTTP, then export again.
3. Export from the command line
tshark writes every HTTP object into a directory:
tshark -r capture.pcapng -q --export-objects http,objects
File names come from the URL, so expect names built from query strings, and numbered copies where names repeat. Don't trust a file name or its extension to say what a file is; the next step checks that. Swap http for smb, tftp or imf to export those protocols instead.
4. Hash and identify the files
# Linux and macOS (macOS: shasum -a 256)
sha256sum objects/*
# Windows PowerShell
Get-FileHash -Algorithm SHA256 objects\*
To compare against a list of known-bad SHA-256 hashes, one per line:
sha256sum objects/* | grep -i -F -f hashes.txt
Then check what each file really is. On Linux and macOS, file objects/* reads the first bytes rather than the name, so it shows an executable posing as an image. It also shows whether a body was saved still compressed (gzip compressed data). Threat feeds list the hash of the decoded file, so hash the decompressed version of any body that was sent with Content-Encoding: gzip.
5. Check each file is complete
A hash only means something for the whole file. A file is likely incomplete when:
- The capture started after the download began, or stopped before it ended.
- Packets are missing from the capture (look for
tcp.analysis.lost_segmentin that conversation). - The response was
206 Partial Content: a range request fetches a file in pieces, and each piece hashes differently. - The saved size doesn't match the response's
Content-Lengthheader.
An incomplete file can still be useful for its type, strings or embedded addresses, but its hash won't match any list. Say so in your notes rather than reporting "hash not found".
6. Handle files safely
- Don't open them on your workstation. A recovered file is exactly as dangerous as the original download.
- Look up the hash, don't upload the file. Searching a malware database for a hash reveals only the hash. Uploading a file can publish a confidential document to everyone with access to that service.
- Analyse in isolation: a disposable virtual machine with no route to your network.
- Share malware in a password-protected archive, so mail filters and colleagues' antivirus don't trip over it;
infectedis the conventional password. - Protect recovered documents as carefully as the capture: an upload may be the very data you are investigating the loss of.
"Not found" in a database only means nobody has reported that exact file. New or tailored malware is unknown by definition, and one changed byte changes the hash.
Manual method vs PCAPNG Analyzer
Manual method
- Export HTTP objects with Wireshark or tshark.
- Hash every file and compare with your lists.
- Check each file's real type and completeness.
- Decompress encoded bodies before hashing.
- Look up unknown hashes by hand.
With PCAPNG Analyzer
- Upload the capture.
- Under HTTP Hosts, choose See files: every file with its type, size and SHA-256 hash, with uploads and incomplete files marked.
- Copy a hash to look it up, or download the file to analyse in isolation. A hash on your threat-intel lists raises a finding.
Each conversation that carried an HTTP request is reassembled from the original capture, then bodies are de-chunked and decoded (gzip and deflate), so the hash is of the file itself, which is what threat feeds list. Brotli-encoded bodies are hashed as sent. Decoding stops at 64 MB per file and 256 MB per capture, so a compression "bomb" can't exhaust memory; a file past either limit is hashed as sent and marked incomplete. Downloads are always saved as files, never opened in the browser.
Every HTTP file, hashed and checked
See what crossed your network in clear text, with hashes matched against your own lists, on a server you control.
Compare Free and ProSelf-host it