From e51c8d87adcd5476e23d8abd6dcae6da350aa761 Mon Sep 17 00:00:00 2001 From: jenz Date: Thu, 28 Apr 2022 21:12:51 +0200 Subject: [PATCH] update for now. technically speaking could some kind of fingerprinting be very usefull here --- .../python/nosteam_checker.py | 49 +++++++++++++++++++ .../scripting/nosteam_verifier.sp | 2 +- .../systemctl/kicklist.service | 10 ++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 nosteam_verificiation/python/nosteam_checker.py create mode 100644 nosteam_verificiation/systemctl/kicklist.service diff --git a/nosteam_verificiation/python/nosteam_checker.py b/nosteam_verificiation/python/nosteam_checker.py new file mode 100644 index 00000000..a0ae75fb --- /dev/null +++ b/nosteam_verificiation/python/nosteam_checker.py @@ -0,0 +1,49 @@ +#!/home/nonroot/import_bans/venv/bin/python3 +from settings import (get_connection) + +def create_tables(): + with get_connection() as conn: + with conn.cursor() as cur: + sql_statement = """ + CREATE TABLE IF NOT EXISTS + `unloze_anti-spoofing`.kicklist + ( + steam_id varchar(64) not null, + ipv4 varchar(64) not null, + kick boolean default FALSE, + inserted_on datetime default now(), + primary key (steam_id, ipv4) + ) + """ + cur.execute(sql_statement) + +def select_into_recent_bans(): + with get_connection() as conn: + with conn.cursor() as cur: + sql_statement = """ + insert IGNORE + `unloze_anti-spoofing`.kicklist(steam_id, ipv4) + select + cr.steam_id, cr.ipv4 + from `unloze_anti-spoofing`.connect_restriction cr + where cr.cooldown > NOW() + """ + cur.execute(sql_statement) + +def update_kick_flag(): + with get_connection() as conn: + with conn.cursor() as cur: + sql_statement = """ + update `unloze_anti-spoofing`.kicklist set kick = true + """ + cur.execute(sql_statement) + +def main(): + create_tables() + print("new iteration") + select_into_recent_bans() + #TODO generate some fingerprints to base the kick flag being set by + update_kick_flag() + +if __name__ == '__main__': + main() diff --git a/nosteam_verificiation/scripting/nosteam_verifier.sp b/nosteam_verificiation/scripting/nosteam_verifier.sp index 48a6ba67..8ee6ae2a 100644 --- a/nosteam_verificiation/scripting/nosteam_verifier.sp +++ b/nosteam_verificiation/scripting/nosteam_verifier.sp @@ -257,7 +257,7 @@ public void sql_truncate_sb_bans_shortened(Database db, DBResultSet results, con if ((client = GetClientFromSerial(data)) == 0) return; char sql_statement[512]; - Format(sql_statement, sizeof(sql_statement), "select distinct ip, authid from sb_bans where ip is not null and ip != '' and authid is not null and authid != '' and (RemoveType != 'U' or RemoveType is NULL) and (ends = created or ends > UNIX_TIMESTAMP())"); + Format(sql_statement, sizeof(sql_statement), "select distinct ip, authid, name from sb_bans where ip is not null and ip != '' and authid is not null and authid != '' and (RemoveType != 'U' or RemoveType is NULL) and created > UNIX_TIMESTAMP(NOW() - INTERVAL 5 DAY) and (ends > UNIX_TIMESTAMP() or ends = created) order by created desc"); g_hDatabase_sourceban.Query(sql_select_sb_bans, sql_statement, GetClientSerial(client), DBPrio_High); delete results; } diff --git a/nosteam_verificiation/systemctl/kicklist.service b/nosteam_verificiation/systemctl/kicklist.service new file mode 100644 index 00000000..02e0f983 --- /dev/null +++ b/nosteam_verificiation/systemctl/kicklist.service @@ -0,0 +1,10 @@ +[Unit] +Description=constantly updating the kicklist + +[Service] +Type=simple +User=nonroot +WorkingDirectory=/home/nonroot/nosteam_verifier +Restart=always +RestartSec=5 +ExecStart=/home/nonroot/nosteam_verifier/nosteam_checker.py