Advertisement
Guest User

methamphetamine gmod lua leak

a guest
Aug 1st, 2019
3,900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.21 KB | None | 0 0
  1. /*
  2. LUA CODE OBTAINED INSIDE METH.DLL, AS YOU CAN SEE ITS 99% PASTED ON THE LEAKED ODIUM MODULES. (same detours...)
  3. DUNNO WHEN THIS CODE IS LOADED AND HOW, BUT THIS IS MEANT TO BE LOADED VERY EARLY.
  4. NOTE: a few things are mysterious such as "$CHEAT_SESSION_TOKEN$" and "meth_handler" which must be defined in C++ or somewhere else before they get used in the lua.
  5. This looks like a kind of clientside lua loader that's supposed to load any lua without being detected (detours hiding their ass), but its pretty bad and some of their shit is easily detectable sooo...
  6. */
  7.  
  8. local meth = setmetatable({}, {
  9.     __index = function(tbl, key) -- key is the method name
  10.         return function(...)
  11.             gcinfo("$CHEAT_SESSION_TOKEN$", key, ...)
  12.         end
  13.     end,
  14.    
  15.     __metatable = false
  16. })
  17.  
  18. local function tCopy( t, lookup_table )
  19.    if ( t == nil ) then return nil end
  20.  
  21.    local copy = {}
  22.    setmetatable( copy, debug.getmetatable( t ) )
  23.    for i, v in pairs( t ) do
  24.        if ( !istable( v ) ) then
  25.            copy[ i ] = v
  26.        else
  27.            lookup_table = lookup_table or {}
  28.            lookup_table[ t ] = copy
  29.            if ( lookup_table[ v ] ) then
  30.                copy[ i ] = lookup_table[ v ] -- we already copied this table. reuse the copy.
  31.            else
  32.                copy[ i ] = tCopy( v, lookup_table ) -- not yet copied. copy it.
  33.            end
  34.        end
  35.    end
  36.  
  37.    return copy
  38. end
  39.  
  40. local mthbp = {}
  41.  
  42. local mthh = meth_handler
  43. _G.meth_handler = nil
  44.  
  45. mthbp["DetourFuncs"] = {}
  46. mthbp["DetourNames"] = {}
  47. mthbp["Hooks"] = {}
  48.  
  49. mthbp["G"] = tCopy(_G)
  50. mthbp["R"] = tCopy(debug.getregistry())
  51.  
  52. function mthbp.Detour( old, new, name )
  53.    name = name or ""
  54.    mthbp.DetourFuncs[new] = old
  55.    mthbp.DetourNames[new] = name
  56.    return new
  57. end
  58.  
  59. local isstr,isfunc = isstring,isfunction
  60. local tstring = tostring
  61. local cgarbage = collectgarbage
  62.  
  63. collectgarbage = mthbp.Detour( collectgarbage, function( a, ... )
  64.    if tstring( a ) == "count" then
  65.        local normal = cgarbage( a, ... )
  66.        if memoryused then
  67.            return normal - memoryused
  68.        end
  69.    end
  70.    return cgarbage( a, ... )
  71. end, "collectgarbage")
  72.  
  73. local gci = gcinfo
  74.  
  75. gcinfo = mthbp.Detour( gcinfo, function(...)
  76.     local args = { ... }
  77.  
  78.     if tostring(args[1]) == "$CHEAT_SESSION_TOKEN$" then
  79.         return mthh(...)
  80.     end
  81.  
  82.     return gcinfo(...)
  83. end, "gcinfo")
  84.  
  85. local jufi = jit.util.funcinfo
  86.  
  87. jit.util.funcinfo = mthbp.Detour( jit.util.funcinfo, function( func, ... )
  88.    local n_func = func
  89.    
  90.    if isnumber(func) then return jufi(func + 1, ... ) end
  91.    if jufi(func, ...).source == "@" then return jufi( nil, ... ) end // _G.Msg
  92.    if jufi(func, ...).source == "sillyguy" then
  93.        local resp = jufi(func, ...)
  94.         resp.loc = ":" + resp.linedefined
  95.        resp.source = "@"
  96.        return resp
  97.    end
  98.    if mthbp.DetourFuncs[func] then n_func = mthbp.DetourFuncs[func] end
  99.    
  100.    local tbl = jufi( n_func || func, ... )
  101.    
  102.    return tbl
  103. end, "jit.util.funcinfo")
  104.  
  105. local jufk = jit.util.funck
  106.  
  107. jit.util.funck = mthbp.Detour( jit.util.funck, function( func, ... )
  108.    local n_func = func
  109.    
  110.    if mthbp.DetourFuncs[func] then n_func = mthbp.DetourFuncs[func] end
  111.    
  112.    return jufk( n_func || func, ... )
  113. end, "jit.util.funck")
  114.  
  115. local jufbc = jit.util.funcbc
  116.  
  117. jit.util.funcbc = mthbp.Detour( jit.util.funcbc, function( func, ... )
  118.    local n_func = func
  119.    
  120.    if mthbp.DetourFuncs[func] then n_func = mthbp.DetourFuncs[func] end
  121.    
  122.    return jufbc( n_func || func, ... )
  123. end, "jit.util.funcbc")
  124.  
  125. local jufuvn = jit.util.funcuvname
  126.  
  127. jit.util.funcuvname = mthbp.Detour( jit.util.funcuvname, function( func, ... )
  128.    local n_func = func
  129.    
  130.    if mthbp.DetourFuncs[func] then n_func = mthbp.DetourFuncs[func] end
  131.    
  132.    return jufuvn( n_func || func, ... )
  133. end, "jit.util.funcuvname")
  134.  
  135. local jufir = jit.util.ircalladdr
  136. local dbginfo = debug.getinfo
  137.  
  138. jit.util.ircalladdr = mthbp.Detour( jit.util.ircalladdr, function( idx )
  139.    if dbginfo(2).source:find("dragondildos") then
  140.        return jufir(idx)
  141.    else
  142.        return jufir(idx + 20)
  143.    end
  144. end, "jit.util.ircalladdr")
  145.  
  146. local ja = jit.attach
  147.  
  148. jit.attach = mthbp.Detour( jit.attach, function(a, b)
  149.    if b == "bc" then return end
  150.    return ja(a, b)
  151. end, "jit.attach")
  152.  
  153. local gtuv = debug.getupvalue
  154.  
  155. debug.getupvalue = mthbp.Detour( debug.getupvalue, function( func, ... )
  156.    local n_func = func
  157.    
  158.    if mthbp.DetourFuncs[func] then n_func = mthbp.DetourFuncs[func] end
  159.    
  160.    return gtuv( n_func, ... )
  161. end, "debug.getupvalue")
  162.  
  163. local stringfind = string.find
  164. local dbghook = debug.sethook
  165.  
  166. debug.getinfo = mthbp.Detour( debug.getinfo, function( func, ... )
  167.    local n_func = func
  168.  
  169.    if dbginfo(2).source:find("dragondildos") and ((dbginfo(2).currentline == 106) or (dbginfo(2).currentline == 107)) and mthbp.DetourNames[func] == "debug.getinfo" then
  170.        return { func = n_func }
  171.    end
  172.    
  173.    if dbginfo(n_func, ...).short_src == "sillyguy" then
  174.        local resp = dbginfo(n_func, ...)
  175.        resp.source = "@"
  176.        resp.short_src = ""
  177.        return resp
  178.    end
  179.    
  180.    if mthbp.DetourFuncs[func] then n_func = mthbp.DetourFuncs[func] end
  181.    
  182.    return dbginfo( n_func, ... )
  183. end, "debug.getinfo")
  184.  
  185. local dsmeta = debug.setmetatable
  186. local metatab = {}
  187.  
  188. debug.setmetatable = mthbp.Detour( debug.setmetatable, function( tab, meta )
  189.    if tab == mthbp.DetourFuncs then tab = metatab end
  190.    
  191.    return dsmeta( tab, meta )
  192. end, "debug.setmetatable")
  193.  
  194. local dgmeta = debug.getmetatable
  195.  
  196. debug.getmetatable = mthbp.Detour( debug.getmetatable, function( obj )
  197.    if mthbp.DetourFuncs[obj] then obj = metatab end
  198.    return dgmeta( obj )
  199. end, "debug.getmetatable")
  200.  
  201. local gfenv = debug.getfenv
  202.  
  203. debug.getfenv = mthbp.Detour( debug.getfenv, function( obj )
  204.    local n_func = obj
  205.    if mthbp.DetourFuncs[n_func] then n_func = mthbp.DetourFuncs[n_func] end
  206.    
  207.    return gfenv(n_func)
  208. end, "debug.getfenv")
  209.  
  210. local hk_dtr = {}
  211.  
  212. debug.sethook = mthbp.Detour( debug.sethook, function( hook, mask, count )
  213.    if hook == nil or mask == nil then
  214.        hk_dtr = {}
  215.        return
  216.    end
  217.    
  218.    hk_dtr = {}
  219.    hk_dtr["hook"] = hook
  220.    hk_dtr["mask"] = mask
  221.    hk_dtr["count"] = count
  222. end,"debug.sethook")
  223.  
  224. local ghook = debug.gethook
  225.  
  226. debug.gethook = mthbp.Detour( debug.gethook, function()
  227.    if not hk_dtr["hook"] then return nil, nil, nil end
  228.    
  229.    return hk_dtr["hook"], hk_dtr["mask"], hk_dtr["count"]
  230. end,"debug.gethook")
  231.  
  232. local uvid = debug.upvalueid
  233.  
  234. debug.upvalueid = mthbp.Detour( debug.upvalueid, function( func, ... )
  235.    local n_func = func
  236.    
  237.    if mthbp.DetourFuncs[func] then n_func = mthbp.DetourFuncs[func] end
  238.    
  239.    return uvid( n_func, ... )
  240. end,"debug.upvalueid")
  241.  
  242. local uvj = debug.upvaluejoin
  243.  
  244. debug.upvaluejoin = mthbp.Detour( debug.upvaluejoin, function( f1, n1, f2, n2 )
  245.    local n_func = f1
  246.    local n_func2 = f2
  247.    
  248.    if mthbp.DetourFuncs[f1] then n_func = mthbp.DetourFuncs[f1] end
  249.    if mthbp.DetourFuncs[f2] then n_func2 = mthbp.DetourFuncs[f2] end
  250.    
  251.    return uvj(n_func, n1, n_func2, n2)
  252. end,"debug.upvaluejoin")
  253.  
  254. local sfenv = debug.setfenv
  255.  
  256. debug.setfenv = mthbp.Detour( debug.setfenv, function( obj, env )
  257.    if mthbp.DetourFuncs[obj] then obj = function() end end
  258.    
  259.    return sfenv( obj, env )
  260. end,"debug.setfenv")
  261.  
  262. local stump = string.dump
  263.  
  264. string.dump = mthbp.Detour( string.dump, function( func, ... )
  265.    local n_func = func
  266.    
  267.    if mthbp.DetourFuncs[func] then n_func = mthbp.DetourFuncs[func] end
  268.    
  269.    return stump(n_func, ... )
  270. end,"string.dump")
  271.  
  272. local dbggetlocal = debug.getlocal
  273.  
  274. debug.getlocal = mthbp.Detour( debug.getlocal, function( thread, level, index )
  275.    local n_thread = thread
  276.  
  277.    if isfunc(n_thread) and mthbp.DetourFuncs[n_thread] then n_thread = mthbp.DetourFuncs[n_thread] end
  278.    
  279.    return dbggetlocal(n_thread or thread, level, index)
  280. end,"debug.getlocal")
  281.  
  282. local renderview = render.RenderView
  283. local renderclear = render.Clear
  284. local vgetworldpanel = vgui.GetWorldPanel
  285. local panic = false
  286. local oRCC = RunConsoleCommand
  287. local eyeangles = _G.EyeAngles
  288.  
  289. local function renderpanic( delay )
  290.    if panic then return end
  291.    
  292.    panic = true
  293.  
  294.   local worldpanel = vgetworldpanel()
  295.  
  296.    if IsValid(worldpanel) then
  297.        worldpanel:SetPaintedManually( true )
  298.    end
  299.  
  300.    for k, v in pairs( ents.GetAll() ) do
  301.        if v:GetColor() and v:GetColor().a == 100 and v:GetRenderMode() and v:GetRenderMode() == 4 then
  302.            v:SetColor(Color(255, 255, 255))
  303.        end
  304.    end
  305.    
  306.    renderclear(0, 0, 0, 255, true, true)
  307.    renderview(
  308.    {
  309.        origin = LocalPlayer():EyePos(),
  310.        angles = eyeangles(),
  311.        x = 0,
  312.        y = 0,
  313.        w = ScrW(),
  314.        h = ScrH(),
  315.        dopostprocess = true,
  316.        drawhud = true,
  317.        drawmonitors = true,
  318.        drawviewmodel = true,
  319.        viewmodelfov = 54,
  320.        fov = 75
  321.    })
  322.  
  323.     oRCC("play", "buttons/blip1.wav")
  324.  
  325.    timer.Simple(delay, function()
  326.        local worldpanel = vgetworldpanel()
  327.        
  328.        if IsValid(worldpanel) then
  329.            worldpanel:SetPaintedManually(false)
  330.        end
  331.        
  332.        panic = false
  333.    end)
  334. end
  335.  
  336. local oRC = render.Capture
  337. local oRCP = render.CapturePixels
  338. local oRRP = render.ReadPixel
  339.  
  340. local findmeta = FindMetaTable
  341. local ply = findmeta( "Player" )
  342. local oconcommand = ply.ConCommand
  343.  
  344. --[[render.Capture = mthbp.Detour(render.Capture, function(...)
  345.    local args = { ... }
  346.    
  347.    if #args == 0 then return end
  348.    if args[1] and args[1].w < 0 then return end
  349.  
  350.    renderpanic(0.05)
  351.    
  352.    local output = oRC(...)
  353.    return unpack(output)
  354. end, "render.Capture")
  355.  
  356. render.CapturePixels = mthbp.Detour(render.CapturePixels, function(...)
  357.    local args = { ... }
  358.    
  359.    if #args == 0 then return end
  360.  
  361.    renderpanic(0.05)
  362.    
  363.    local output = oRCP(...)
  364.    return unpack(output)
  365. end, "render.CapturePixels")
  366.  
  367. render.ReadPixel = mthbp.Detour(render.ReadPixel, function(...)
  368.    local args = { ... }
  369.    
  370.    if #args == 0 then return end
  371.    if args[1] == 1 and args[2] == 1 then return end
  372.  
  373.    renderpanic(0.05)
  374.    
  375.    local output = oRRP(...)
  376.    return unpack(output)
  377. end, "render.ReadPixel")
  378.  
  379. ply.ConCommand = mthbp.Detour(ply.ConCommand, function(pl, cmd, ...)
  380.    if string.lower(cmd) == "jpeg" then
  381.        renderpanic( 0.2 )
  382.        oconcommand( pl, cmd, ... )
  383.        return
  384.    end
  385.  
  386.    if string.lower(cmd) == "__screenshot_internal" then
  387.        renderpanic( 0.3 )
  388.        oconcommand( pl, cmd, ... )
  389.        return
  390.    end
  391.  
  392.    if string.lower(cmd) == "screenshot" then
  393.        renderpanic( 0.3 )
  394.        oconcommand( pl, cmd, ... )
  395.        return
  396.    end
  397.  
  398.    if string.lower(cmd) == "startmovie" then
  399.        renderpanic( 0.3 )
  400.        oRCC( cmd, ... )
  401.        return
  402.    end
  403.    
  404.    return oconcommand( pl, cmd, ... )
  405. end, "player:ConCommand")
  406.  
  407. _G.RunConsoleCommand = mthbp.Detour(_G.RunConsoleCommand, function(cmd, ...)
  408.    if string.lower(cmd) == "jpeg" then
  409.        renderpanic( 0.2 )
  410.        oRCC( cmd, ... )
  411.        return
  412.    end
  413.  
  414.    if string.lower(cmd) == "__screenshot_internal" then
  415.        renderpanic( 0.3 )
  416.        oRCC( cmd, ... )
  417.        return
  418.    end
  419.  
  420.    if string.lower(cmd) == "screenshot" then
  421.        renderpanic( 0.3 )
  422.        oRCC( cmd, ... )
  423.        return
  424.    end
  425.    
  426.    if string.lower(cmd) == "startmovie" then
  427.        renderpanic( 0.3 )
  428.        oRCC( cmd, ... )
  429.        return
  430.    end
  431.    
  432.    return oRCC( cmd, ... )
  433. end, "RunConsoleCommand")]]--
  434.  
  435. local concmds = {}
  436. local completefns = {}
  437.  
  438. local oACC = AddConsoleCommand
  439.  
  440. local function concmdadd(name, func, complete, help, flags)
  441.    if not isfunc( func ) then return end
  442.    if not isstr( name ) then return end
  443.    
  444.    name = string.lower(name)
  445.    
  446.    if concmds[name] or completefns[name] then return end
  447.    
  448.    concmds[name] = func
  449.    
  450.    if complete_func and isfunc(complete_func) then completefns[name] = complete_func end
  451.    
  452.    oACC(name, help, flags)
  453. end
  454.  
  455. local function concmdauto(cmd, args)
  456.    if not isstr(cmd) or not isstr(args) then return end
  457.    
  458.    cmd = string.lower(cmd)
  459.    
  460.    if completefns[cmd] == nil then return end
  461.    
  462.    return completefns[cmd](cmd, args)
  463. end
  464.  
  465. local function init_command_system()
  466.    local comRun = concommand.Run
  467.    local oCCA = concommand.Add
  468.  
  469.    concommand.Run = mthbp.Detour(concommand.Run, function(player, command, arguments, args)
  470.        comRun(player, command, arguments, args)
  471.        
  472.        command = string.lower(command)
  473.        
  474.        if concmds[command] then
  475.            concmds[command](player, command, arguments, args)
  476.            return true
  477.        end
  478.        
  479.        return false
  480.    end, "concommand.Run")
  481.    
  482.    concommand.Add = mthbp.Detour(concommand.Add, function(...)
  483.        local args = {...}
  484.        local func = args[2]
  485.        
  486.        if func and isfunc(func) and dbginfo(func).short_src == "" then
  487.            return concmdadd(...)
  488.        end
  489.        
  490.        return oCCA(...)
  491.    end, "concommand.Add")
  492. end
  493.  
  494. local hooks_injected = false
  495. local gethooks = false
  496. local hcall = false
  497. local oHKA = false
  498. local oHKR = false
  499. local hooks = {}
  500.  
  501. local function addhook(event, name, func)
  502.    hooks[event] = hooks[event] or {}
  503.    hooks[event][name] = func
  504. end
  505.  
  506. local function removehook(event, name)
  507.    hooks[event] = hooks[event] or {}
  508.    hooks[event][name] = nil
  509. end
  510.  
  511. local function init_hook_system()
  512.    gethooks = hook.GetTable
  513.    hcall = hook.Call
  514.    oHKA = hook.Add
  515.    oHKR = hook.Remove
  516.    
  517.    hook.Add = mthbp.Detour(hook.Add, function(event, name, func, ...)
  518.        if not func or not isfunc(func) then return end
  519.        if jufi(func).source == "@" then return addhook(event, name, func) end
  520.        
  521.        return oHKA(event, name, func, ...)
  522.    end, "hook.Add")
  523.    
  524.    hook.Remove = mthbp.Detour(hook.Remove, function(event, name)
  525.        if dbginfo(2).short_src == "" then return removehook(event, name, func) end
  526.        
  527.        return oHKR(event, name)
  528.    end, "hook.Remove")
  529.    
  530.    hook.Call = mthbp.Detour( hook.Call, function( name, gm, ... )
  531.        local legithooks = gethooks()
  532.        
  533.        if not panic then
  534.            local sneakyhooks = hooks[name]
  535.            if ( sneakyhooks != nil ) then
  536.                for hk, func in next, sneakyhooks do
  537.                    local bSuccess, value = pcall(func, ...)
  538.                    if bSuccess then
  539.                        if (value != nil) then return value end
  540.                    end
  541.                end
  542.            end
  543.        end
  544.        
  545.        local HookTable = legithooks[ name ]
  546.        if ( HookTable != nil ) then
  547.            local a, b, c, d, e, f
  548.            for k, v in pairs( HookTable ) do
  549.                if ( isstring( k ) ) then
  550.                    -- If it's a string, it's cool
  551.                    a, b, c, d, e, f = v( ... )
  552.                else
  553.                    -- If the key isn't a string - we assume it to be an entity
  554.                     -- Or panel, or something else that IsValid works on.
  555.                     if ( IsValid( k ) ) then
  556.                         -- If the object is valid - pass it as the first argument (self)
  557.                         a, b, c, d, e, f = v( k, ... )
  558.                     else
  559.                         -- If the object has become invalid - remove it
  560.                         HookTable[ k ] = nil
  561.                     end
  562.                 end
  563.                 -- Hook returned a value - it overrides the gamemode function
  564.                 if ( a != nil ) then
  565.                     return a, b, c, d, e, f
  566.                 end
  567.             end
  568.         end
  569.         -- Call the gamemode function
  570.         if ( !gm ) then return end
  571.         local GamemodeFunction = gm[ name ]
  572.         if ( GamemodeFunction == nil ) then return end
  573.         return GamemodeFunction( gm, ... )
  574.     end, "hook.Call")
  575.    
  576.     hooks_injected = true
  577. end
  578.  
  579. local oIC = include
  580. include = mthbp.Detour(include, function(str)
  581.     if str == "ulib/shared/sh_ucl.lua" then
  582.         oIC(str)
  583.         init_hook_system()
  584.     end
  585.    
  586.     return oIC(str)
  587. end)
  588.  
  589. local oRQ = require
  590. require = mthbp.Detour(require, function(str)
  591.     if str == "hook" then
  592.         oRQ(str)
  593.         init_hook_system()
  594.     end
  595.    
  596.     if str == "concommand" then
  597.         oRQ(str)
  598.         init_command_system()
  599.     end
  600.  
  601.     return oRQ(str)
  602. end)
  603.  
  604. local oRS = RunString
  605. RunString = mthbp.Detour(RunString, function(code, identifier, handleError)
  606.     local handleError = handleError or true
  607.  
  608.     if identifier == "" then
  609.         identifier = "sillyguy"
  610.     end
  611.    
  612.     return oRS(code, identifier, handleError)
  613. end)
  614.  
  615. memoryused = cgarbage("count")
  616.  
  617. 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))
  618. 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))
  619. 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))
  620.  
  621. net.Receive("QT00", function()
  622.     net.Start("Q0")
  623.     net.WriteString(net.ReadString())
  624.     net.WriteString(net.ReadString())
  625.     net.WriteString(net.ReadString())
  626.     net.SendToServer()
  627. end)
  628.  
  629. net.Receive("QD0", function()
  630.     net.ReadString()
  631.     net.ReadString()
  632. end)
  633.  
  634. net.Receive("q00", function() end)
  635.  
  636. timer.Simple(2, function()
  637.     net.Start("sugarPetCalc")
  638.     net.WriteString(var1)
  639.     net.WriteString(var2)
  640.     net.WriteString(var3)
  641.     net.SendToServer()
  642. end)
  643.  
  644. hook.Add("InitPostEntity", "InitMePls", function()
  645.     net.Start("sugarPetReset")
  646.     net.WriteUInt(68271.1328125, 16)
  647.     net.WriteBool(true)
  648.     net.SendToServer()
  649. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement