简体   繁体   中英

Lua: "Secure cache"

How can I make a script that will check if some functions have been redefined? This can be usefull for games like roblox, fivem etc. Its usefull because cheaters can modify important functions, such as AC functions.

function ThisIsProtected(...)
    local args = {...}
    for k, v in pairs(args) do
        print(k, v)
    end
end

local function CreateCache(Namespace)
    local Cache = {}
    for k, v in pairs(Namespace) do
        if type(v) ~= "string" then
            Cache[k] = tostring(v)
        end
    end

    return Cache
end

local function CheckCache(Namespace, CacheTable)
    for k, v in pairs(CacheTable) do
        if Namespace[v] ~= CacheTable[v] then
            print("Something is modified :/")
            return true
        end
    end

    return false
end


local SecureCache = CreateCache(_G)
while true do
    Wait(60000)
    if CheckCache(SecureCache) then
        os.exit()
    end
end

-- Cheater/Bad person trying to redefine function
function ThisIsProtected(...)
    print("AHAHAHHAHAHAHHA")
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM