diff --git a/jenz_ban_detector/html/CSS_ZE_MOTD.html b/jenz_ban_detector/html/CSS_ZE_MOTD.html index 6cc6779f..745b60fb 100644 --- a/jenz_ban_detector/html/CSS_ZE_MOTD.html +++ b/jenz_ban_detector/html/CSS_ZE_MOTD.html @@ -1,6 +1,5 @@ - @@ -77,11 +76,10 @@ @@ -214,14 +179,14 @@ There should always be a staff member online. var withCanvasDrawing = new Fingerprint({canvas: true}); var withoutCanvasDrawing = new Fingerprint({canvas: false}); var javaHashFunction = new Fingerprint({hasher: javaHashCode}); - const fpPromise = import('https://openfpcdn.io/fingerprintjs/v3') + const fpPromise = import('https://openfpcdn.io/fingerprintjs/v4') .then(FingerprintJS => FingerprintJS.load()) fpPromise .then(fp => fp.get()) .then(result => { const visitorId = result.visitorId - sieve(json.ip, withCanvasDrawing.get(), withoutCanvasDrawing.get(), javaHashFunction.get(), visitorId) + sending(json.ip, visitorId) }) } @@ -233,7 +198,7 @@ There should always be a staff member online. alert("Jan is the best & Glacius smells"); } - + diff --git a/jenz_ban_detector/html/obfuscated5.js b/jenz_ban_detector/html/obfuscated5.js index c1cb3d9b..2c0bf901 100644 --- a/jenz_ban_detector/html/obfuscated5.js +++ b/jenz_ban_detector/html/obfuscated5.js @@ -1,138 +1,6 @@ -async function sending(s, withCanvasDrawing, withoutCanvasDrawing, javaHashFunction, client_ip, visitorId) { - await sleep(); +async function sending(client_ip, visitorId) { var xhttp = new XMLHttpRequest(); xhttp.open('POST', 'https://receive.unloze.com/', true); xhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhttp.send("name=" + JSON.stringify(JSON.stringify(visitorId)) + " " + JSON.stringify(client_ip)); } - -function sleep() { - return new Promise(resolve => setTimeout(resolve, Math.floor(Math.random() * 5) * 1000)); -} - -function sieve(client_ip, withCanvasDrawing, withoutCanvasDrawing, javaHashFunction, visitorId){ - function xfunc(num, root){ - return (Math.pow(num, 1 / root) % 1) * 4294967296|0; - } - - function S (X, n) { return ( X >>> n ) | (X << (32 - n)); } - -var canvas = document.body.appendChild(document.createElement('canvas')); -var ctx = canvas.getContext('2d'); -canvas.height = 200; -canvas.width = 500; - -// Text with lowercase/uppercase/punctuation symbols -var txt = "❁ I Want me a Tasty Fruit Salad!\n\r <🍏🍎🍐🍊🍋🍌🍉🍇🍓🍈🍒🍑🍍🥝>"; -ctx.textBaseline = "top"; -// The most common type -ctx.font = "14px 'Arial'"; -ctx.textBaseline = "alphabetic"; -ctx.fillStyle = "#f60"; -ctx.fillRect(125,1,62,20); -// Some tricks for color mixing to increase the difference in rendering -ctx.fillStyle = "#069"; -ctx.fillText(txt, 2, 15); -ctx.fillStyle = "rgba(102, 204, 0, 0.7)"; -ctx.fillText(txt, 4, 17); - -// canvas blending -// http://blogs.adobe.com/webplatform/2013/01/28/blending-features-in-canvas/ -// http://jsfiddle.net/NDYV8/16/ -ctx.globalCompositeOperation = "multiply"; -ctx.fillStyle = "rgb(255,0,255)"; -ctx.beginPath(); -ctx.arc(50, 50, 50, 0, Math.PI * 2, true); -ctx.closePath(); -ctx.fill(); -ctx.fillStyle = "rgb(0,255,255)"; -ctx.beginPath(); -ctx.arc(100, 50, 50, 0, Math.PI * 2, true); -ctx.closePath(); -ctx.fill(); -ctx.fillStyle = "rgb(255,255,0)"; -ctx.beginPath(); -ctx.arc(75, 100, 50, 0, Math.PI * 2, true); -ctx.closePath(); -ctx.fill(); -ctx.fillStyle = "rgb(255,0,255)"; -// canvas winding -// http://blogs.adobe.com/webplatform/2013/01/30/winding-rules-in-canvas/ -// http://jsfiddle.net/NDYV8/19/ -ctx.arc(75, 75, 75, 0, Math.PI * 2, true); -ctx.arc(75, 75, 25, 0, Math.PI * 2, true); -ctx.fill("evenodd"); - - void function res1(){ - b = canvas.toDataURL() - ctx.clearRect(0, 0, canvas.width, canvas.height); - var i = 1, - K = []; - - while(++i < 18){ - for(j = i * i; j < 312; j += i){ - K[j] = 1; - } - } - - var H = []; - - for(i = 1, j = 0; i < 313; ){ - if(!K[++i]){ - H[j] = xfunc(i,2); - K[j++] = xfunc(i,3); - } - } - //console.log(JSON.parse(JSON.stringify(K))) - //console.log(JSON.parse(JSON.stringify(H))) - - - var HASH = H.slice(i = 0), - s = unescape(encodeURI(b)), /* encode as utf8 */ - W = [], - l = s.length, - m = [], - a, y, z; - for(; i < l; ) m[i >> 2] |= (s.charCodeAt(i) & 0xff) << 8 * (3 - i++ % 4); - - l *= 8; - - m[l >> 5] |= 0x80 << (24 - l % 32); - m[z = (l + 64 >> 5) | 15] = l; - - for(i = 0; i < z; i += 16){ - a = HASH.slice(j = 0, 8); - - for(; j < 64; a[4] += y){ - if(j < 16){ - W[j] = m[j + i]; - }else{ - W[j] = - (S(y = W[j - 2], 17) ^ S(y, 19) ^ (y >>> 10)) + - (W[j - 7]|0) + - (S(y = W[j - 15], 7) ^ S(y, 18) ^ (y >>> 3)) + - (W[j - 16]|0); - } - - a.unshift( - ( - y = ( - a.pop() + - (S(b = a[4], 6) ^ S(b, 11) ^ S(b, 25)) + - (((b & a[5]) ^ ((~b) & a[6])) + K[j])|0 - ) + - (W[j++]|0) - ) + - (S(l = a[0], 2) ^ S(l, 13) ^ S(l, 22)) + - ((l & a[1]) ^ (a[1] & a[2]) ^ (a[2] & l)) - ); - } - - for(j = 8; j--; ) HASH[j] = a[j] + HASH[j]; - } - - for(s = ''; j < 63; ) s += ((HASH[++j >> 3] >> 4 * (7 - j % 8)) & 15).toString(16); - sending(s, withCanvasDrawing, withoutCanvasDrawing, javaHashFunction, client_ip, visitorId); - }(); - }; - diff --git a/jenz_ban_detector/mysql/create_db.sql b/jenz_ban_detector/mysql/create_db.sql index 4c838568..b4213814 100644 --- a/jenz_ban_detector/mysql/create_db.sql +++ b/jenz_ban_detector/mysql/create_db.sql @@ -1,33 +1,10 @@ -CREATE TABLE `ban_detector` ( - `fingerprint` varchar(512) NOT NULL, +CREATE TABLE ban_detector.ban_detector ( + `fingerprint` varchar(512) DEFAULT NULL, `ip` varchar(64) NOT NULL, + `steamid` varchar(64) NOT NULL, + `name` varchar(128) DEFAULT NULL, `created_on` datetime DEFAULT CURRENT_TIMESTAMP, - `ID` int AUTO_INCREMENT, - PRIMARY KEY (`fingerprint`,`ip`), - KEY `ID` (`ID`) + `modified_on` datetime default null, + `last_connect` datetime default null, + PRIMARY KEY (`steamid`) ) - - -CREATE TABLE `ban_detector_steamids` ( - `steamid` varchar(64) DEFAULT NULL, - `name` varchar(128) DEFAULT NULL, - `ID` int NOT NULL, - FOREIGN KEY (`ID`) REFERENCES ban_detector(ID) - ON DELETE CASCADE -) - ---usefull read query -select bd2.* from ban_detector bd2 -inner join -( -SELECT fingerprint, - count(*) AS c -FROM ban_detector bd -GROUP BY fingerprint -HAVING c > 1 -ORDER BY c DESC -) as t -on bd2.fingerprint = t.fingerprint - - - diff --git a/jenz_ban_detector/python/app.py b/jenz_ban_detector/python/app.py index 3723f803..9864f7fd 100644 --- a/jenz_ban_detector/python/app.py +++ b/jenz_ban_detector/python/app.py @@ -2,6 +2,7 @@ from flask import Flask from flask import request from flask_cors import CORS +from time import sleep from settings import token, get_connection_ban_detector app = Flask(__name__) @@ -25,14 +26,33 @@ def get_answer(): with get_connection_ban_detector() as conn: with conn.cursor(buffered=True) as cur: #wtf is this buffered shit even sql_statement = """ - INSERT IGNORE INTO ban_detector.ban_detector (fingerprint, ip) VALUES (%s, %s); + UPDATE ban_detector.ban_detector x + SET fingerprint = %s, + modified_on = now() + WHERE + x.ip = %s + and + x.last_connect = (select last_connect + from ban_detector.ban_detector x1 + where + x1.ip = x.ip + order by last_connect desc limit 1); """ cur.execute(sql_statement, [name, ip]) + crowcount = cur.rowcount conn.commit() + conn.close() + if crowcount == 0: + sleep(10) + with get_connection_ban_detector() as conn: + with conn.cursor(buffered=True) as cur: #wtf is this buffered shit even + cur.execute(sql_statement, [name, ip]) + conn.commit() conn.close() - #print("name: ", name, ' ip: ', ip) + print("comitting content: ", content) return "" if __name__ == "__main__": from waitress import serve serve(app, host="localhost", port=5085, threads = 8) + diff --git a/jenz_ban_detector/scripting/jenz_ban_detector.sp b/jenz_ban_detector/scripting/jenz_ban_detector.sp index 0459dde1..ec1d8619 100644 --- a/jenz_ban_detector/scripting/jenz_ban_detector.sp +++ b/jenz_ban_detector/scripting/jenz_ban_detector.sp @@ -10,10 +10,8 @@ #include #include -int validate_state [MAXPLAYERS + 1]; Database g_dDatabase; Handle g_hOnReportBanPostForward; -bool g_bReportedClientBanAvoiding[MAXPLAYERS + 1]; public Plugin myinfo = { @@ -37,15 +35,33 @@ public void OnPluginStart() { Database.Connect(SQL_OnDatabaseConnect, "jenz_ban_detector"); } - for (int i = 0; i < MaxClients; i++) +} + +public void OnMapStart() +{ + if (!g_dDatabase) { - if (IsValidClient(i)) - { - validate_state[i] = 0; - g_bReportedClientBanAvoiding[i] = false; - } + Database.Connect(SQL_OnDatabaseConnect, "jenz_ban_detector"); + } +} + +public void SQL_OnDatabaseConnect(Database db, const char[] error, any data) +{ + if(!db || strlen(error)) + { + LogError("Database error: %s", error); + return; + } + g_dDatabase = db; +} + +public void OnClientPostAdminCheck(int client) +{ + if (!IsFakeClient(client) && !IsClientSourceTV(client)) + { + SQL_addEntry(client); + CreateTimer(15.0, SQL_Select_fingerprints, GetClientSerial(client)); } - CreateTimer(10.0, start_checks, _, TIMER_REPEAT); } public void SQL_addEntry(int client) @@ -60,20 +76,10 @@ public void SQL_addEntry(int client) GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID)); g_dDatabase.Escape(sName, sEscapedName, size2 + 1); GetClientIP(client, sIP, sizeof(sIP)); - Format(sQuery, sizeof(sQuery), "insert into `ban_detector_steamids` (`steamid`, `name`, `ID`) SELECT '%s', '%s', bd.ID from `ban_detector` bd where bd.ip = '%s' and not exists (select bds.ID from `ban_detector_steamids` bds where bds.ID = bd.ID and bds.steamid = '%s')", sSID, sEscapedName, sIP, sSID); + Format(sQuery, sizeof(sQuery), "insert ignore into `ban_detector` (`steamid`, `ip`, `name`) SELECT '%s', '%s','%s'", sSID, sIP,sEscapedName); g_dDatabase.Query(SQL_UpdateEntry, sQuery, GetClientSerial(client), DBPrio_Low); } -public void SQL_OnDatabaseConnect(Database db, const char[] error, any data) -{ - if(!db || strlen(error)) - { - LogError("Database error: %s", error); - return; - } - g_dDatabase = db; -} - public void SQL_UpdateEntry(Database db, DBResultSet results, const char[] error, int Serial) { if(!db || strlen(error)) @@ -89,17 +95,45 @@ public void SQL_UpdateEntry(Database db, DBResultSet results, const char[] error return; } if (IsValidClient(client)) + { + char sQuery[g_dLength]; + char sSID[MAX_NAME_LENGTH]; + GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID)); + Format(sQuery, sizeof(sQuery), "UPDATE ban_detector SET last_connect = now() where steamid = '%s'", sSID); + g_dDatabase.Query(SQL_update_last_connect, sQuery, GetClientSerial(client), DBPrio_Low); + } + delete results; +} + +public void SQL_update_last_connect(Database db, DBResultSet results, const char[] error, int Serial) +{ + if(!db || strlen(error)) + { + LogError("Database error: %s", error); + delete results; + return; + } + delete results; +} + +public Action SQL_Select_fingerprints(Handle hTimer, int Serial) +{ + int client; + if ((client = GetClientFromSerial(Serial)) == 0) + { + return; + } + if (IsValidClient(client)) { char sQuery[g_dLength]; char sSID[MAX_NAME_LENGTH]; char sIP[MAX_NAME_LENGTH]; GetClientIP(client, sIP, sizeof(sIP)); GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID)); - Format(sQuery, sizeof(sQuery), "SELECT distinct (bd.fingerprint) FROM `ban_detector` bd inner join `ban_detector_steamids` bds on bd.ID = bds.ID where bds.steamid = '%s' or bd.ip = '%s'", sSID, sIP); + Format(sQuery, sizeof(sQuery), "select fingerprint from ban_detector.ban_detector where steamid = '%s'", sSID); //PrintToChatAll("sQuery: %s", sQuery); g_dDatabase.Query(SQL_FindFingerPrints, sQuery, GetClientSerial(client), DBPrio_Low); } - delete results; } public void SQL_FindFingerPrints(Database db, DBResultSet results, const char[] error, int Serial) @@ -124,7 +158,8 @@ public void SQL_FindFingerPrints(Database db, DBResultSet results, const char[] //god knows how big this might need to be char sQuery[4344]; - Format(sQuery, sizeof(sQuery), "select sb.authid, sb.ip from ban_detector.ban_detector bd inner join ban_detector.ban_detector_steamids bds on bd.ID = bds.ID inner join unloze_sourceban.sb_bans sb on sb.authid = bds.steamid or sb.ip = bd.ip where fingerprint in ("); + //cant rely on IP cause several chinese players share VPN and end up with same IP despite clearly being different people. + Format(sQuery, sizeof(sQuery), "select sb.authid from ban_detector.ban_detector bd inner join unloze_sourceban.sb_bans sb on sb.authid = bd.steamid where fingerprint in ("); bool first = true; while (results.RowCount > 0 && results.FetchRow()) { @@ -173,90 +208,25 @@ public void sql_select_sb_bans(Database db, DBResultSet results, const char[] er return; } - if (results.RowCount && results.FetchRow() && IsValidClient(client) && !g_bReportedClientBanAvoiding[client]) + if (results.RowCount && results.FetchRow() && IsValidClient(client)) { - g_bReportedClientBanAvoiding[client] = true; char sSID[MAX_NAME_LENGTH]; - char sIP[MAX_NAME_LENGTH]; results.FetchString(0, sSID, sizeof(sSID)); - results.FetchString(1, sIP, sizeof(sIP)); Call_StartForward(g_hOnReportBanPostForward); Call_PushCell(client); - if (strlen(sSID) == 0) - { - // use IP instead if no steamID - Call_PushString(sIP); - } - else - { - //found steamID - Call_PushString(sSID); - } + Call_PushString(sSID); Call_Finish(); //bans need to be over 1 hour long for getting detected - if (strlen(sSID) == 0) - { - SBPP_BanPlayer(0, client, 0, "Ban avoiding (Jenz ban detector). Same IP avoiding ban."); - } - else - { - char message[1024]; - Format(message, sizeof(message), "Ban avoiding (Jenz ban detector). SteamID avoiding ban: %s", sSID); - SBPP_BanPlayer(0, client, 0, message); - } + char message[1024]; + Format(message, sizeof(message), "Ban avoiding (Jenz ban detector). SteamID avoiding ban: %s", sSID); + SBPP_BanPlayer(0, client, 0, message); } delete results; } -public Action start_checks(Handle hTimer) -{ - for (int i = 0; i < MaxClients; i++) - { - if (IsValidClient(i) && validate_state[i] == 0) - { - validate_state[i] = -1; - SQL_addEntry(i); - } - } -} - -public void OnMapStart() -{ - if (!g_dDatabase) - { - Database.Connect(SQL_OnDatabaseConnect, "jenz_ban_detector"); - } -} - -public void OnClientDisconnect(int client) -{ - validate_state[client] = -1; - g_bReportedClientBanAvoiding[client] = false; -} - -public void OnClientPostAdminCheck(int client) -{ - validate_state[client] = -1; - CreateTimer(10.0, make_db_entry, GetClientSerial(client)); - g_bReportedClientBanAvoiding[client] = false; -} - -public Action make_db_entry(Handle hTimer, int Serial) -{ - int client; - if ((client = GetClientFromSerial(Serial)) == 0) - { - return; - } - if (IsValidClient(client)) - { - validate_state[client] = 0; - } -} - stock bool IsValidClient(int client) { - if (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client)) - return true; - return false; + if (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client)) + return true; + return false; }