paclo.decode-ext lets you annotate or transform decoded packets immediately after decode,
without changing the base parser (parse/packet->clj).
m -> m' where m is a packet map from (packets {:decode? true ...}).:decoded exists and :decode-error is absent.m -> m') is stable.register!, unregister!, installed, and apply! behavior is part of the public API contract.(require '[paclo.decode-ext :as dx])
(dx/register! ::my-hook
(fn [m]
(if (= :udp (get-in m [:decoded :l3 :l4 :type]))
(assoc-in m [:decoded :note] "hello-udp")
m)))
(dx/unregister! ::my-hook)
(dx/installed)
paclo.core/packets calls decode-ext/apply! when :decode? true is set, so every decoded packet
passes through installed hooks.
(require '[paclo.proto.dns-ext :as dns-ext])
(dns-ext/register!)
;; Adds [:decoded :l3 :l4 :app :summary] to DNS packets
Repository-local CLI runs that use DNS extension should include :dns-ext:
clojure -M:dev:dns-ext -m examples.dns-topn test/resources/dns-sample.pcap
When Paclo is consumed as a dependency artifact, paclo.proto.dns-ext is included.
Extract SNI from TLS ClientHello on a best-effort basis (single-segment, no stream reassembly).
(require '[paclo.core :as core]
'[paclo.proto.tls-ext :as tls-ext])
(tls-ext/register!)
(into []
(comp
(filter #(= :tls (get-in % [:decoded :l3 :l4 :app :type])))
(map #(select-keys (get-in % [:decoded :l3 :l4 :app]) [:sni :summary])))
(core/packets {:path "tls-sample.pcap"
:filter "tcp and port 443"
:decode? true}))
CLI example:
clojure -M:dev -m examples.tls-sni-scan tls-sample.pcap 'tcp and port 443' 10 jsonl
:my.ns/hook).Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |