forked from DNS-OARC/PacketQ
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
rickarddahlstrand edited this page May 2, 2011
·
37 revisions
This is the official homepage for PacketQ, a simple tool to make SQL-queries agains PCAP-files, making packet-analysis and building statistics simple and quick. PacketQ was previously know as DNS2db but was renamed in 2011 when it was rebuilt and could handle other protocols than DNS among other things.
Look how easy it's to count DNS-packets in a PCAP-file.
# packetq -s "select count(*) as count_dns from dns" packets.pcap
[
{
"table_name": "result",
"head": [
{ "name": "count_dns","type": "int" }
],
"data": [
[95501]
]
}
]
Read more in our FAQ and Examples section below.
- Super-fast native decoding of PCAP-files (even gzipped) and dirt-quick in-memory sorting algorithms.
- A extensible protocol decoding design with build in support for ICMP and DNS from start.
- Support for grouping, sorting, counting and most other important SQL-functions.
- Only dependent on zlib, no other hard-to-find libs needed. Compiles on everything.
- Build-in web-server, JSON API and a simple JQuery-based GUI concept application with graphs.
- Can be designed to cache queries by pre-processing PCAPs into static JSON-files that can be used to make queries again.
- Built in DNS-resolver function (used by GUI).
- Support for sampling. Helps when making queries to large, uniform PCAP-files.
- Can convert flags in packet-headers to text on the fly.
- Can make multiple queries towards the same data in memory.
See Functions
The short answer is no. Packet implements an SQL like select function with some notable omissions like:
- No 3 value logic i.e. theres no special NULL value
- No supports for joins or subqueries
- No support for the distinct keyword
- No support for like in where statements
Refer to the file grammar for supported statements.
Use this SQL-statement.
# packetq -s "select * from dns limit 3" packets.pcap
# packetq -s "select qname,count(*) as count from dns group by qname order by count desc limit 1 " packets.pcap
[
{ "table_name": "result",
"head": [
{ "name": "qname","type": "text" },
{ "name": "count","type": "int" }
],
"data": [ ["se.",2747] ]
}
]
# packetq -s "select src_addr,count(*) as count from dns group by src_addr order by count desc limit 1" packets.pcap
[
{
"table_name": "result",
"head": [
{ "name": "src_addr","type": "text" },
{ "name": "count","type": "int" }
],
"data": [
["::127.0.0.1",1849]
]
}
]
By using the sample-keyword before the actual query, it selects only every Xth packet.
# ./packetq -s "sample 1000; select count(*) from dns" ~/pcap/*
[ {
"table_name": "result",
"head": [ { "name": "count(1)","type": "int" }],
"data": [ [9000]] }]