noPE

Ye olde RiotServers.net "anticheat"

Jan 13th, 2013
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.20 KB | None | 0 0
  1.  Stupid anticheat from RiotServers.net, written by some dumbass, circa October 2011
  2.  Included is a serverside counterpart "emulator" you can use to see if your shit gets past it
  3.  Have fun and go fuck yourself
  4.  
  5.  UAC_cl.lua
  6. if SERVER and not CLIENT then return end
  7. require "usermessage"
  8.  
  9. local GetConVar = GetConVar
  10. local GetConVarNumber = GetConVarNumber
  11. local GetConVarString = GetConVarNumber
  12. local setmetatable = setmetatable
  13. local getmetatable = getmetatable
  14. local RunConsoleCommand = RunConsoleCommand
  15. local AddConsoleCommand = AddConsoleCommand
  16. local engineConsoleCommand = engineConsoleCommand
  17. local rawget = rawget
  18. local rawset = rawset
  19. local type = type
  20. local string = string
  21. local math = math
  22. local timer = require "timer"
  23. local _hook = require "hook"
  24. local _debug = debug
  25. local _util = util
  26. local pcall = pcall
  27. local UAC = {}
  28.  
  29. local bResponse = false
  30. local bInform = false
  31. local bDebugValid = false
  32. local bMetaValid = false
  33. local protected_struct = {
  34.     "hook",
  35.     "debug"
  36. }
  37. local debug_struct = {
  38.     "getupvalue",
  39.     "sethook",
  40.     "getlocal",
  41.     "setlocal",
  42.     "gethook",
  43.     "getmetatable",
  44.     "setmetatable",
  45.     "traceback",
  46.     "setfenv",
  47.     "getinfo",
  48.     "setupvalue",
  49.     "getregistry",
  50.     "getfenv",
  51. }
  52. local detour_check_struct = {
  53.     ["file"] = {
  54.         "Read",
  55.         "Write",
  56.         "Exists",
  57.         "Find"
  58.     },
  59.     ["debug"] = {
  60.         "getupvalue",
  61.         "sethook",
  62.         "getlocal",
  63.         "setlocal",
  64.         "gethook",
  65.         "getmetatable",
  66.         "setmetatable",
  67.         "traceback",
  68.         "setfenv",
  69.         "getinfo",
  70.         "setupvalue",
  71.         "getregistry",
  72.         "getfenv",
  73.     },
  74.  
  75.     "GetConVar",
  76.     "GetConVarNumber",
  77.     "GetConVarString",
  78.     "engineConsoleCommand"
  79. }
  80. local cheat_specific_struct = {
  81.     ["FapHack"] = function()
  82.         local s, v = _debug.getupvalue( _G.hook.Add, 2 )
  83.         return s == "FapHack"
  84.     end,
  85.     ["detours"] = function()
  86.         local name, v
  87.  
  88.         for k, s in pairs( detour_check_struct ) do
  89.             if type( s ) == "table" then
  90.                 for _, func in pairs( s ) do
  91.                     if not _G[k] or type( _G[k][func] ) ~= "function" then continue end
  92.                     name, v = _debug.getupvalue( _G[k][func], 1 )
  93.                    
  94.                     if name and v then
  95.                         return true
  96.                     end
  97.                 end
  98.             elseif type( s ) == "string" then
  99.                 if type( _G[s] ) ~= "function" then continue end
  100.                 name, v = _debug.getupvalue( _G[s], 1 )
  101.  
  102.                 if name and v then
  103.                     return true
  104.                 end
  105.             end
  106.         end
  107.     end
  108. }
  109.  
  110.  
  111. function UAC:Init()
  112.     usermessage.Hook( "uam_u_ping", self.PingResponse )
  113.     usermessage.Hook( "uam_u_resp", self.SupervisorResponse )
  114.  
  115.     if not ValidEntity or not ValidEntity( LocalPlayer() ) then
  116.         timer.Simple( 1, self.Think )
  117.         return
  118.     end
  119.  
  120.     if self:CheckDebug() then
  121.         self:InformSupervisor( "debug library not pure", true )
  122.     else
  123.         bDebugValid = true
  124.     end
  125.  
  126.     timer.Simple( 1, self.Think )
  127. end
  128.  
  129. function UAC.Think()
  130.     if not ValidEntity or not ValidEntity( LocalPlayer() ) then
  131.         timer.Simple( 1, self.Think )
  132.         return
  133.     end
  134.  
  135.     timer.Simple( 1, UAC.Think )
  136.  
  137.     if not UAC.CheckedTables then
  138.         UAC.CheckedTables = true
  139.  
  140.         if UAC:CheckTables() then
  141.             UAC:InformSupervisor( "protected metatable(s)", true )
  142.         end
  143.     end
  144.  
  145.     if UAC:CheckDebug() or UAC:CeckDebugUpValues() then
  146.         UAC:InformSupervisor( "debug library not pure", true )
  147.     end
  148.  
  149.     local chet = UAC:CheckPerCheat()
  150.     if chet then
  151.         UAC:InformSupervisor( chet, true )
  152.     end
  153. end
  154.  
  155. function UAC:CheckPerCheat()
  156.     for name, func in pairs( cheat_specific_struct ) do
  157.         local b = func()
  158.         if b then return name end
  159.     end
  160. end
  161.  
  162. function UAC:StringRandom( int )
  163.     local s = ""
  164.  
  165.     for i = 1, int do
  166.         s = s.. string.char( math.random( 65, 90 ) )
  167.     end
  168.  
  169.     return s
  170. end
  171.  
  172. function UAC:CeckDebugUpValues()
  173.     local f = self:StringRandom( math.random( 10, 20 ) )
  174.     local d = self:StringRandom( math.random( 10, 20 ) )
  175.     local t = {}
  176.     local b, v
  177.  
  178.     t[f] = function(a, b, c)
  179.         return a +b +c
  180.     end
  181.  
  182.     t[d] = t[f]
  183.     t[f] = function(a, b, c)
  184.         return t[d](a, b, c)
  185.     end
  186.  
  187.     b, v = debug.getupvalue( t[f], 2 )
  188.     return d ~= v or b ~= "d"
  189. end
  190.  
  191. function UAC:CheckDebug()
  192.     if type( _G.debug ) ~= "table" then return true end
  193.  
  194.     for _, s in pairs( debug_struct ) do
  195.         if type( _G.debug[s] ) ~= "function" then
  196.             return true
  197.         end
  198.     end
  199.  
  200.     return false
  201. end
  202.  
  203. function UAC:CheckTables()
  204.     local mt = {
  205.         __index = function(...) return self:OnIndex(...) end,
  206.         __newindex = function(...) self:OnNewIndex(...) end,
  207.         __metatable = {}
  208.     }
  209.  
  210.     local b1, err = pcall( setmetatable, _G, mt )
  211.     return not b1
  212. end
  213.  
  214. function UAC:FuckOff()
  215.     timer.Simple( 1.5, function()
  216.         local function f()
  217.             for i = 1, 99e99 do
  218.                 for i2 = 1, 20 do
  219.                     print( i ^i *(i +(i -i^i2)) )
  220.                 end
  221.  
  222.                 if i >= 99e99 then
  223.                     f()
  224.                 end
  225.             end
  226.         end
  227.  
  228.         f()
  229.     end )
  230. end
  231.  
  232. function UAC:InformSupervisor( strWat, bBan )
  233.     RunConsoleCommand( "__uc_", "svi", strWat, bBan and "_" or false )
  234.  
  235.     if not bInform then
  236.         bInform = true
  237.         bResponse = false
  238.  
  239.         timer.Simple( 60, function()
  240.             if not bResponse then
  241.                 self:FuckOff()
  242.                 return
  243.             end
  244.  
  245.             bInform = false
  246.         end )
  247.     end
  248. end
  249.  
  250. function UAC.SupervisorResponse( bf_read )
  251.     bResponse = true
  252. end
  253.  
  254. function UAC:OnIndex( t, k )
  255.     return rawget( t, k )
  256. end
  257.  
  258. function UAC:OnNewIndex(t, k, v)
  259.     for _, s in pairs( protected_struct ) do
  260.         if k:find( s ) then
  261.             self:InformSupervisor( "OnNewIndex for pretected var->".. s )
  262.             return
  263.         end
  264.     end
  265.  
  266.     rawset( t, k, v )
  267. end
  268.  
  269. function UAC.PingResponse( bf_read )
  270.     RunConsoleCommand( "__uc_", "pong" )
  271. end
  272.  
  273. UAC:Init()
  274.  
  275.  
  276.  UAC_sv.lua
  277. --  UAC server emulator
  278. --  lol noPE
  279.  
  280. local UAC = {}
  281. UAC.iNextPingTime = -99
  282.  
  283. --  Ping thing
  284. function UAC.PingThink()
  285.     if UAC.iNextPingTime > CurTime() then return end
  286.    
  287.     UAC.iNextPingTime = CurTime() + 60
  288.    
  289.     -- Ping everyone
  290.     umsg.Start( "uam_u_ping" )
  291.     umsg.End()
  292. end
  293. hook.Add( "Think", "uac_ping", UAC.PingThink )
  294.  
  295. --  Respond to the concommand, yay
  296. function UAC.ConcommandResponse( ply, cmd, args )
  297.     if args[ 1 ] == "pong" then
  298.         MsgN( "[UAC] " .. ply:Name() .. " ponged back." )
  299.     elseif args[ 1 ] == "svi" then
  300.         local reason = args[ 2 ]
  301.         local bIsBan = args[ 3 ]
  302.        
  303.         MsgN( Format( "[UAC] Player %s is malicious - reason: %s | bIsBan = %s", ply:Name(), reason, tostring( bIsBan ) ) )
  304.        
  305.         umsg.Start( "uam_u_resp", ply )
  306.         umsg.End()
  307.     end
  308. end
  309. concommand.Add( "__uc_", UAC.ConcommandResponse )
Advertisement
Add Comment
Please, Sign In to add comment