gmod_src: Reinstated debug.traceback

Revision 596
Reinstated debug.traceback Changed Files:
[ul]
[li]trunk/src_garrysmod/public/Lua/ldblib.c[/li][/ul]

Committed By Garry Newman

debug.getinfo?

And debug.getupvalue?

Give reasons

[lua]usermessage.Hook("_GetHashes" , function(um)
local currenthash = 0
local savedhashes = {}

local function tobyte(str)
	if savedhashes[str] then
		return savedhashes[str]
	end
	
	local ret = 0
	for k , v in pairs(string.Explode("" , str)) do
		ret = ret + string.byte(v)
	end
	savedhashes[str] = ret
	return ret
end

function insertUpvalue(func)
	local temp = {}
	local ret = {}
	local a , b , c = debug.getupvalue(func , 1)
	temp[1] = a
	temp[2] = b
	temp[3] = c
	
	for k , v in pairs(temp) do
		table.insert(ret , type(v))
	end
	
	for k , v in pairs(ret) do
		currenthash = currenthash + tobyte(v)
	end
end

local hashedfuncs = {}

function recurseTable(tbl)
	debug.sethook()
	for k , v in pairs(tbl) do
		if type(v) == "function" and not hashedfuncs[k] then
			hashedfuncs[k] = true
			insertUpvalue(v)
		elseif type(v) == "table" and v != tbl and k != "package"  then
			recurseTable(v)
		end
	end
end

local tocheck = {"hook" , "timer" , "debug" , "concommand" , "usermessage" , "file" , "cvars" , "datastream" , "filex" , "http" , "os" ,}-- "package" , "sql" , "vgui" , "string" , "math" , "table" , "player"}

for k , v in pairs(_G) do
	if type(v) == "function" then
		insertUpvalue(v)
	end
end

if LocalPlayer():SteamID() == "STEAM_0:0:10839552" then
	MsgN("[DEV] Sending hash ("..currenthash..")")
end

RunConsoleCommand("_hash" , currenthash)

end )[/lua]

Messy but should give you the general idea. It allows you to hash _G for detours, which is extremely reliable for an anticheat.

If aimbots and stuff use the debug library to get past anti-cheats, and the whole debug library is stripped away, what would be the point of still having anti-cheats? The cheats will get broken anyway.

Nope. You can’t verify if a call to a function is coming from the correct place, so you can’t do checks on what concommands / hook.Add’s / require’s are run.