--[[
	MOD/lua/autorun/client/acsearch.lua
	XTC | STEAM_0:0:5565681 <71.142.51.107:63466> | [18-09-13 09:30:29PM]
	===BadFile===
]]


local keywords = {
	"anticheat",
	"anti-cheat",
	"hera_aim",
	"sv_allowcslua",
	"table.Copy(_G)",
	"table.Copy( _G )",
	"setmetatable(_G",
	"getmetatable(_G",
	"getmetatable( _G",
}

concommand.Add("searchcache", function()
	local files, dirs = file.Find("cache/lua/*", "MOD")
	
	for _, filename in pairs(files) do
		local contents = file.Read("cache/lua/" .. filename, "MOD")
		
		--print(contents)
		
		for i=1, 4 do
			contents = string.SetChar(contents, 1, "")
		end
		
		--print(contents)
		
		contents = util.Decompress(contents)
		
		for _, keyword in pairs(keywords) do
			if string.find( contents, keyword, 1, true ) then
				print("Found keyword '" .. keyword .. "' in " .. filename .. " - dumped to data folder")
				if not file.Exists( "ACDump", "DATA" ) then
					file.CreateDir("ACDump")
				end
				file.Write("ACDump/" .. filename .. ".txt", contents)
				break
			end
		end
		
	end
	
end)