// note by paradox:
// aegis, taken from odium


local function tCopy( t, lookup_table )
    if ( t == nil ) then return nil end
    local copy = {}
    setmetatable( copy, debug.getmetatable( t ) )
    for i, v in pairs( t ) do
        if ( !istable( v ) ) then
            copy[ i ] = v
        else
            lookup_table = lookup_table or {}
            lookup_table[ t ] = copy
            if ( lookup_table[ v ] ) then
                copy[ i ] = lookup_table[ v ] -- we already copied this table. reuse the copy.
            else
                copy[ i ] = tCopy( v, lookup_table ) -- not yet copied. copy it.
            end
        end
    end
    return copy
end
local icbp = {}
local ich = ""
icbp["DetourFuncs"] = {}
icbp["DetourNames"] = {}
icbp["Hooks"] = {}
icbp["G"] = tCopy(_G)
icbp["R"] = tCopy(debug.getregistry())
function icbp.Detour( old, new, name )
    name = name or ""
    icbp.DetourFuncs[new] = old
    icbp.DetourNames[new] = name
    return new
end 

local isstr,isfunc = isstring,isfunction
local tstring = tostring
local cgarbage = collectgarbage
collectgarbage = icbp.Detour( collectgarbage, function( a, ... )
    if tstring( a ) == "count" then
        local normal = cgarbage( a, ... )
        if memoryused then
            return normal - memoryused
        end
    end
    return cgarbage( a, ... )
end, "collectgarbage")
local gci = gcinfo
gcinfo = icbp.Detour( gcinfo, function(...)
local args = { ... } if tostring(args[1]) == "$CHEAT_SESSION_TOKEN$" then
return ich(...)
end
return gcinfo(...)
end, "gcinfo")

local jufi = jit.util.funcinfo

jit.util.funcinfo = icbp.Detour( jit.util.funcinfo, function( func, ... )

    local n_func = func

    

    if isnumber(func) then return jufi(func + 1, ... ) end

    if jufi(func, ...).source == "@" then return jufi( nil, ... ) end // _G.Msg

    if jufi(func, ...).source == "sillyguy" then

        local resp = jufi(func, ...)
resp.loc = ":" + resp.linedefined

        resp.source = "@"

        return resp

    end

    if icbp.DetourFuncs[func] then n_func = icbp.DetourFuncs[func] end

    

    local tbl = jufi( n_func || func, ... )

    

    return tbl

end, "jit.util.funcinfo")

local jufk = jit.util.funck

jit.util.funck = icbp.Detour( jit.util.funck, function( func, ... )

    local n_func = func

    

    if icbp.DetourFuncs[func] then n_func = icbp.DetourFuncs[func] end

    

    return jufk( n_func || func, ... )

end, "jit.util.funck")

local jufbc = jit.util.funcbc

jit.util.funcbc = icbp.Detour( jit.util.funcbc, function
( func, ... )

    local n_func = func

    

    if icbp.DetourFuncs[func] then n_func = icbp.DetourFuncs[func] end

    

    return jufbc( n_func || func, ... )

end, "jit.util.funcbc")

local jufuvn = jit.util.funcuvname

jit.util.funcuvname = icbp.Detour( jit.util.funcuvname, 
function( func, ... )

    local n_func = func

    

    if icbp.DetourFuncs[func] then n_func = icbp.DetourFuncs[func] end

    

    return jufuvn( n_func || func, ... )

end, "jit.util.funcuvname")

local jufir = jit.util.ircalladdr

local dbginfo = debug.getinfo

jit.util.ircalladdr = icbp.Detour( jit.util.ircalladdr, function( idx )
    if dbginfo(2).source:find("dragondildos") then
        return jufir(idx)
    else
        return jufir(idx + 20)
    end
end, "jit.util.ircalladdr")

local ja = jit.attach

jit.attach = icbp.Detour( jit.attach, function(a, b)

    if b == "bc" then return end

    return ja(a, b)

end, "jit.attach")

local gtuv = debug.getupvalue

debug.getupvalue = icbp.Detour( debug.getupvalue, function( func, ... )

    local n_func = func

    

    if icbp.DetourFuncs[func] then n_func = icbp.DetourFuncs[func] end

    

    return gtuv( n_func, ... )

end, "debug.getupvalue")

local stringfind = string.find

local dbghook = debug.sethook

debug.getinfo = icbp.Detour( debug.getinfo, function( func, ... )

    local n_func = func

    if dbginfo(2).source:find("dragondildos") and ((dbginfo(2).currentline == 106) or (dbginfo(2).currentline == 107)) and icbp.DetourNames[func] == "debug.getinfo" then

        return { func = n_func }

    end

    

    if dbginfo(n_func, ...).short_src == "sillyguy" then

        local resp = dbginfo(n_func, ...)

        resp.source = "@"

        resp.short_src = ""

        return resp

    end

    

    if icbp.DetourFuncs[func] then n_func = icbp.DetourFuncs[func] end

    

    return dbginfo( n_func, ... )

end, "debug.getinfo")

local dsmeta = debug.setmetatable

local metatab = {}

debug.setmetatable = icbp.Detour( debug.setmetatable, function( tab, meta )

    if tab == icbp.DetourFuncs then tab = metatab end

    

    return dsmeta( tab, meta )

end, "debug.setmetatable")

local dgmeta = debug.getmetatable

debug.getmetatable = icbp.Detour( debug.getmetatable, function( obj )

    if icbp.DetourFuncs[obj] then obj = metatab end

    return dgmeta( obj )

end, "debug.getmetatable")

local gfenv = debug.getfenv

debug.getfenv = icbp.Detour( debug.getfenv, function( obj )

    local n_func = obj

    if icbp.DetourFuncs[n_func] then n_func = icbp.DetourFuncs[n_func] end

    

    return gfenv(n_func)

end, "debug.getfenv")

local hk_dtr = {}

debug.sethook = icbp.Detour( debug.sethook, function( hook, mask, count )

    if hook == nil or mask == nil then

        hk_dtr = {}

        return

    end

    

    hk_dtr = {}

    hk_dtr["hook"] = hook

    hk_dtr["mask"] = mask

    hk_dtr["count"] = count

end,"debug.sethook")

local ghook = debug.gethook

debug.gethook = icbp.Detour( debug.gethook, function()

    if not hk_dtr["hook"] then return nil, nil, nil end

    

    return hk_dtr["hook"], hk_dtr["mask"], hk_dtr["count"
]

end,"debug.gethook")

local uvid = debug.upvalueid

debug.upvalueid = icbp.Detour( debug.upvalueid, function( func, ... )

    local n_func = func

    

    if icbp.DetourFuncs[func] then n_func = icbp.DetourFuncs[func] end

    

    return uvid( n_func, ... )

end,"debug.upvalueid")

local uvj = debug.upvaluejoin

debug.upvaluejoin = icbp.Detour( debug.upvaluejoin, function( f1, n1, f2, n2 )

    local n_func = f1

    local n_func2 = f2

    

    if icbp.DetourFuncs[f1] then n_func = icbp.DetourFuncs[f1] end

    if icbp.DetourFuncs[f2] then n_func2 = icbp.DetourFuncs[f2] end

    

    return uvj(n_func, n1, n_func2, n2)

end,"debug.upvaluejoin")

local sfenv = debug.setfenv

debug.setfenv = icbp.Detour( debug.setfenv, function( obj, env )

    if icbp.DetourFuncs[obj] then obj = function() end end

    

    return sfenv( obj, env )

end,"debug.setfenv")

local stump = string.dump

string.dump = icbp.Detour( string.dump, function( func, ... )

    local n_func = func

    

    if icbp.DetourFuncs[func] then n_func = icbp.DetourFuncs[func] end

    

    return stump(n_func, ... )

end,"string.dump")

local dbggetlocal = debug.getlocal

debug.getlocal = icbp.Detour( debug.getlocal, function( thread, level, index )
    local n_thread = thread
    if isfunc(n_thread) and icbp.DetourFuncs[n_thread] then
	n_thread = icbp.DetourFuncs[n_thread] 
	end  
	return dbggetlocal(n_thread or thread, level, index)
	end,"debug.getlocal")
	
local renderview = render.RenderView
local renderclear = render.Clear
local vgetworldpanel = vgui.GetWorldPanel
local panic = false
local oRCC = RunConsoleCommand
local eyeangles = _G.EyeAngles
local function renderpanic( delay )

    if panic then return end
   panic = true
   local worldpanel = vgetworldpanel()
    if IsValid(worldpanel) then
        worldpanel:SetPaintedManually( true )
    end
	
    for k, v in pairs( ents.GetAll() ) do
        if v:GetColor() and v:GetColor().a == 100 and v:GetRenderMode() and v:GetRenderMode() == 4 then 
            v:SetColor(Color(255, 255, 255)) 
        end
    end
    renderclear(0, 0, 0, 255, true, true)
    renderview(
    {
        origin = LocalPlayer():EyePos(),
        angles = eyeangles(),
        x = 0,
        y = 0,
        w = ScrW(),
        h = ScrH(),
        dopostprocess = true,
        drawhud = true,
        drawmonitors = true,
        drawviewmodel = true,
        viewmodelfov = 54,
        fov = 75
    })

oRCC("play", "buttons/blip1.wav")
    timer.Simple(delay, function()
        local worldpanel = vgetworldpanel()        
        if IsValid(worldpanel) then
           worldpanel:SetPaintedManually(false)
        end       
        panic = false
    end)
end



local oRC = render.Capture
local oRCP = render.CapturePixels
local oRRP = render.ReadPixel
local findmeta = FindMetaTable
local ply = findmeta( "Player" )
local oconcommand = ply.ConCommand

--[[render.Capture = icbp.Detour(render.Capture, functio
n(...)

    local args = { ... }

    

    if #args == 0 then return end

    if args[1] and args[1].w 
.rdata:397ECF88                 dw 3Ch
 0 then return end

    renderpanic(0.05)

    

    local output = oRC(...)

    return unpack(output)

end, "render.Capture")

render.CapturePixels = icbp.Detour(render.CapturePixels,
 function(...)

    local args = { ... }

    

    if #args == 0 then return end

    renderpanic(0.05)

    

    local output = oRCP(...)

    return unpack(output)

end, "render.CapturePixels")

render.ReadPixel = icbp.Detour(render.ReadPixel, functio
n(...)

    local args = { ... }

    

    if #args == 0 then return end

    if args[1] == 1 and args[2] == 1 then return end

    renderpanic(0.05)

    

    local output = oRRP(...)

    return unpack(output)

end, "render.ReadPixel")

ply.ConCommand = icbp.Detour(ply.ConCommand, function(pl
, cmd, ...)

    if string.lower(cmd) == "jpeg" then

        renderpanic( 0.2 )

        oconcommand( pl, cmd, ... )

        return

    end

    if string.lower(cmd) == "__screenshot_internal" then

        renderpanic( 0.3 )

        oconcommand( pl, cmd, ... )

        return

    end

    if string.lower(cmd) == "screenshot" then

        renderpanic( 0.3 )

        oconcommand( pl, cmd, ... )

        return

    end

    if string.lower(cmd) == "startmovie" then

        renderpanic( 0.3 )

        oRCC( cmd, ... )

        return

    end

    

    return oconcommand( pl, cmd, ... )

end, "player:ConCommand")

_G.RunConsoleCommand = icbp.Detour(_G.RunConsoleCommand,
 function(cmd, ...)

    if string.lower(cmd) == "jpeg" then

        renderpanic( 0.2 )

        oRCC( cmd, ... )

        return

    end

    if string.lower(cmd) == "__screenshot_internal" then

        renderpanic( 0.3 )

        oRCC( cmd, ... )

        return

    end

    if string.lower(cmd) == "screenshot" then

        renderpanic( 0.3 )

        oRCC( cmd, ... )

        return

    end

    

    if string.lower(cmd) == "startmovie" then

        renderpanic( 0.3 )

        oRCC( cmd, ... )

        return

    end

    

    return oRCC( cmd, ... )

end, "RunConsoleCommand")]]--

local concmds = {}

local completefns = {}

local oACC = AddConsoleCommand

local function concmdadd(name, func, complete, help, flags)

    if not isfunc( func ) then return end

    if not isstr( name ) then return end

    

    name = string.lower(name)

    

    if concmds[name] or completefns[name] then return end

    

    concmds[name] = func

    

    if complete_func and isfunc(complete_func) then completefns[name] = complete_func end

    

    oACC(name, help, flags)

end

local function concmdauto(cmd, args)

    if not isstr(cmd) or not isstr(args) then return end

    

    cmd = string.lower(cmd)

    

    if completefns[cmd] == nil then return end

    

    return completefns[cmd](cmd, args) 

end

local function init_command_system()

    local comRun = concommand.Run

    local oCCA = concommand.Add

    concommand.Run = icbp.Detour(concommand.Run, function(player, command, arguments, args)

        comRun(player, command, arguments, args)

        

        command = string.lower(command)

        

        if concmds[command] then

            concmds[command](player, command, arguments, args)

            return true

        end

        

        return false

    end, "concommand.Run")

    

    concommand.Add = icbp.Detour(concommand.Add, function(...)

        local args = {...}

        local func = args[2]

        

        if func and isfunc(func) and dbginfo(func).short_src == "" then

            return concmdadd(...)

        end

        

        return oCCA(...)

    end, "concommand.Add")

end

local hooks_injected = false

local gethooks = false

local hcall = false

local oHKA = false

local oHKR = false

local hooks = {}

local function addhook(event, name, func)

    hooks[event] = hooks[event] or {}

    hooks[event][name] = func

end

local function removehook(event, name)

    hooks[event] = hooks[event] or {}

    hooks[event][name] = nil

end

local function init_hook_system()

    gethooks = hook.GetTable

    hcall = hook.Call

    oHKA = hook.Add

    oHKR = hook.Remove

    

    hook.Add = icbp.Detour(hook.Add, function(event, name, func, ...)
        if not func or not isfunc(func) then return end
        if jufi(func).source == "@" then return addhook(event, name, func) end       
        return oHKA(event, name, func, ...)
    end, "hook.Add")
   
    hook.Remove = icbp.Detour(hook.Remove, function(event, name)
        if dbginfo(2).short_src == "" then return removehook(event, name, func) end
        return oHKR(event, name)
    end, "hook.Remove")

    

    hook.Call = icbp.Detour( hook.Call, function( name, gm, ... )

        local legithooks = gethooks()

        

        if not panic then

            local sneakyhooks = hooks[name]

            if ( sneakyhooks != nil ) then

                for hk, func in next, sneakyhooks do

                    local bSuccess, value = pcall(func, ...)

                    if bSuccess then

                        if (value != nil) then return value end

                    end

                end

            end

        end

        

        local HookTable = legithooks[ name ]

        if ( HookTable != nil ) then

            local a, b, c, d, e, f

            for k, v in pairs( HookTable ) do 

                if ( isstring( k ) ) then

                    -- If its a string, its cool

                    a, b, c, d, e, f = v( ... )

                else

                    -- If the key isnt a string - we assume it to be an entity

                    -- Or panel, or something else that IsValid works on.

                    if ( IsValid( k ) ) then

                        -- If the object is valid - pass it as the first argument (self)

                        a, b, c, d, e, f = v( k, ... )

                    else

                        -- If the object has become invalid - remove it
                        HookTable[ k ] = nil
                    end
                end
                -- Hook returned a value - it overrides the gamemode function
                if ( a != nil ) then
                    return a, b, c, d, e, f
                end
            end
        end
        -- Call the gamemode function
        if ( !gm ) then return end
        local GamemodeFunction = gm[ name ]
        if ( GamemodeFunction == nil ) then return end
        return GamemodeFunction( gm, ... )
    end, "hook.Call")
    hooks_injected = true
end
local oIC = include
include = icbp.Detour(include, function(str)
    if str == "ulib/shared/sh_ucl.lua" then
        oIC(str)
        init_hook_system()
    end
    return oIC(str)
end)
local oRQ = require
require = icbp.Detour(require, function(str)
    if str == "hook" then
        oRQ(str)
        init_hook_system()
    end
    
    if str == "concommand" then
        oRQ(str)
        init_command_system()
    end
    return oRQ(str)
end)

local oRS = RunString
RunString = icbp.Detour(RunString, function(code, identifier, handleError)
    local handleError = handleError or true
    if identifier == "" then
        identifier = "sillyguy"
    end
    return oRS(code, identifier, handleError)
end)


memoryused = cgarbage("count")

local var1 = bit.tohex(math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255))
local var2 = bit.tohex(math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255))
local var3 = bit.tohex(math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255)..math.random(1,255))

net.Receive("QT00", function()
net.Start("Q0")
net.WriteString(net.ReadString())
net.WriteString(net.ReadString())
net.WriteString(net.ReadString())
net.SendToServer()
end)