DRILL-8556: Various PCAP and PCAP-NG Improvements by cgivre · Pull Request #3087 · apache/drill · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
1974d40
DRILL-8556: Various PCAP and PCAP-NG Improvements
cgivre Oct 2, 2026
2d2f356
DRILL-8556: Add design for PCAP protocol decoders
cgivre Oct 2, 2026
be84c93
DRILL-8556: Record malformed packet headers instead of failing
cgivre Oct 2, 2026
b08a520
DRILL-8556: Add protocol decoder interfaces and registry
cgivre Oct 2, 2026
2a6ee90
DRILL-8556: Add exposeCredentials format option
cgivre Oct 2, 2026
dcf50af
DRILL-8556: Add decoder columns and never-fail errors to the PCAP-NG …
cgivre Oct 2, 2026
1a6adb7
DRILL-8556: Add decoder columns and never-fail errors to the PCAP reader
cgivre Oct 2, 2026
f61a5d6
DRILL-8556: Reassemble TCP streams for session protocol decoders
cgivre Oct 2, 2026
5315771
DRILL-8556: Keep map arrays nested in maps intact in scan output
cgivre Oct 2, 2026
fddb04e
DRILL-8556: Count projected array dimensions per column
cgivre Oct 2, 2026
bf9b3b5
DRILL-8556: Add DNS protocol decoder
cgivre Oct 2, 2026
04bd891
DRILL-8556: Add HTTP packet decoder
cgivre Oct 2, 2026
9671674
DRILL-8556: Add HTTP session decoder
cgivre Oct 2, 2026
84149b6
DRILL-8556: Document protocol decoders
cgivre Oct 2, 2026
55c34e3
DRILL-8556: Remove a debugging test and license the service files
cgivre Oct 2, 2026
78864e2
DRILL-8556: Pair HTTP requests with their final responses
cgivre Oct 2, 2026
400fc7f
DRILL-8556: Bound length fields and report packet errors in session mode
cgivre Oct 2, 2026
ae6595e
DRILL-8556: Rename the PCAP-NG timestamp column to packet_timestamp
cgivre Oct 2, 2026
8c19ccd
DRILL-8556: Fix minor decoder issues found in review
cgivre Oct 2, 2026
d29f569
DRILL-8556: Document the packet_timestamp column
cgivre Oct 2, 2026
9c9c0dd
DRILL-8556: Add link and IP payload accessors for protocol decoders
cgivre Oct 2, 2026
1061de1
DRILL-8556: Read compressed and damaged captures reliably
cgivre Oct 2, 2026
4ac2c40
DRILL-8556: Add ICMP and ICMPv6 protocol decoder
cgivre Oct 2, 2026
8cef513
DRILL-8556: Add ARP protocol decoder
cgivre Oct 2, 2026
c63ab79
DRILL-8556: Add ICMP and ARP decoder fixtures and query tests
cgivre Oct 2, 2026
5d63c34
DRILL-8556: Merge ICMP and ARP decoders
cgivre Oct 2, 2026
8c4f981
DRILL-8556: Add NTP, syslog, SSDP and SIP protocol decoders
cgivre Oct 2, 2026
3fec4c7
DRILL-8556: Add DHCP, DHCPv6 and TFTP protocol decoders
cgivre Oct 2, 2026
fb8afbc
DRILL-8556: Add NetBIOS Name Service protocol decoder
cgivre Oct 2, 2026
0fa53ee
DRILL-8556: Add RADIUS protocol decoder
cgivre Oct 2, 2026
2e93f48
DRILL-8556: Add SNMP protocol decoder
cgivre Oct 2, 2026
917ff1f
DRILL-8556: Register NetBIOS-NS, RADIUS and SNMP decoders and add que…
cgivre Oct 2, 2026
32a2eb8
DRILL-8556: Add TLS hello protocol decoder
cgivre Oct 2, 2026
d1d8b42
DRILL-8556: Add STUN protocol decoder
cgivre Oct 2, 2026
386fa53
DRILL-8556: Merge NTP, syslog, SSDP and SIP decoders
cgivre Oct 2, 2026
28e7cc1
DRILL-8556: Merge DHCP, DHCPv6 and TFTP decoders
cgivre Oct 2, 2026
7352f9c
DRILL-8556: Merge NetBIOS-NS, RADIUS and SNMP decoders
cgivre Oct 2, 2026
d0e7341
DRILL-8556: Merge TLS hello and STUN decoders
cgivre Oct 2, 2026
21cd891
DRILL-8556: Let harvest grow vectors past the batch size limit
cgivre Oct 2, 2026
92863f4
DRILL-8556: Add TLS session protocol decoder
cgivre Oct 2, 2026
008481b
DRILL-8556: Test that decoder field names need no quoting
cgivre Oct 2, 2026
d35e779
DRILL-8556: Merge TLS session decoder
cgivre Oct 2, 2026
4ef3087
DRILL-8556: Point the TLS session test at its fixture script
cgivre Oct 2, 2026
4c1d203
DRILL-8556: Add FTP, SSH and DNS over TCP session decoders
cgivre Oct 2, 2026
939ddbb
Merge branch 'dec-g' into pcap-improvements
cgivre Oct 2, 2026
196849b
DRILL-8556: Document phase 2 and 3 protocol decoders
cgivre Oct 2, 2026
aa85060
DRILL-8556: Add SMTP, POP3 and IMAP protocol decoders
cgivre Oct 2, 2026
2f6f1e6
Merge branch 'dec-f' into pcap-improvements
cgivre Oct 2, 2026
2ba9c8d
DRILL-8556: Rename reserved mail field names and document mail decoders
cgivre Oct 2, 2026
466a41b
DRILL-8556: Add JA4 TLS client fingerprint to the tls decoder
cgivre Oct 2, 2026
5edd61c
DRILL-8556: Add Telnet protocol decoder
cgivre Oct 2, 2026
03803ed
DRILL-8556: Add RDP protocol decoder
cgivre Oct 2, 2026
485c093
DRILL-8556: Add MQTT protocol decoder
cgivre Oct 2, 2026
cbf749b
DRILL-8556: Add SMB2/SMB3 session decoder with shared NTLMSSP parser
cgivre Oct 2, 2026
c87c76e
Merge branch 'dec-a' into pcap-improvements
cgivre Oct 2, 2026
9a984ca
DRILL-8556: Add QUIC Initial packet decoder with ClientHello and JA4
cgivre Oct 2, 2026
e14244b
DRILL-8556: Add Kerberos protocol decoder
cgivre Oct 2, 2026
51c5ad3
DRILL-8556: Add LDAP session protocol decoder
cgivre Oct 2, 2026
9cc36c0
Merge branch 'dec-c' into pcap-improvements
cgivre Oct 2, 2026
e74d114
Merge branch 'dec-b' into pcap-improvements
cgivre Oct 2, 2026
769cd85
DRILL-8556: Document phase 4 decoders (auth protocols, QUIC, JA4)
cgivre Oct 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
105 changes: 103 additions & 2 deletions contrib/format-pcapng/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,107 @@ The following table lists configuration attributes:
Attribute|Default Value|Description
---------|-------------|-----------
stat|false|return the statistics data about the each pcapng file if true
sessionizeTCPStreams|false|return one row per TCP session instead of one row per packet, for both PCAP and PCAP-NG. A session is written when it closes (FIN or RST). Sessions still open at the end of the file, such as ones that outlived the capture, are written last with `session_closed` false
exposeCredentials|false|include cleartext passwords found by protocol decoders in `parsed_data`; usernames and a `password_present` flag are always included

## ToDo
We plan to refactor the NG parser because of the `pcapngdecoder` so bad to process huge pcapng file. (Neither efficient nor support parser packet as stream)
## PCAP-NG columns

PCAP-NG files are streamed one block at a time, so file size is not limited by memory.

In addition to the packet columns above, packet queries return the following metadata.
The time of each packet is in `packet_timestamp`, the same column name as in PCAP files. (It was named
`timestamp` in PCAP-NG files before; that name is a reserved word that had to be quoted in every query.)
Timestamps honor each interface's `if_tsresol` and `if_tsoffset`.

Column|Description
------|-----------
captured_length|Bytes of the packet stored in the file (`packet_length` is the original length on the wire)
interface_id|Index of the capturing interface within its section
interface_name|`if_name` of the capturing interface
link_type|[LINKTYPE_ value](https://www.tcpdump.org/linktypes.html) of the capturing interface
comment|Packet comments (`opt_comment`), newline separated
direction|`inbound` or `outbound` (`epb_flags`)
reception_type|`unicast`, `multicast`, `broadcast` or `promiscuous` (`epb_flags`)
fcs_length|Frame check sequence length in octets (`epb_flags`)
drop_count|Packets lost since the preceding packet (`epb_dropcount`)
packet_hash|`epb_hash` as `algorithm:hex`, such as `md5:9e107d9d...`

IP, port and TCP columns are decoded for these link types: Ethernet (1), raw IP (101, 228, 229),
BSD loopback (0, 108), PPP (9), Linux cooked capture v1 and v2 (113, 276). On other link types they are null,
and the MAC address columns are only set for Ethernet.

With `stat` set to true, options a block does not have are null. The `comment` column holds the section, interface, name resolution or
statistics block comment.

## Protocol decoding

Packets and TCP sessions whose application protocol is recognized are decoded into three columns, in both
PCAP and PCAP-NG files:

Column|Description
------|-----------
parsed_protocol|Name of the decoder that handled the row, such as `dns` or `http`; null if none did
parsed_data|One map per decoder, named after its protocol; only the one named by `parsed_protocol` is filled
decode_error|Why the row could not be fully decoded; null when there was no problem

```sql
-- DNS questions and answers
SELECT t.parsed_data.dns.questions[0].name AS query, t.parsed_data.dns.answers
FROM dfs.`capture.pcapng` t
WHERE parsed_protocol = 'dns';

-- HTTP requests, one row per connection
SELECT src_ip, t.parsed_data.http.exchanges[0].host AS host, t.parsed_data.http.exchanges[0].uri AS uri
FROM table(dfs.`capture.pcap` (type => 'pcap', sessionizeTCPStreams => true)) t
WHERE parsed_protocol = 'http';

-- What could not be decoded
SELECT decode_error, count(*) FROM dfs.`capture.pcapng`
WHERE decode_error IS NOT NULL GROUP BY decode_error;
```

Built-in decoders:

Protocol|Rows|Matches
--------|----|-------
dns|packets|DNS, mDNS and LLMNR on ports 53, 5353 and 5355
dns|sessions|DNS over TCP port 53, such as zone transfers
http|packets and sessions|HTTP/1.x on ports 80, 591, 3128, 8000, 8008, 8080 and 8888
icmp|packets|ICMP and ICMPv6
arp|packets|ARP
ntp|packets|UDP 123
syslog|packets|UDP 514, RFC 5424 and BSD formats
ssdp|packets|UDP 1900
sip|packets|UDP and TCP 5060
dhcp|packets|UDP 67 and 68
dhcpv6|packets|UDP 546 and 547
tftp|packets|UDP 69
netbios_ns|packets|UDP 137
radius|packets|UDP 1812, 1813, 1645 and 1646
snmp|packets|UDP 161 and 162, versions 1, 2c and 3
tls|packets|ClientHello and ServerHello (SNI, ALPN, JA3, JA3S, JA4) on TLS ports such as 443, 993 and 8443
tls|sessions|Full handshake on the same ports: negotiated version and cipher, certificates
stun|packets|UDP 3478 and 19302
quic|packets|QUIC v1 Initial on UDP 443: ClientHello (SNI, ALPN, JA4) decrypted from public keys
kerberos|packets|Kerberos on port 88: message type, principals, encryption types, errors
ftp|sessions|FTP control channel on port 21
ssh|sessions|SSH identification and key exchange (HASSH) on ports 22 and 2222
smtp|sessions|SMTP on ports 25, 587 and 2525: credentials, envelope, message headers
pop3|sessions|POP3 on port 110: credentials, retrieved message headers
imap|sessions|IMAP on port 143: credentials, mailboxes, fetched message headers
smb|sessions|SMB2/3 on ports 445 and 139: dialect, signing, and NTLM/Kerberos identity (no hashes)
ldap|sessions|LDAP on port 389: bind DNs, auth result, search filters
telnet|sessions|Telnet on port 23: negotiated options and session text
rdp|sessions|RDP on port 3389: the mstshash cookie and requested security protocols
mqtt|sessions|MQTT on port 1883: client id, credentials, topics

A decoder only handles traffic that parses as its protocol: other traffic on the same port is left undecoded.
Decoding runs only when `parsed_protocol` or `parsed_data` is queried.

Errors never stop a file from being read. Malformed packets keep the fields that could be read and explain
the problem in `decode_error`. Damage that makes the rest of a file unreadable, or a file that is not a
capture at all, produces one row with only `decode_error` set; exclude such rows with
`WHERE decode_error IS NULL`.

Fields of each decoder, and how to write a decoder of your own, are described in
`docs/dev/PcapProtocolDecoders.md`.
5 changes: 0 additions & 5 deletions contrib/format-pcapng/pom.xml
Loading
Loading