CREATE OR REPLACE VIEW fake_bad_connections AS (SELECT * FROM fake_bad_connections_telnet) UNION (SELECT * FROM fake_bad_connections_ssh_honey);
CREATE OR REPLACE VIEW fake_bad_connections_telnet_alt AS SELECT
fake_logs.server,
fake_logs.remote,
remote_port,
local,
2323 AS local_port,
MIN(timestamp) AS start_time_utc,
MAX(timestamp) AS end_time_utc,
SUM((event = 'login')::INTEGER) AS login_attempts,
MIN(clients) AS clients_total
FROM
fake_logs
JOIN fake_blacklist ON fake_logs.remote = fake_blacklist.remote
WHERE
fake_logs.server = 'telnet_alt'
AND fake_blacklist.server = 'telnet_alt'
AND fake_blacklist.mode = 'hard'
AND remote_port IS NOT NULL
GROUP BY
fake_logs.server,
fake_logs.remote,
remote_port,
local
ORDER BY
fake_logs.remote,
local,
MIN(timestamp);
CREATE OR REPLACE VIEW fake_bad_connections_http AS SELECT
fake_logs.server,
fake_logs.remote,
remote_port,
local,
80 AS local_port,
MIN(timestamp) AS start_time_utc,
MAX(timestamp) AS end_time_utc,
SUM((event = 'login')::INTEGER) AS login_attempts,
MIN(clients) AS clients_total
FROM
fake_logs
JOIN fake_blacklist ON fake_logs.remote = fake_blacklist.remote
WHERE
fake_logs.server = 'http'
AND fake_blacklist.server = 'http'
AND fake_blacklist.mode = 'hard'
AND remote_port IS NOT NULL
GROUP BY
fake_logs.server,
fake_logs.remote,
remote_port,
local
ORDER BY
fake_logs.remote,
local,
MIN(timestamp);
CREATE OR REPLACE VIEW fake_bad_connections AS (SELECT * FROM fake_bad_connections_telnet) UNION (SELECT * FROM fake_bad_connections_telnet_alt) UNION (SELECT * FROM fake_bad_connections_http) UNION (SELECT * FROM fake_bad_connections_ssh_honey);