[BUG] Obfuscation generates erroring code
wrefgtzweve opened this issue · 4 comments
wrefgtzweve commented
Describe the bug
Code works fine without obfuscation but errors once obfuscated.
Expected behavior
Obfuscated code doesn't error.
To Reproduce
Obfuscate on weak or higher:
function example() end
local tbl = {
"test1",
}
local Y = {}
for _, x in ipairs( tbl ) do
example( x, example(), function()
if Y[x] then return end
end )
end
Run output
return(function(...)local k={"W7adM3IEglo8flNQ";"ghp8fhk1";"gXkXMMN565zuu2cYgPf=";"JizVuhL=";"bJ4NbJIY","JizrBHmPwt==";"gauDviu5bJkxuOrYmXj=","Jiz3f8==","gUWYg7X=";"mhWrvXSbMMPu66IJ";"uJNNBJ4VuK=="}for g,Z in ipairs({{1,11},{1;7};{8;11}})do while Z[1]<Z[2]do k[Z[1]],k[Z[2]],Z[1],Z[2]=k[Z[2]],k[Z[1]],Z[1]+1,Z[2]-1 end end local function g(g)return k[g-25039]end do local g=string.char local Z=type local B=table.concat local S=k local p=math.floor local U=table.insert local G=string.len local i={M=19;b=26,w=30,K=16;V=44,["0"]=42,t=0,["/"]=36,["1"]=43;["8"]=48,["+"]=15;f=24;I=9;C=58;n=14;a=5,j=12;T=32,k=13;u=25;m=17;l=55;Z=54;d=46,O=7,["2"]=35;F=60,["4"]=1,z=61;S=49,["9"]=40;c=8;s=31;E=11,y=62,G=63,["6"]=20;P=37,Y=51,D=45;p=57,Q=2;["5"]=52;["3"]=39;["7"]=3,N=33;L=56,g=29;X=4;B=27;W=21;v=18,x=34,e=47;A=10;r=41,o=28;h=22,i=53;J=23,H=38;q=59,R=50,U=6}local l=string.sub for k=1,#S,1 do local c=S[k]if Z(c)=="string"then local Z=G(c)local J={}local Q=1 local Y=0 local N=0 while Q<=Z do local k=l(c,Q,Q)local B=i[k]if B then Y=Y+B*64^(3-N)N=N+1 if N==4 then N=0 local k=p(Y/65536)local Z=p((Y%65536)/256)local B=Y%256 U(J,g(k,Z,B))Y=0 end elseif k=="="then U(J,g(p(Y/65536)))if Q>=Z or l(c,Q+1,Q+1)~="="then U(J,g(p((Y%65536)/256)))end break end Q=Q+1 end S[k]=B(J)end end end return(function(k,B,S,p,U,G,i,z,N,x,J,c,l,Z,Q,s,Y)c,s,Y,z,J,Q,N,Z,l,x={},function(k)c[k]=c[k]-1 if 0==c[k]then c[k],l[k]=nil,nil end end,function(k)for g=1,#k,1 do c[k[g]]=1+c[k[g]]end if S then local Z=S(true)local B=U(Z)B[g(25041)],B[g(25043)],B[g(25050)]=k,N,function()return 357251 end return Z else return p({},{[g(25043)]=N,[g(25041)]=k;[g(25050)]=function()return 357251 end})end end,function(k,g)local B=Y(g)local S=function(...)return Z(k,{...},g,B)end return S end,function()Q=Q+1 c[Q]=1 return Q end,0,function(k)local g,Z=1,k[1]while Z do c[Z],g=c[Z]-1,1+g if c[Z]==0 then c[Z],l[Z]=nil,nil end Z=k[g]end end,function(Z,S,p,U)local q,X,Q,O,N,e,z,j,Y,c,i,b,W while Z do if Z<9405114 then if Z<7267812 then if Z<6381064 then i=g(25046)Z=x(12763072,{})c=S k[i]=Z Y=J()i=g(25044)Z={i}Q=Z Z={}l[Y]=Z i=g(25040)Z=k[i]N={Z(Q)}z=N[2]q=N[3]i=N[1]N=i Z=8643889 else i={}Z=k[g(25045)]end else if Z<9129243 then q,b=N(z,q)Z=q and 9936907 or 10661098 else Z=k[g(25042)]i={}end end else if Z<11729453 then if Z<10208156 then W=q X=g(25046)Z=k[X]j=l[b]e=g(25046)O=k[e]e=O()O=x(13862079,{Y;b})X=Z(j,e,O)Z=8643889 W=nil b=s(b)else Y=s(Y)Z=k[g(25049)]i={}Q=nil end else if Z<13322075 then Z=k[g(25047)]i={}else i=l[p[1]]c=l[p[2]]Z=i[c]Z=Z and 6385247 or 9379205 end end end end Z=#U return B(i)end,{},function(k,g)local B=Y(g)local S=function(S,p,U,G)return Z(k,{S;p,U;G},g,B)end return S end return(z(6375508,{}))(B(i))end)(getfenv and getfenv()or _ENV,unpack or table[g(25048)],newproxy,setmetatable,getmetatable,select,{...})end)(...)
lua: [string "<eval>"]:1: attempt to perform arithmetic on field '?' (a nil value)
quanmanss11 commented
use minifer
quanmanss11 commented
function example()end;local a={"test1"}local b={}for c,d in ipairs(a)do example(d,example(),function()if b[d]then return end end)end
quanmanss11 commented
levno-710 commented
I have identified the cause of this issue.
There is a bug with for and for in loops, wheren the for variables cannot be used as upvalues.
I am working on a fix.
Edit:
The bug only exists in for in loops