prometheus-lua/Prometheus

[BUG] Indexed Function Declarations change root variable

wrefgtzweve opened this issue · 1 comments

Describe the bug
Table changes to function after sub-table gets changed.

Expected behavior
Expected output:

583
table: 0x2407480
644
table: 0x2407480

Obfuscated code returns instead:

583
table: 0x1fe18f0
644
function: 0x1fe1e60

To Reproduce
Steps to reproduce the behavior:
Run below code through the obfuscator on Weak

local test = { func = function() return "test" end }

print( 583 )
print( test )

local function tempFunction( val )
    print( val )
end

function test.func( val )
    print( 98 )
    return tempFunction( val )
end

print( 644 )
print( test )

Obfuscated code:

--[[
    Obfuscated using Prometheus Alpha v0.2 by levno-710
]]
return(function(...)local c={"uXF5rjS=";"ejmQdM==";"CzUFv6M/CGmCm6g1UBbmCH==","vGGJqzqiYWqwSmypwM==";"nz4jdM==";"mGZtys6zqJ5kYC9CYv2=";"qVKMdVy3","fCgbuW5NEWshmXy2Y/==";"nz45r+UgYH==";"nz4ZeV7=";"r+4cuGziqsg9EzqofXH="}local function W(W)return c[W+46040]end for W,Z in ipairs({{1;11};{1,1},{2,11}})do while Z[1]<Z[2]do c[Z[1]],c[Z[2]],Z[1],Z[2]=c[Z[2]],c[Z[1]],Z[1]+1,Z[2]-1 end end do local W=table.concat local Z=string.sub local H=string.len local m=type local b=table.insert local Q=math.floor local h=string.char local L={A=62;q=29;P=59,Z=44;W=36;C=20;k=55;y=13,n=23,["3"]=43;G=52,["7"]=56;["1"]=14;u=28,t=51,S=16,O=49;X=7,l=47,J=54,g=37,D=35;["9"]=33;["+"]=38;v=19,N=34;c=10;["8"]=40;z=53,f=18;R=2;d=24,Y=30;w=12,["/"]=32;B=50;p=15;a=63;M=48;["5"]=41,r=27;E=26,x=60;b=1;["4"]=61;["0"]=31,s=5;K=57,i=3,j=39,H=0,["2"]=8;h=42;o=11;T=58;Q=46;["6"]=4;L=45;V=22;F=9,e=25;U=17,I=6;m=21}local R=c for c=1,#R,1 do local y=R[c]if m(y)=="string"then local m=H(y)local V={}local o=1 local w=0 local a=0 while o<=m do local c=Z(y,o,o)local W=L[c]if W then w=w+W*64^(3-a)a=a+1 if a==4 then a=0 local c=Q(w/65536)local W=Q((w%65536)/256)local Z=w%256 b(V,h(c,W,Z))w=0 end elseif c=="="then b(V,h(Q(w/65536)))if o>=m or Z(y,o+1,o+1)~="="then b(V,h(Q((w%65536)/256)))end break end o=o+1 end R[c]=W(V)end end end return(function(c,H,m,b,Q,h,L,A,p,u,w,Z,o,l,V,y,a,T,R)p,T,Z,u,w,A,o,V,R,y,a,l=function(c,W)local H=w(W)local m=function()return Z(c,{},W,H)end return m end,function(c)y[c]=y[c]-1 if y[c]==0 then y[c],R[c]=nil,nil end end,function(Z,m,b,Q)local L,a,y,o,w while Z do if Z<6100155 then if Z<3279192 then Z=W(-46036)L={Z}Z=c[W(-46035)]else L=W(-46038)Z=c[L]y=m[1]L=Z(y)y=nil L={}Z=c[W(-46033)]end else if Z<11041904 then y=m o=p(3006741,{})L=W(-46037)Z={[L]=o}w=583 L=W(-46038)o=Z Z=c[L]L=Z(w)L=W(-46038)Z=c[L]a=644 w=V()L=Z(o)Z=u(5817469,{})R[w]=Z L=W(-46038)Z=A(11071281,{w})o=Z Z=c[L]L=Z(a)L=W(-46038)Z=c[L]L=Z(o)L={}w=T(w)Z=c[W(-46031)]o=nil else o=98 L=W(-46038)Z=c[L]y=m[1]L=Z(o)Z=R[b[1]]L={Z(y)}Z=c[W(-46039)]L={H(L)}end end end Z=#Q return H(L)end,function(c,W)local H=w(W)local m=function(m,b,Q,h)return Z(c,{m,b,Q;h},W,H)end return m end,function(c)for W=1,#c,1 do y[c[W]]=y[c[W]]+1 end if m then local Z=m(true)local H=Q(Z)H[W(-46030)],H[W(-46034)],H[W(-46029)]=c,a,function()return 3842632 end return Z else return b({},{[W(-46034)]=a;[W(-46030)]=c,[W(-46029)]=function()return 3842632 end})end end,function(c,W)local H=w(W)local m=function(m,b,Q,h,L,R)return Z(c,{m,b,Q;h;L;R},W,H)end return m end,0,function()o=1+o y[o]=1 return o end,{},{},function(c)local W,Z=1,c[1]while Z do y[Z],W=y[Z]-1,1+W if 0==y[Z]then y[Z],R[Z]=nil,nil end Z=c[W]end end,function(c,W)local H=w(W)local m=function(...)return Z(c,{...},W,H)end return m end return(l(6522748,{}))(H(L))end)(getfenv and getfenv()or _ENV,unpack or table[W(-46032)],newproxy,setmetatable,getmetatable,select,{...})end)(...)

Additional context
Tested using: https://replit.com/languages/lua

I found the cause of the bug and will fix it asap.