pgsqlpot 2.0.0__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- core/__init__.py +0 -0
- core/config.py +50 -0
- core/logfile.py +74 -0
- core/output.py +39 -0
- core/paths.py +53 -0
- core/protocol.py +161 -0
- core/tools.py +170 -0
- output_plugins/__init__.py +0 -0
- output_plugins/couch.py +68 -0
- output_plugins/datadog.py +74 -0
- output_plugins/discord.py +133 -0
- output_plugins/elastic.py +137 -0
- output_plugins/hpfeed.py +43 -0
- output_plugins/influx2.py +66 -0
- output_plugins/jsonlog.py +36 -0
- output_plugins/kafka.py +57 -0
- output_plugins/localsyslog.py +66 -0
- output_plugins/mongodb.py +83 -0
- output_plugins/mysql.py +210 -0
- output_plugins/nlcvapi.py +119 -0
- output_plugins/postgres.py +154 -0
- output_plugins/redisdb.py +47 -0
- output_plugins/rethinkdblog.py +46 -0
- output_plugins/slack.py +94 -0
- output_plugins/socketlog.py +40 -0
- output_plugins/sqlite.py +141 -0
- output_plugins/telegram.py +141 -0
- output_plugins/textlog.py +46 -0
- output_plugins/xmpp.py +193 -0
- pgsqlpot/__init__.py +25 -0
- pgsqlpot/cli.py +512 -0
- pgsqlpot/data/Dockerfile +56 -0
- pgsqlpot/data/docs/INSTALL.md +400 -0
- pgsqlpot/data/docs/INSTALLWIN.md +411 -0
- pgsqlpot/data/docs/PLUGINS.md +21 -0
- pgsqlpot/data/docs/TODO.md +8 -0
- pgsqlpot/data/docs/datadog/README.md +32 -0
- pgsqlpot/data/docs/discord/README.md +58 -0
- pgsqlpot/data/docs/geoipupdtask.ps1 +270 -0
- pgsqlpot/data/docs/mysql/README.md +176 -0
- pgsqlpot/data/docs/mysql/READMEWIN.md +157 -0
- pgsqlpot/data/docs/mysql/mysql.sql +85 -0
- pgsqlpot/data/docs/postgres/README.md +184 -0
- pgsqlpot/data/docs/postgres/READMEWIN.md +196 -0
- pgsqlpot/data/docs/postgres/postgres.sql +73 -0
- pgsqlpot/data/docs/slack/README.md +68 -0
- pgsqlpot/data/docs/sqlite3/README.md +131 -0
- pgsqlpot/data/docs/sqlite3/READMEWIN.md +123 -0
- pgsqlpot/data/docs/sqlite3/sqlite3.sql +69 -0
- pgsqlpot/data/docs/telegram/README.md +103 -0
- pgsqlpot/data/etc/honeypot.cfg +415 -0
- pgsqlpot/data/etc/honeypot.cfg.base +418 -0
- pgsqlpot/data/test/.gitignore +3 -0
- pgsqlpot/data/test/test.py +51 -0
- pgsqlpot/honeypot.py +117 -0
- pgsqlpot-2.0.0.dist-info/METADATA +152 -0
- pgsqlpot-2.0.0.dist-info/RECORD +61 -0
- pgsqlpot-2.0.0.dist-info/WHEEL +6 -0
- pgsqlpot-2.0.0.dist-info/entry_points.txt +2 -0
- pgsqlpot-2.0.0.dist-info/licenses/LICENSE +674 -0
- pgsqlpot-2.0.0.dist-info/top_level.txt +3 -0
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
# DO NOT EDIT THIS FILE!
|
|
2
|
+
# Changes to default files will be lost on update and are difficult to
|
|
3
|
+
# manage and support.
|
|
4
|
+
#
|
|
5
|
+
# Please make any changes to system defaults by overriding them in
|
|
6
|
+
# honeypot.cfg
|
|
7
|
+
#
|
|
8
|
+
# To override a specific setting, copy the name of the stanza and
|
|
9
|
+
# setting to the file where you wish to override it.
|
|
10
|
+
|
|
11
|
+
# ============================================================================
|
|
12
|
+
# General Honeypot Options
|
|
13
|
+
# ============================================================================
|
|
14
|
+
[honeypot]
|
|
15
|
+
|
|
16
|
+
# Sensor name is used to identify this honeypot instance. Used by the database
|
|
17
|
+
# logging modules such as JSON.
|
|
18
|
+
#
|
|
19
|
+
# If not specified, the logging modules will instead use the host name of the
|
|
20
|
+
# server as the sensor name.
|
|
21
|
+
#
|
|
22
|
+
# (default: the name of the local machine)
|
|
23
|
+
#sensor_name = myhostname
|
|
24
|
+
|
|
25
|
+
# Directory where to save log files in.
|
|
26
|
+
# Log files are named <log_filename>.YYYY-MM-DD in that directory
|
|
27
|
+
#
|
|
28
|
+
# (default: log)
|
|
29
|
+
log_path = log
|
|
30
|
+
|
|
31
|
+
# Log file name
|
|
32
|
+
#
|
|
33
|
+
# (default: stdout)
|
|
34
|
+
#log_filename =
|
|
35
|
+
|
|
36
|
+
# ============================================================================
|
|
37
|
+
# Network Specific Options
|
|
38
|
+
# ============================================================================
|
|
39
|
+
|
|
40
|
+
# Port to listen for incoming connections.
|
|
41
|
+
#
|
|
42
|
+
# (default: 5432)
|
|
43
|
+
#listen_port = 5432
|
|
44
|
+
|
|
45
|
+
# Site to query for one's public IP address
|
|
46
|
+
#
|
|
47
|
+
# (default: https://ident.me)
|
|
48
|
+
#public_ip_url = https://ident.me
|
|
49
|
+
|
|
50
|
+
# Enable to log the public IP of the honeypot (useful if listening on 127.0.0.1)
|
|
51
|
+
# IP address is obtained by querying public_ip_url
|
|
52
|
+
#
|
|
53
|
+
# (default: false)
|
|
54
|
+
#report_public_ip = false
|
|
55
|
+
|
|
56
|
+
# A comma-separated list of networks, connection from whose IPs won't be logged
|
|
57
|
+
#
|
|
58
|
+
# (default: none)
|
|
59
|
+
#blacklist=127.0.0.1,192.168.0.0/16
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# ============================================================================
|
|
63
|
+
# Output Plugins
|
|
64
|
+
# These provide an extensible mechanism to send audit log entries to third
|
|
65
|
+
# parties. The audit entries contain information on clients connecting to
|
|
66
|
+
# the honeypot.
|
|
67
|
+
#
|
|
68
|
+
# Output entries need to start with 'output_' and have the 'enabled' entry.
|
|
69
|
+
# ============================================================================
|
|
70
|
+
|
|
71
|
+
# CouchDB logging module
|
|
72
|
+
#
|
|
73
|
+
#[output_couch]
|
|
74
|
+
#enabled = false
|
|
75
|
+
#host = localhost
|
|
76
|
+
#port = 5984
|
|
77
|
+
#username = pgsqlpot
|
|
78
|
+
#password = secret
|
|
79
|
+
#database = pgsqlpot
|
|
80
|
+
#geoip = true
|
|
81
|
+
# Location of the databases used for geolocation
|
|
82
|
+
#geoip_citydb = data/GeoLite2-City.mmdb
|
|
83
|
+
#geoip_asndb = data/GeoLite2-ASN.mmdb
|
|
84
|
+
|
|
85
|
+
# Datadog output module
|
|
86
|
+
# sends JSON directly to Datadog
|
|
87
|
+
# mandatory field: api_key
|
|
88
|
+
# optional fields (fallback configured in module): ddsource, ddtags, service
|
|
89
|
+
# For more information on fields https://docs.datadoghq.com/api/latest/logs/#send-logs
|
|
90
|
+
#
|
|
91
|
+
#[output_datadog]
|
|
92
|
+
#enabled = false
|
|
93
|
+
#url = https://http-intake.logs.datadoghq.com/api/v2/logs
|
|
94
|
+
#api_key = abcdef1234567890fedcba0987654321
|
|
95
|
+
#ddsource = pgsqlpot
|
|
96
|
+
#ddtags = env:dev
|
|
97
|
+
#service = honeypot
|
|
98
|
+
# Host from which the logs are connected, default - current hostname
|
|
99
|
+
#hostname = pandora.nlcv.bas.bg
|
|
100
|
+
|
|
101
|
+
# Send output to a Discord webhook
|
|
102
|
+
#
|
|
103
|
+
#[output_discord]
|
|
104
|
+
#enabled = false
|
|
105
|
+
# Delay between messages (for rate limiting)
|
|
106
|
+
#delay = 2.0
|
|
107
|
+
#url = https://discord.com/api/webhooks/id/token
|
|
108
|
+
|
|
109
|
+
# Elasticsearch logging module
|
|
110
|
+
#
|
|
111
|
+
#[output_elastic]
|
|
112
|
+
#enabled = false
|
|
113
|
+
#host = localhost
|
|
114
|
+
#port = 9200
|
|
115
|
+
#index = pgsqlpot
|
|
116
|
+
#
|
|
117
|
+
# type has been deprecated since ES 6.0.0
|
|
118
|
+
# use _doc which is the default type. See
|
|
119
|
+
# https://stackoverflow.com/a/53688626 for
|
|
120
|
+
# more information
|
|
121
|
+
#
|
|
122
|
+
#type = _doc
|
|
123
|
+
#
|
|
124
|
+
# set pipeline = geoip to map src_ip to
|
|
125
|
+
# geo location data. You can use a custom
|
|
126
|
+
# pipeline but you must ensure it exists
|
|
127
|
+
# in elasticsearch.
|
|
128
|
+
#
|
|
129
|
+
#pipeline = geoip
|
|
130
|
+
#
|
|
131
|
+
# Authentication. When x-pack.security is enabled
|
|
132
|
+
# in ES, default users have been created and requests
|
|
133
|
+
# must be authenticated.
|
|
134
|
+
#
|
|
135
|
+
# Credentials
|
|
136
|
+
#
|
|
137
|
+
#username = pgsqlpot
|
|
138
|
+
#password = secret
|
|
139
|
+
#
|
|
140
|
+
# TLS encryption. Communications between the client (pgsqlpot)
|
|
141
|
+
# and the ES server should naturally be protected by encryption
|
|
142
|
+
# if requests are authenticated (to prevent from man-in-the-middle
|
|
143
|
+
# attacks). The following options are then paramount
|
|
144
|
+
# if username and password are provided.
|
|
145
|
+
#
|
|
146
|
+
# use ssl/tls
|
|
147
|
+
#ssl = true
|
|
148
|
+
# verify SSL certificates
|
|
149
|
+
#verify_certs = true
|
|
150
|
+
# Path to trusted CA certs on disk
|
|
151
|
+
#ca_certs = /path/to/cert/file/elastic_ca.crt
|
|
152
|
+
|
|
153
|
+
# HPFeeds
|
|
154
|
+
#
|
|
155
|
+
# Note the lack of "s" at the end:
|
|
156
|
+
#[output_hpfeed]
|
|
157
|
+
#enabled = false
|
|
158
|
+
#server = hpfeeds.mysite.org
|
|
159
|
+
#tlscert = /path/to/tls/cert/file
|
|
160
|
+
#port = 10000
|
|
161
|
+
#identifier = abc123
|
|
162
|
+
#secret = secret
|
|
163
|
+
#channel = pgsqlpot
|
|
164
|
+
|
|
165
|
+
# InfluxDB 2.0 logging module
|
|
166
|
+
#
|
|
167
|
+
#[output_influx2]
|
|
168
|
+
#enabled = false
|
|
169
|
+
#host = hostname
|
|
170
|
+
#token = token
|
|
171
|
+
#org = organization
|
|
172
|
+
#bucket = pgsqlpot
|
|
173
|
+
|
|
174
|
+
# JSON based logging module
|
|
175
|
+
#
|
|
176
|
+
#[output_jsonlog]
|
|
177
|
+
#enabled = false
|
|
178
|
+
#logfile = log/pgsqlpot.json
|
|
179
|
+
#epoch_timestamp = true
|
|
180
|
+
|
|
181
|
+
# Kafka logging module
|
|
182
|
+
#
|
|
183
|
+
#[output_kafka]
|
|
184
|
+
#enabled = false
|
|
185
|
+
#host = 127.0.0.1
|
|
186
|
+
#port = 9092
|
|
187
|
+
#topic = pgsqlpot
|
|
188
|
+
#username =
|
|
189
|
+
#password =
|
|
190
|
+
#debug = false
|
|
191
|
+
|
|
192
|
+
# MongoDB logging module
|
|
193
|
+
#
|
|
194
|
+
#[output_mongodb]
|
|
195
|
+
#enabled = false
|
|
196
|
+
#host = 127.0.0.1
|
|
197
|
+
#username = pgsqlpot
|
|
198
|
+
#password = secret
|
|
199
|
+
#database = pgsqlpot
|
|
200
|
+
# Note: .format(username, password, host) is done on the following string,
|
|
201
|
+
# so make sure that there are exactly 3 placeholders ({}) in it
|
|
202
|
+
#connection_string = mongodb+srv://{}:{}@{}/?retryWrites=true&w=majority&appName=Cluster0
|
|
203
|
+
# Whether to store geolocation data in the database
|
|
204
|
+
#geoip = true
|
|
205
|
+
# Location of the databases used for geolocation
|
|
206
|
+
#geoip_citydb = data/GeoLite2-City.mmdb
|
|
207
|
+
#geoip_asndb = data/GeoLite2-ASN.mmdb
|
|
208
|
+
|
|
209
|
+
# MySQL logging module
|
|
210
|
+
# Database structure for this module is supplied in docs/sql/mysql.sql
|
|
211
|
+
#
|
|
212
|
+
# MySQL logging requires extra software: sudo apt-get install libmysqlclient-dev
|
|
213
|
+
# MySQL logging requires an extra Python module: pip install mysql-python
|
|
214
|
+
#
|
|
215
|
+
#[output_mysql]
|
|
216
|
+
#enabled = false
|
|
217
|
+
#host = localhost
|
|
218
|
+
#database = pgsqlpot
|
|
219
|
+
#username = pgsqlpot
|
|
220
|
+
#password = secret
|
|
221
|
+
#port = 3306
|
|
222
|
+
#debug = false
|
|
223
|
+
# Whether to store geolocation data in the database
|
|
224
|
+
#geoip = true
|
|
225
|
+
# Location of the databases used for geolocation
|
|
226
|
+
#geoip_citydb = data/GeoLite2-City.mmdb
|
|
227
|
+
#geoip_asndb = data/GeoLite2-ASN.mmdb
|
|
228
|
+
|
|
229
|
+
# NLCV-BAS honeypot data aggregation API
|
|
230
|
+
#
|
|
231
|
+
#[output_nlcvapi]
|
|
232
|
+
#enabled = false
|
|
233
|
+
#host = https://api.nlcv.bas.bg/v1.0/honeypot
|
|
234
|
+
# Whether to store geolocation data in the database
|
|
235
|
+
#geoip = true
|
|
236
|
+
# Location of the databases used for geolocation
|
|
237
|
+
#geoip_citydb = data/GeoLite2-City.mmdb
|
|
238
|
+
#geoip_asndb = data/GeoLite2-ASN.mmdb
|
|
239
|
+
|
|
240
|
+
# PostgreSQL logging module
|
|
241
|
+
#
|
|
242
|
+
#[output_postgres]
|
|
243
|
+
#enabled = false
|
|
244
|
+
#host = hostname
|
|
245
|
+
#username = pgsqlpot
|
|
246
|
+
#password = secret
|
|
247
|
+
#port = 5432
|
|
248
|
+
#database = pgsqlpot
|
|
249
|
+
#debug = false
|
|
250
|
+
# Whether to store geolocation data in the database
|
|
251
|
+
#geoip = true
|
|
252
|
+
# Location of the databases used for geolocation
|
|
253
|
+
#geoip_citydb = data/GeoLite2-City.mmdb
|
|
254
|
+
#geoip_asndb = data/GeoLite2-ASN.mmdb
|
|
255
|
+
|
|
256
|
+
# RedisDB logging module
|
|
257
|
+
#
|
|
258
|
+
#[output_redisdb]
|
|
259
|
+
#enabled = false
|
|
260
|
+
#debug = true
|
|
261
|
+
#host = 127.0.0.1
|
|
262
|
+
#port = 6379
|
|
263
|
+
# DB of the redis server. Defaults to 0
|
|
264
|
+
#db = 0
|
|
265
|
+
# Password of the redis server. Defaults to None
|
|
266
|
+
#password = secret
|
|
267
|
+
# Name of the list to push to or the channel to publish to. Required
|
|
268
|
+
#keyname = pgsqlpot
|
|
269
|
+
# Method to use when sending data to redis.
|
|
270
|
+
# Can be one of [lpush, rpush, publish]. Defaults to lpush
|
|
271
|
+
#send_method = lpush
|
|
272
|
+
|
|
273
|
+
# Rethinkdb output module
|
|
274
|
+
#
|
|
275
|
+
#[output_rethinkdblog]
|
|
276
|
+
#enabled = false
|
|
277
|
+
#host = 127.0.0.1
|
|
278
|
+
#port = 28015
|
|
279
|
+
#table = events
|
|
280
|
+
#db = pgsqlpot
|
|
281
|
+
#user = admin
|
|
282
|
+
#password =
|
|
283
|
+
|
|
284
|
+
# Slack logging module
|
|
285
|
+
# This will produce a _lot_ of messages - you have been warned....
|
|
286
|
+
#
|
|
287
|
+
#[output_slack]
|
|
288
|
+
#enabled = false
|
|
289
|
+
#channel = channel_that_events_should_be_posted_in
|
|
290
|
+
#token = slack_token_for_your_bot
|
|
291
|
+
# Delay between messages (for rate limiting)
|
|
292
|
+
#delay = 1.2
|
|
293
|
+
|
|
294
|
+
# Socket logging module
|
|
295
|
+
#
|
|
296
|
+
#[output_socketlog]
|
|
297
|
+
#enabled = false
|
|
298
|
+
#address = 127.0.0.1:9000
|
|
299
|
+
#timeout = 5
|
|
300
|
+
|
|
301
|
+
# SQLite3 logging module
|
|
302
|
+
#
|
|
303
|
+
# Logging to SQLite3 database. To init the database, use the script
|
|
304
|
+
# docs/sql/sqlite3.sql:
|
|
305
|
+
# sqlite3 <db_file> < docs/sql/sqlite3.sql
|
|
306
|
+
#
|
|
307
|
+
#[output_sqlite]
|
|
308
|
+
#enabled = false
|
|
309
|
+
#debug = false
|
|
310
|
+
#db_file = data/pgsqlpot.db
|
|
311
|
+
# Whether to store geolocation data in the database
|
|
312
|
+
#geoip = true
|
|
313
|
+
# Location of the databases used for geolocation
|
|
314
|
+
#geoip_citydb = data/GeoLite2-City.mmdb
|
|
315
|
+
#geoip_asndb = data/GeoLite2-ASN.mmdb
|
|
316
|
+
|
|
317
|
+
# Local Syslog output module
|
|
318
|
+
#
|
|
319
|
+
# This sends log messages to the local syslog daemon.
|
|
320
|
+
#
|
|
321
|
+
#[output_localsyslog]
|
|
322
|
+
#enabled = false
|
|
323
|
+
# Facility can be:
|
|
324
|
+
# KERN, USER, MAIL, DAEMON, AUTH, LPR, NEWS, UUCP, CRON, SYSLOG and LOCAL0 to LOCAL7.
|
|
325
|
+
#
|
|
326
|
+
# default: USER
|
|
327
|
+
#facility = USER
|
|
328
|
+
|
|
329
|
+
# Send message using Telegram bot
|
|
330
|
+
# 1. Create a bot following https://core.telegram.org/bots#6-botfather to get token.
|
|
331
|
+
# 2. Send message to your bot, then use https://api.telegram.org/bot{bot_token}/getUpdates to find chat_id.
|
|
332
|
+
#
|
|
333
|
+
#[output_telegram]
|
|
334
|
+
#enabled = false
|
|
335
|
+
#bot_token = 123456789:AbCDEfGhiJkLmnOpQRstUVWxYZ
|
|
336
|
+
#chat_id = 987654321
|
|
337
|
+
# Delay between messages (for rate limiting)
|
|
338
|
+
#delay = 2.0
|
|
339
|
+
|
|
340
|
+
# Text output
|
|
341
|
+
# This writes audit log entries to a text file
|
|
342
|
+
#
|
|
343
|
+
#[output_textlog]
|
|
344
|
+
#enabled = false
|
|
345
|
+
#logfile = log/pgsqlpot.txt
|
|
346
|
+
|
|
347
|
+
# XMPP logging module
|
|
348
|
+
#
|
|
349
|
+
#[output_xmpp]
|
|
350
|
+
#enabled=false
|
|
351
|
+
#server = conference.pgsqlpot.local
|
|
352
|
+
#user = pgsqlpot@pgsqlpot.local
|
|
353
|
+
#password = secret
|
|
354
|
+
#muc = hacker_room
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
# TODO:
|
|
358
|
+
|
|
359
|
+
# Send login attemp information to SANS DShield
|
|
360
|
+
# See https://isc.sans.edu/ssh.html
|
|
361
|
+
# You must signup for an api key.
|
|
362
|
+
# Once registered, find your details at: https://isc.sans.edu/myaccount.html
|
|
363
|
+
#
|
|
364
|
+
#[output_dshield]
|
|
365
|
+
#enabled = false
|
|
366
|
+
#userid = userid_here
|
|
367
|
+
#auth_key = auth_key_here
|
|
368
|
+
#batch_size = 100
|
|
369
|
+
|
|
370
|
+
# Graylog logging module for GELF http input
|
|
371
|
+
#
|
|
372
|
+
#[output_graylog]
|
|
373
|
+
#enabled = false
|
|
374
|
+
#url = http://graylog.example.com:122011/gelf
|
|
375
|
+
|
|
376
|
+
# InfluxDB logging module
|
|
377
|
+
#
|
|
378
|
+
#[output_influx]
|
|
379
|
+
#enabled = false
|
|
380
|
+
#host = 127.0.0.1
|
|
381
|
+
#port = 8086
|
|
382
|
+
#database_name = pgsqlpot
|
|
383
|
+
#retention_policy_duration = 30d
|
|
384
|
+
|
|
385
|
+
# Oracle Cloud custom logs output module
|
|
386
|
+
# sends JSON directly to Oracle Cloud custom logs
|
|
387
|
+
# mandatory field: authtype, log_ocid
|
|
388
|
+
# optional fields (to be set if user_principals is selected as authtype): user_ocid, fingerprint, tenancy_ocid, region, keyfile
|
|
389
|
+
# For more information on Oracle Cloud custom logs: https://docs.oracle.com/en-us/iaas/Content/Logging/Concepts/custom_logs.htm
|
|
390
|
+
# For more information on Oracle Cloud user principal authentication method: https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#five
|
|
391
|
+
# For more information on Oracle Cloud instance principal authentication method: https://blogs.oracle.com/developers/post/accessing-the-oracle-cloud-infrastructure-api-using-instance-principals
|
|
392
|
+
#
|
|
393
|
+
#[output_oraclecloud]
|
|
394
|
+
#enabled = false
|
|
395
|
+
# authtype must be set either to user_principals or to instance_principals
|
|
396
|
+
#authtype = instance_principals
|
|
397
|
+
# following parameters must be set in case user_principals is used. keyfile is the absolute path to your API pem key file.
|
|
398
|
+
#log_ocid = ocid1.log.oc1.eu-stockholm-1.xxx
|
|
399
|
+
#user_ocid = ocid1.user.oc1..xxx
|
|
400
|
+
#fingerprint = 77:9c:4xxxxx
|
|
401
|
+
#tenancy_ocid = ocid1.tenancy.oc1..xxx
|
|
402
|
+
#region = eu-stockholm-1
|
|
403
|
+
#keyfile = /home/xx/key.pem
|
|
404
|
+
|
|
405
|
+
# Splunk HTTP Event Collector (HEC) output module
|
|
406
|
+
# sends JSON directly to Splunk over HTTP or HTTPS
|
|
407
|
+
# Use 'https' if your HEC is encrypted, else 'http'
|
|
408
|
+
# mandatory fields: url, token
|
|
409
|
+
# optional fields: index, source, sourcetype, host
|
|
410
|
+
#
|
|
411
|
+
#[output_splunk]
|
|
412
|
+
#enabled = false
|
|
413
|
+
#url = https://localhost:8088/services/collector/event
|
|
414
|
+
#token = 6A0EA6C6-8006-4E39-FC44-C35FF6E561A8
|
|
415
|
+
#index = pgsqlpot
|
|
416
|
+
#sourcetype = pgsqlpot
|
|
417
|
+
#source = pgsqlpot
|
|
418
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
from __future__ import print_function
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
__description__ = 'Test the PGSQLPot honeypot'
|
|
8
|
+
__license__ = 'GPL'
|
|
9
|
+
__VERSION__ = '1.0.0'
|
|
10
|
+
__author__ = 'Vesselin Bontchev'
|
|
11
|
+
__email__ = 'vbontchev@yahoo.com'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
from argparse import ArgumentParser
|
|
15
|
+
from os import environ
|
|
16
|
+
from sys import stderr
|
|
17
|
+
|
|
18
|
+
try:
|
|
19
|
+
from psycopg2 import connect, OperationalError
|
|
20
|
+
except ImportError:
|
|
21
|
+
print('Could not import module "psycopg2"; try "pip install psycopg2".', file=stderr)
|
|
22
|
+
exit(1)
|
|
23
|
+
|
|
24
|
+
def get_options():
|
|
25
|
+
parser = ArgumentParser(description=__description__)
|
|
26
|
+
|
|
27
|
+
parser.add_argument('-v', '--version', action='version', version='%(prog)s version ' + __VERSION__)
|
|
28
|
+
parser.add_argument('-P', '--port', type=int, default=5432,
|
|
29
|
+
help='Port to send data to (default: %(default)d)')
|
|
30
|
+
parser.add_argument('-H', '--host', default='127.0.0.1',
|
|
31
|
+
help='Host to communicate with (default: %(default)s)')
|
|
32
|
+
parser.add_argument('-u', '--user',
|
|
33
|
+
default=environ.get('USERNAME', '') or environ.get('USER', ''),
|
|
34
|
+
help='Username (default: %(default)s)')
|
|
35
|
+
parser.add_argument('-p', '--password', help='Password')
|
|
36
|
+
args = parser.parse_args()
|
|
37
|
+
return args
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def main():
|
|
41
|
+
args = get_options()
|
|
42
|
+
try:
|
|
43
|
+
connect(host=args.host, port=args.port, user=args.user, password=args.password)
|
|
44
|
+
except OperationalError as e:
|
|
45
|
+
print('Error: {}'.format(e.args[0]), file=stderr)
|
|
46
|
+
except KeyboardInterrupt:
|
|
47
|
+
pass
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
if __name__ == '__main__':
|
|
51
|
+
main()
|
pgsqlpot/honeypot.py
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
from argparse import ArgumentParser
|
|
5
|
+
from ipaddress import ip_network
|
|
6
|
+
from os.path import join
|
|
7
|
+
from socket import gethostname
|
|
8
|
+
from sys import version_info
|
|
9
|
+
|
|
10
|
+
from core.config import CONFIG
|
|
11
|
+
from core.logfile import set_logger
|
|
12
|
+
from core.paths import workdir_path
|
|
13
|
+
from core.protocol import PostgresFactory
|
|
14
|
+
from core.tools import (
|
|
15
|
+
get_public_ip,
|
|
16
|
+
import_plugins,
|
|
17
|
+
mkdir,
|
|
18
|
+
stop_plugins,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
from twisted.internet import error
|
|
22
|
+
from twisted.internet.reactor import listenTCP, run
|
|
23
|
+
from twisted.python.log import msg
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
__VERSION__ = '2.0.0'
|
|
27
|
+
__description__ = 'A PostgreSQL Honeypot'
|
|
28
|
+
__license__ = 'GPLv3'
|
|
29
|
+
__uri__ = 'https://gitlab.com/bontchev/pgsqlpot'
|
|
30
|
+
__author__ = 'Vesselin Bontchev'
|
|
31
|
+
__email__ = 'vbontchev@yahoo.com'
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
if version_info[0] >= 3:
|
|
35
|
+
def unicode(x):
|
|
36
|
+
return x
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def get_options(cfg_options):
|
|
40
|
+
parser = ArgumentParser(description=__description__)
|
|
41
|
+
|
|
42
|
+
parser.add_argument('-v', '--version', action='version', version=__VERSION__)
|
|
43
|
+
parser.add_argument('-p', '--port', type=int, default=cfg_options['port'],
|
|
44
|
+
help='Port to listen on (default: %(default)s)')
|
|
45
|
+
parser.add_argument('-l', '--logfile', type=str, default=cfg_options['logfile'],
|
|
46
|
+
help='Log file (default: stdout)')
|
|
47
|
+
parser.add_argument('-s', '--sensor', type=str, default=cfg_options['sensor'],
|
|
48
|
+
help='Sensor name (default: %(default)s)')
|
|
49
|
+
args = parser.parse_args()
|
|
50
|
+
return args
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def set_options():
|
|
54
|
+
cfg_options = {}
|
|
55
|
+
|
|
56
|
+
cfg_options['port'] = CONFIG.getint('honeypot', 'listen_port', fallback=5432)
|
|
57
|
+
log_name = CONFIG.get('honeypot', 'log_filename', fallback='')
|
|
58
|
+
if log_name:
|
|
59
|
+
logdir = workdir_path(CONFIG.get('honeypot', 'log_path', fallback='log'))
|
|
60
|
+
mkdir(logdir)
|
|
61
|
+
cfg_options['logfile'] = join(logdir, log_name)
|
|
62
|
+
else:
|
|
63
|
+
cfg_options['logfile'] = None
|
|
64
|
+
cfg_options['sensor'] = CONFIG.get('honeypot', 'sensor_name', fallback=gethostname())
|
|
65
|
+
|
|
66
|
+
args = get_options(cfg_options)
|
|
67
|
+
|
|
68
|
+
cfg_options['port'] = args.port
|
|
69
|
+
cfg_options['logfile'] = args.logfile
|
|
70
|
+
cfg_options['sensor'] = args.sensor
|
|
71
|
+
cfg_options['public_ip_url'] = CONFIG.get('honeypot', 'public_ip_url', fallback='https://ident.me')
|
|
72
|
+
cfg_options['report_public_ip'] = CONFIG.getboolean('honeypot', 'report_public_ip', fallback=False)
|
|
73
|
+
|
|
74
|
+
pub_ip = get_public_ip(cfg_options['public_ip_url'])
|
|
75
|
+
if pub_ip is None:
|
|
76
|
+
cfg_options['report_public_ip'] = False
|
|
77
|
+
cfg_options['public_ip'] = '127.0.0.1'
|
|
78
|
+
else:
|
|
79
|
+
cfg_options['public_ip'] = pub_ip
|
|
80
|
+
|
|
81
|
+
cfg_options['blacklist'] = CONFIG.get('honeypot', 'blacklist', fallback='127.0.0.1,192.168.0.0/16').split(',')
|
|
82
|
+
|
|
83
|
+
return cfg_options
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def main():
|
|
87
|
+
cfg_options = set_options()
|
|
88
|
+
|
|
89
|
+
set_logger(cfg_options)
|
|
90
|
+
|
|
91
|
+
msg(__description__ + ' by ' + __author__)
|
|
92
|
+
|
|
93
|
+
blacklist = []
|
|
94
|
+
for network in cfg_options['blacklist']:
|
|
95
|
+
try:
|
|
96
|
+
if network:
|
|
97
|
+
ip_network(unicode(network))
|
|
98
|
+
blacklist += [network]
|
|
99
|
+
except ValueError:
|
|
100
|
+
msg('Blacklist element "{}" is not a valid IP address; ignored.'.format(network))
|
|
101
|
+
cfg_options['blacklist'] = blacklist
|
|
102
|
+
|
|
103
|
+
cfg_options['output_plugins'] = import_plugins(cfg_options)
|
|
104
|
+
|
|
105
|
+
try:
|
|
106
|
+
listenTCP(cfg_options['port'], PostgresFactory(cfg_options))
|
|
107
|
+
except error.CannotListenError as e:
|
|
108
|
+
msg('Cannot listen on port {}: {}'.format(e.port, e.socketError.strerror))
|
|
109
|
+
stop_plugins(cfg_options)
|
|
110
|
+
return
|
|
111
|
+
run()
|
|
112
|
+
msg('Shutdown requested, exiting...')
|
|
113
|
+
stop_plugins(cfg_options)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
if __name__ == '__main__':
|
|
117
|
+
main()
|