--[[
GateKeeper written by Cêñoßy†ê
This script includes:
- Detection of faking users
- Has on/off option command
- Detect fake sharesizes (add/delete/show commands)
- Detect fake files (add/delete/show commands)
- Detection of forbidden files
- Has on/off option commands
- Add/delete/show commands
- Detection of kademlia enabled clients
- Has on/off option commands
- Add/delete/show commands
- Detection of empty 0b files
- Has on/off option commands
- Add/delete/show commands
- Has allso ignored data database with add/delete/show commands
- Option to change hubs UDP port
- Option to set up alternative hub IP
- Detection logging for 'data' to easyer check what detected when/how many times
- Report/kick mode for detections (report sends info to op-chat if op-chat enabled,else it sends info to main chat for operators)
- Adjustable command permissions
Ptokax default profiles:
-1 unregistered users
0 master
1 operator
2 vip
3 reg
Tested on:
Windows 8.1 ULTIMATE x64 PtokaX 0.5.2.2 556 Lua 5.3
Windows 10 PRO x64 PtokaX 0.5.2.2 556 Lua 5.3
Debian 9.0 x64 PtokaX 0.5.2.2 556 Lua 5.3
]]--
1.9
++ Added if IP not detected script disables detections so user can add correct ip 09.12.2020
++ Added automated resolve IP to Hostname activation (easyer for non GUI users,tested on win 10 x64) 09.12.2020
++ Added commands:
!gdel fakeshare <string> -- deletes fakesharesize from database (only numbers allowed) 16.01.2021
!gdel fakefile <string> -- deletes fake data from database (spaces etc UPPER/lower case data allowed) 16.01.2021
!gdel incomplete <string> -- deletes incomplete data from database (spaces etc UPPER/lower case data allowed) 16.01.2021
!gdel installed <string> -- deletes incomplete data from database (spaces etc UPPER/lower case data allowed) 16.01.2021
!gdel ignored <string> -- deletes ignored from database (spaces etc UPPER/lower case data allowed) 16.01.2021
!ghelp 30.12.2020
!gset report <on/off> -- sets reporting mode on/off 29.12.2020
!gadd fakeshare <string> -- adds fakeshare size to database (only numbers allowed) 29.12.2020
!gadd fakefile <string> -- adds fake data to database (spaces etc UPPER/lower case data allowed) 15.12.2020
!gadd incomplete <string> -- adds incomplete data to database (spaces etc UPPER/lower case data allowed) 15.12.2020
!gadd installed <string> -- adds incomplete data to database (spaces etc UPPER/lower case data allowed) 15.12.2020
!gadd ignore <string> -- adds ignored data to database (spaces etc UPPER/lower case data allowed) 15.12.2020
!gshow ignored 10.12.2020
!gshow fakeshres 09.12.2020
!gshow fakefiles 09.12.2020
!gshow incomplete 09.12.2020
!gshow installed 09.12.2020
!gshow forbidden 09.12.2020
!gset ip <ip> -- Set if script informs no IP detected 09.12.2020
!gset udp <port> -- Set if script informs no UDP detected 09.12.2020
!gset kademlia <on/off> 09.12.2020
!gset installed <on/off> 09.12.2020
!gset incomplete <on/off> 09.12.2020
!gset empty <on/off> 09.12.2020
!gset fake <on/off> 09.12.2020
!gset forbidden <on/off> 09.12.2020
++ Added linux host option by IP (settings.ini/IP)-- 02.12.2020 (requested by Mothman)
++ Added ip check if PtokaX cant find it
++ Added !glogs command (shows counters of all detections)
++ Added detection if user tryes download from bot(s)
** Re-written whole script
++ Added Kademlia detection
https://en.wikipedia.org/wiki/Kademlia ** Changed database style
v1.8
++ Added adjustable rightclick/help lists order 22.09.2020
++ Added detection of empty databases (all) 22.09.2020
** Changed bot description for new command 02.09.2020
-- if [ S] then detection action is SILENT
-- if [K] then detection action is KICK
-- if [R] then detection action is REPORT
** Changed command !reportdata <on/off> to !action <silent/kick/report> 02.09.2020
** Fixed attempt to concatenate local 'where' (a nil value) (reported by MothMan) 29.08.2020
++ Added installed programs/games detection 27.08.2020
++ Added commands:
-- !checkinstalled <on/off> enables/disables checking of installed data 27.08.2020
-- !addinstalled <data> adds data to database 27.08.2020
-- !delinstalled <data> deletes data from database 27.08.2020
-- !showinstalled shows database 27.08.2020
-- !reggbot option to hide the bot

<on/off> 27.08.2020
** Updated bot description with [IN] = installed 27.08.2020
-- [xx/xx/xx/xx/xx] = bad tth or data/bad sharesizes/ignored data/incomplete/installed in database
v1.7
++ Added command !addincomplete <data> 20.08.2020
++ Added command !delincomplete <data> 20.08.2020
** Fixed attempt to concatenate a nil value (local 'tth') (reported by Quasar) 19.08.2020
++ Added detection of 0 hubs on user TAG 13.07.2020
++ Added !showincomplete command 13.07.2020
++ Added !ghelp as help command as requested 13.07.2020
** Updated new description for bot 01.07.2020
-- [xx/xx/xx/xx] = bad tth or data/bad sharesizes/ignored data/incomplete in database
-- if [I ] then incomplete files detection enabled
-- if [E] then empty files detection enabled
-- if [B ] then bot detection enabled
-- if [R] then reporting enabled
++ Added on/off option for bot detection (requested by Beertje) 31.05.2020
++ Database 1685/35/18 02.06.2020
** Fixed bug with !addshare command on v1.6 23.05.2020
** Changed bot detection ip ban to 24 hours 17.05.2020
-- Removed tag from bot as useless 17.05.2020
++ Added Unknown arrival detection (ddos by PPK) 17.05.2020
++ Added command !checkincomplete on/off 13.05.2020
++ Added command !checkempty on/off 13.05.2020
++ Added incomplete file check (default every 10 seconds) 08.05.2020
-- Removed spam bot detection 08.05.2020
v1.6
++ Bad data/ignore data can be upper/lower or mixed case 14.04.2020
** Fixed bug in delete commands 14.04.2020
** Updated bot detection messages 08.04.2020
** Changed bot ip tempban to 120 minutes 08.04.2020
v1.5
** Fixed sharesize on fake share detection
** Updated bad data's
++ Added empty file TTH as protected TTH
++ Added empty files to report/kick (request from Mothman)
v1.4
++ Added detection of empty files (0 bytes)
- Sends pm to user what/where file detected
- Informs operators
++ Combined SRArrival and UDPSArrival as one
-- Huge code cleaning
** Changed reporting email to use PtokaX owner email
** Changed !reportfake and !reportpedo commands to !reportdata
** Changed all TTH/pedo commands
++ Bad TTH and bad data now in same file
-- Removed fakefiles.tbl
-- Removed pfiles.tbl
++ Added bad_data.tbl
++ Added new type on/off for profile options in commands
-- Removed IP logging
-- Removed nick/ip ban parts
++ 200 new TTHs

v 1.3
++ Added adjustable X times same number in share as fake share example 123000000b (default 6)
-- Removed adjustable time for time ban (uses ptokax default tempbantime)
+- Added adjustable email for report (if false detection)
++ Added 30 more fake file TTHs + more coming
** Arranged and updated pedodetection database
++ Added small cosmetic changes
++ Added new database counter
++ Added Spammerbot detection (From Angelique script by Cêñoßy†ê)
++ Added detection of possible fake file
** Changed pedofiles to own database
v 1.2
-- Rebuilded ip logging ( b )
-- Added ignore file ( b )
-- Added commands + rc: ( b )
!addignore <data> adds new ignored data
!delignore <data> deletes ignored data
!showignore shows all ignored data
!showtth shows all tth data
!deltth <data> deletes tth data
-- Fixed !delshare <sharesize> command ( b )
-- Added buildmode default is off ( c )
-- Code cleaning ( c )
-- Added counter for detected fake share ips ( d )
-- Added option for full nickban/ipban for fake shares detected 3 times ( d )
-- Added sharesize containing 5x 0-9 as hardcoded fake share ( d )
-- Updated !addshare <value> command to ignore hardcoded shares
-- Added changable timer times
-- Added changable count when fakes get banned
-- Rewritten fake share function
-- Added BOT detection (From Pinhead script by Cêñoßy†ê)
-- Updated ignored data function
v 1.1
-- Removed on/off for pedo/bad files
-- Added ignore list
-- Added !delshare <sharesize> command + rc
-- Added ip monitoring database cleaner
-- Added ip monitoring for detected ips
-- Added !showsettings command + rc
-- Added !reportpedo <on/off> command + rc
-- Added !reportfake <on/off> command + rc
-- Added !addshare <sharesize> command + rc
-- Added !addtth <tth> command + rc
-- Added settings file
-- Added database file for fakeshares
-- Added own folder for files
-- Added if bot name is empty script uses main bot name
-- Added fake share detector