Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.

Commit 0a90c29

Browse files
committed
postgresql: Some notes about the PostgreSQL analyzer
1 parent 148dfe9 commit 0a90c29

File tree

2 files changed

+99
-1
lines changed

2 files changed

+99
-1
lines changed

logs/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ Zeek Logs
1919
ntp
2020
smb
2121
irc
22-
rdp
2322
ldap
23+
postgresql
2424
quic
25+
rdp
2526
traceroute
2627
tunnel
2728
dpd

logs/postgresql.rst

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
.. _PostgreSQL protocol: https://www.postgresql.org/docs/current/protocol.html
2+
3+
==============
4+
postgresql.log
5+
==============
6+
7+
.. versionadded:: 7.1
8+
9+
Overview
10+
========
11+
12+
Zeek contains a basic spicy-based `PostgreSQL protocol`_ analyzer.
13+
14+
Example
15+
=======
16+
17+
An example of :file:`postgresql.log`.
18+
19+
.. code-block:: console
20+
21+
$ zeek -C LogAscii::use_json=T -r psql-create-insert-select-delete-drop.pcap
22+
$ jq < postgresql.log
23+
{
24+
"ts": 1725368066.79174,
25+
"uid": "C68Wxi3EStaTmxaUVl",
26+
"id.orig_h": "127.0.0.1",
27+
"id.orig_p": 40190,
28+
"id.resp_h": "127.0.0.1",
29+
"id.resp_p": 5432,
30+
"user": "postgres",
31+
"database": "postgres",
32+
"application_name": "psql",
33+
"frontend": "simple_query",
34+
"frontend_arg": "CREATE TABLE IF NOT EXISTS t (i int, s varchar, t time);",
35+
"success": true,
36+
"rows": 0
37+
}
38+
{
39+
"ts": 1725368066.80694,
40+
"uid": "C68Wxi3EStaTmxaUVl",
41+
"id.orig_h": "127.0.0.1",
42+
"id.orig_p": 40190,
43+
"id.resp_h": "127.0.0.1",
44+
"id.resp_p": 5432,
45+
"user": "postgres",
46+
"database": "postgres",
47+
"application_name": "psql",
48+
"frontend": "simple_query",
49+
"frontend_arg": "INSERT INTO t VALUES (42, 'forty-two', now());",
50+
"success": true,
51+
"rows": 0
52+
}
53+
54+
55+
:zeek:see:`PostgreSQL::Info` provides further details about the current output of the
56+
:file:`postgresql.log`.
57+
58+
TLS
59+
===
60+
61+
The PostgreSQL protocol provides a mechanism to upgrade client-server connections
62+
to TLS. The analyzer detects this mechanism and hands-off analysis to Zeek's
63+
TLS analyzer. The ``postgresql.log`` and ``conn.log`` files will look
64+
as follows:
65+
66+
.. code-block:: console
67+
68+
$ zeek -C LogAscii::use_json=T -r testing/btest/Traces/postgresql/psql-aws-ssl-preferred.pcap
69+
$ jq < postgresql.log
70+
{
71+
"ts": 1670520068.267888,
72+
"uid": "CAcbxM1ou0N1V2cGpe",
73+
"id.orig_h": "192.168.123.132",
74+
"id.orig_p": 39910,
75+
"id.resp_h": "52.200.36.167",
76+
"id.resp_p": 5432,
77+
"frontend": "ssl_request",
78+
"backend": "ssl_reply",
79+
"backend_arg": "S",
80+
"success": true
81+
}
82+
83+
$ jq < conn.log
84+
{
85+
"ts": 1670520068.15752,
86+
"uid": "CAcbxM1ou0N1V2cGpe",
87+
"id.orig_h": "192.168.123.132",
88+
"id.orig_p": 39910,
89+
"id.resp_h": "52.200.36.167",
90+
"id.resp_p": 5432,
91+
"proto": "tcp",
92+
"service": "postgresql,ssl",
93+
"duration": 0.931433916091919,
94+
"orig_bytes": 786,
95+
"resp_bytes": 4542,
96+
...
97+
}

0 commit comments

Comments
 (0)