Export Objects with --export-objects http,./objects
In this step, we'll explore how to extract files transferred over HTTP from a packet capture. When you capture network traffic containing HTTP communications, files like images, PDFs, or scripts are transmitted as binary objects within the HTTP protocol. Tshark provides a convenient way to extract these files for analysis.
First, let's navigate to the project directory where our packet capture file is stored. This ensures all our commands will work with the correct files:
cd ~/project
Before extracting files, we need a place to store them. The mkdir -p
command creates a directory called "objects" where Tshark will save the extracted files. The -p
flag means it won't show an error if the directory already exists:
mkdir -p objects
Now we'll use Tshark's powerful --export-objects
feature. This command scans through the packet capture, identifies HTTP file transfers, and reconstructs the original files. The syntax has two parts after --export-objects
: "http" specifies the protocol, and "./objects" is our output directory:
tshark -r http.pcap --export-objects http,./objects
Here's what happens when you run this command:
- Tshark reads the
http.pcap
file (-r
flag)
- It analyzes HTTP traffic and identifies file transfers
- Each found file is reconstructed and saved in the
./objects
directory
After running the command, Tshark will display each file it extracts. For example, you might see output like this showing the successful extraction of files:
Exporting HTTP object 1: image1.jpg
Exporting HTTP object 2: document.pdf
These files are now available in your objects
directory for further examination. This technique is particularly useful when analyzing web traffic or investigating file downloads during network troubleshooting.