From bb553d6318831d66a935a2066401ab1688284753 Mon Sep 17 00:00:00 2001 From: jenz Date: Sat, 9 Apr 2022 21:49:47 +0200 Subject: [PATCH] simple way to asn/country/provider for banned users and later also nosteam users --- nosteam_verificiation/python/update_sb.py | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 nosteam_verificiation/python/update_sb.py diff --git a/nosteam_verificiation/python/update_sb.py b/nosteam_verificiation/python/update_sb.py new file mode 100644 index 00000000..0a6d1459 --- /dev/null +++ b/nosteam_verificiation/python/update_sb.py @@ -0,0 +1,40 @@ +import time +import requests +from settings import get_connection + +def main(): + with get_connection() as conn: + with conn.cursor() as cur: + sql_statement = """ + select * + from `unloze_anti-spoofing`.sb_bans_shortened sb + left outer join `unloze_anti-spoofing`.connect_restriction cr on + sb.steam_id = cr.steam_id + where cr.asn is null + """ + cur.execute(sql_statement) + res = cur.fetchall() + for index, r in enumerate(res): + steam_id = r[0] + ip = r[1] + url = f"https://proxycheck.io/v2/{ip}?key=30r040-2w8k51-711148-8118n3&asn=1" + jrequest = requests.get(url).json() + #print(jrequest) + d = jrequest[ip] + asn = d["asn"] + provider = d["provider"] + country = d["country"] + with get_connection() as conn: + with conn.cursor() as cur: + sql_statement = """ + insert ignore into `unloze_anti-spoofing`.connect_restriction + (country, asn, provider, steam_id, ipv4) + values (%s, %s, %s, %s, %s) + """ + cur.execute(sql_statement, [country, asn, provider, steam_id, ip]) + conn.commit() + time.sleep(2.5) + print(f'at {index + 1}/{len(res)}') + +if __name__ == '__main__': + main()