Hfinger: Fingerprinting Malware by How It Speaks HTTP
Hook
Most malware families have distinctive HTTP 'accents' - subtle patterns in how they structure requests that persist even when payload content changes. Hfinger turns these behavioral quirks into compact fingerprints.
Context
Traditional network security tools focus on what malicious HTTP requests say - scanning payloads for known signatures, analyzing domains, checking IP reputation. But malware authors can trivially change these surface features. What's harder to change is how the malware speaks: the order of HTTP headers, the specific protocol version choices, the presence of non-standard characters, the request structure itself.
CERT Polska, Poland's national Computer Emergency Response Team, faced this problem at scale when analyzing thousands of malware samples. Existing fingerprinting tools like p0f focused on TCP/IP layers, while application-layer tools either weren't HTTP-specific or produced binary hashes that didn't help humans understand what they were looking at. They needed fingerprints that could group malware families together, remain readable to analysts, and be compact enough for efficient storage in SIEMs. Hfinger emerged from this operational need, backed by academic research comparing it to established tools like FATT and Mercury.
Technical Insight
Hfinger's architecture sits at an interesting intersection: it's a Python tool that wraps Tshark (Wireshark's command-line interface) to extract HTTP features, then applies custom logic to generate fingerprints. This hybrid approach leverages Tshark's mature packet dissection while adding malware-specific heuristics that generic network tools lack.
The fingerprinting process extracts multiple dimensions from each HTTP request: method (GET, POST), protocol version (HTTP/1.0, HTTP/1.1), header order (which matters because different HTTP libraries order headers differently), header values, and structural anomalies like non-ASCII characters in headers. Here's how you'd use it programmatically:
from hfinger import hfinger
# Analyze a pcap file and generate fingerprints
result = hfinger.hfinger(
pcap_file='malware_traffic.pcap',
output_file='fingerprints.txt',
report_mode=2 # Balanced mode (recommended default)
)
# The fingerprint format is human-readable:
# GET|1.1|Accept,User-Agent,Host|gzip,deflate|Mozilla/5.0
# Method|Version|Header_Order|Accept-Encoding|User-Agent_Start
What makes this powerful is the five report modes (0-4) that control feature granularity. Mode 0 includes minimal features for broad grouping, while Mode 4 includes everything down to specific header values - useful for precision but prone to collision (where benign and malicious traffic share fingerprints). Mode 2 strikes the validated balance: it captures method, version, header order, and key header values without over-fitting to individual samples. The academic paper accompanying Hfinger demonstrates this mode achieves the lowest collision rate while maintaining high malware family detection.
The tool's real cleverness is in what it ignores. Unlike payload-based signatures that break when malware authors change command-and-control protocols, Hfinger focuses on structural artifacts that emerge from the HTTP libraries and frameworks malware developers use. A malware family written in Python with the Requests library will have different header ordering than one using Java's HttpURLConnection, even if both hit the same C2 server. These patterns persist across campaigns.
For sandbox integration, Hfinger can process batch pcap files and output structured data:
import json
from hfinger import hfinger
# Process multiple pcap files from a malware sandbox
pcaps = ['sample1.pcap', 'sample2.pcap', 'sample3.pcap']
fingerprints = {}
for pcap in pcaps:
result = hfinger.hfinger(
pcap_file=pcap,
report_mode=2,
verbose=False
)
# Extract fingerprints and group by family
fingerprints[pcap] = result
# Feed to SIEM or threat intelligence platform
print(json.dumps(fingerprints, indent=2))
The dependency on Tshark is both a strength and constraint. Tshark handles the complex work of TCP reassembly, HTTP parsing across different protocol versions, and edge cases in malformed traffic (which malware often generates). But it means Hfinger inherits Tshark's performance characteristics - processing large pcaps is I/O bound and single-threaded. For operational deployment, you'd want to parallelize across multiple pcap files rather than expecting real-time streaming analysis.
Gotcha
The 'working prototype stage' disclaimer in the README isn't just legal covering - it reflects real operational constraints. Hfinger requires Tshark 2.2.0+ installed and accessible in your PATH, which sounds simple until you're deploying to containerized sandbox environments where you need to manage Wireshark dependencies, shared libraries, and proper permissions for packet capture tools. The Docker deployment story isn't documented, and you'll spend time figuring out the right base image and privilege escalation.
More fundamentally, Hfinger only works on captured pcap files, not live traffic. This means you need another tool (tcpdump, Wireshark, your sandbox's built-in capture) to generate the pcaps first, then process them offline. For real-time threat detection, you'd need to architect a pipeline: capture traffic in rolling windows, trigger Hfinger on completed captures, ingest results into your SIEM. That's infrastructure overhead. Tools like Zeek (formerly Bro) or Suricata can generate similar metadata in real-time, though without Hfinger's malware-specific fingerprinting logic. The trade-off is architectural complexity versus analytical precision.
The fingerprints themselves can also generate false positives. Legitimate software using the same HTTP libraries as malware will produce similar fingerprints. A Python script using Requests with default settings might match a malware family that also uses Requests. The tool helps group and identify patterns, but you still need contextual analysis - source IPs, domains, payload inspection - to separate signal from noise.
Verdict
Use if: you're doing malware analysis at scale (CERT team, security research, sandbox operation) and need human-readable HTTP signatures to group malware families, correlate campaigns, or feed threat intelligence platforms. The academic validation and comparison to established tools gives it credibility despite prototype status. It's particularly valuable when analyzing malware that uses uncommon HTTP libraries or non-standard request structures that generic tools miss. Also use if you're building automated analysis pipelines where you control the infrastructure and can manage Tshark dependencies. Skip if: you need real-time network monitoring (use Zeek/Suricata with custom HTTP logging instead), are analyzing encrypted HTTPS without decryption capabilities (use JA3/JA3S for TLS fingerprinting), require production-grade stability and support, or don't have the infrastructure to capture and store pcap files. The offline-only analysis model is a fundamental constraint that no amount of wrapper code will fix.