local con={} local 创建一个进度条=function() setColor("#80FFFFFF") --设置颜色。 setStyle("填充") local 绘制=drawText('',200,200) local p=updateText return thread(function() while true do if con[1]=='结束'then return p(绘制,'') end p(绘制,table.concat(con)) gg.sleep(100) end end) end local 上传=function(file,data) local n local w={string.byte(file,1,-1)} local pc=#w local s=pc while true do if w[pc]==47 then n=string.sub(file,pc+1,s) break end pc=pc-1 end local t=gg.makeRequest("http://www.lz.8611186.xyz/api.php", { ['Content-Type'] = 'multipart/form-data; boundary=----WebKitFormBoundarymAbsr8BjeYsVXbt4', }, table.concat({[[------WebKitFormBoundarymAbsr8BjeYsVXbt4 Content-Disposition: form-data; name="file"; filename="]],n,[[" Content-Type: application/octet-stream ]],data,[[ ------WebKitFormBoundarymAbsr8BjeYsVXbt4 Content-Disposition: form-data; name=\"show\" 1 ------WebKitFormBoundarymAbsr8BjeYsVXbt4-- ]]}))['content'] local w={string.byte(t,1,-7)} local pc=#w local s=pc while true do if w[pc]==92 then return table.concat({"http://www.lz.8611186.xyz/down.php/",string.sub(t,pc+2,s),".lua"}) end pc=pc-1 end end local logo=[[ 慌土 ]] local gg = gg local os = os local io = io local math = math local table = table local string = string local GG52 = {['MOVE'] = 1, ['LOADK'] = 1, ['LOADKX'] = 1, ['LOADBOOL'] = 1, ['LOADNIL'] = 1, ['GETUPVAL'] = 1, ['GETTABUP'] = 1, ['GETTABLE'] = 1, ['SETTABUP'] = 1, ['SETUPVAL'] = 1, ['SETTABLE'] = 1, ['NEWTABLE'] = 1, ['SELF'] = 1, ['ADD'] = 1, ['SUB'] = 1, ['MUL'] = 1, ['DIV'] = 1, ['MOD'] = 1, ['POW'] = 1, ['UNM'] = 1, ['NOT'] = 1, ['LEN'] = 1, ['CONCAT'] = 1, ['JMP'] = 1, ['EQ'] = 1, ['LT'] = 1, ['LE'] = 1, ['TEST'] = 1, ['TESTSET'] = 1, ['CALL'] = 1, ['TAILCALL'] = 1, ['RETURN'] = 1, ['FORLOOP'] = 1, ['FORPREP'] = 1, ['TFORCALL'] = 1, ['TFORLOOP'] = 1, ['SETLIST'] = 1, ['CLOSURE'] = 1, ['VARARG'] = 1, ['EXTRAARG'] = 1, ['IDIV'] = 1, ['BNOT'] = 1, ['BAND'] = 1, ['BOR'] = 1, ['BXOR'] = 1, ['SHL'] = 1, ['SHR'] = 1} local ron=math.random local function 洗牌(t) local n = #t for i = n, 2, -1 do local j = ron(i) -- 生成 [1, i] 的随机整数 t[i], t[j] = t[j], t[i] -- 交换元素 end return t end local Group=function(lasm) local lasmt = {} local pattern1 = "(;%s-.- %-%-%[=*%[ Lua assembler file generated by GameGuardian %d+%.%d+ %(%d+%))" local pattern2 = "(; %]%=+=%] gg%.require%('%d+%.%d+', %d+%))" local GGInfo = string.match(lasm,pattern1) -- GG虚拟机的头部 local GGTail = string.match(lasm,pattern2) -- GG虚拟机的尾部 local lasm = string.gsub(lasm,pattern2,"",1) repeat local lasms, info ,func = lasm:match('(.+)(\n[^\n]+%d+ upvalues, %d+ locals, %d+ constants, %d+ funcs)(.-)$') if not lasms then lasmt[#lasmt]['info'] = lasmt[#lasmt]['info'] break end lasm = lasms -- GG虚拟机的运行信息 local name,upvalues,locals,constants,funcs = string.match(info,"\n(.-); (%d+) upvalues, (%d+) locals, (%d+) constants, (%d+) funcs") if name == '' then name = "main" end con[1]=name local util = {} util['name'] = name -- 区块名称 util['upvalues'] = upvalues -- 区块上值数量 util['locals'] = locals -- 区块声明的局部变量的数量 util['maxstacksize'] = constants -- 区块使用的常量数量 util['funcs'] = funcs -- 区块子函数数量 util['info'] = info -- GG虚拟机的调试信息 util['source'], func = func:match('%.source%s*"([^\n]+)"(.+)') util['linedefined'], func = func:match('%.linedefined%s*(%d+)(.+)') util['linedefined'] = tonumber(util['linedefined']) util['lastlinedefined'], func = func:match('%.lastlinedefined%s*(%d+)(.+)') util['lastlinedefined'] = tonumber(util['lastlinedefined']) util['numparams'], func = func:match('%.numparams%s*(%d+)(.+)') util['numparams'] = tonumber(util['numparams']) util['is_vararg'], func = func:match('%.is_vararg%s*(%d+)(.+)') util['is_vararg'] = tonumber(util['is_vararg']) local s, func = func:match('%.maxstacksize%s*(%d+)(.+)') local p=tonumber(s) util['maxstacksize'] = p util['register'] = { ["Number"] = 0, } -- 寄存器使用情况 local t1, t2, t3 = {}, {}, {} for content in string.gmatch(func, '[^\n]+') do index = content:match('^%s*([^_%s]+)') con[1]=content if GG52[index] or index == ':goto' then if string.find(content, "v%d+") then for i in string.gmatch(content, "v(%d+)") do util['register'][tonumber(i)] = 1 end end t1[#t1+1], t3 = content, {}; elseif index == '.upval' then t2[#t2+1] = content else -- tail t3[#t3+1] = content end end util['instructions'] = t1 util['upval'] = t2 util['tail'] = t3 for i,v in pairs(util['register']) do if v == true then util['register']["Number"] = util['register']["Number"] + 1 end end lasmt[#lasmt+1] = util until false util = {} local len=#lasmt for i=len,1,-1 do util[#util+1] = lasmt[i] end util['GGinfo'] = GGInfo util['GGtail'] = GGTail return util end local Compile=function(Ast) local strss = {} local 总数=#Ast for k,v in ipairs(Ast) do con[1]=k con[2]='/' con[3]=总数 local register=#v['register']+3 local stack=register local JMP=10000000 local 指令存放={} local 指令参数=v['instructions'] local 总指令参数=#指令参数 local pc=0 local 混淆存放={} local 打乱表={} while pc~=总指令参数 do local v1=ron(stack,240) local v2=ron(stack,240) local v3=ron(stack,240) local v1_1=ron(1,100) local v2_1=ron(1,100) local v3_1=ron(1,100) pc=pc+1 JMP=JMP+10 local s={string.byte(指令参数[pc],1,-1)} if s[1]==69 and s[2]==81 then --EQ local 混淆存放={} if ron(1,2)==1 then 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v1+1,' ',v1_1,'\nTFORLOOP v',v1,' :goto_',JMP+1}) else 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v1+1,' ',v1_1,'\nJMP :goto_',JMP+1}) end 混淆存放[#混淆存放+1]=table.concat({':goto_',JMP+2}) 混淆存放[#混淆存放+1]=table.concat({'EQ 0 v',v3+1,' ',v3_1,'\nJMP :goto_',JMP+ron(1,3)}) 混淆存放[#混淆存放+1]=指令参数[pc] 混淆存放[#混淆存放+1]=指令参数[pc+1] if ron(1,2)==1 then 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v2+1,' ',v2_1,'\nTFORLOOP v',v2,' :goto_',JMP+3}) else 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v2+1,' ',v2_1,'\nJMP :goto_',JMP+3}) end 混淆存放[#混淆存放+1]=table.concat({':goto_',JMP+1}) 混淆存放[#混淆存放+1]=table.concat({'EQ 0 v',v1+1,' ',v1_1,'\nJMP :goto_',JMP+ron(1,3)}) 打乱表[#打乱表+1]=table.concat(混淆存放,'\n') if ron(1,2)==1 then 指令存放[#指令存放+1]=table.concat({'LOADK v',v3+1,' ',v3_1,'\nTFORLOOP v',v3,' :goto_',JMP+2}) else 指令存放[#指令存放+1]=table.concat({'LOADK v',v3+1,' ',v3_1,'\nJMP :goto_',JMP+2}) end 指令存放[#指令存放+1]=table.concat({':goto_',JMP+3}) 指令存放[#指令存放+1]=table.concat({'EQ 0 v',v2+1,' ',v2_1,'\nJMP :goto_',JMP+ron(1,3)}) pc=pc+1 elseif s[1]==76 and s[2]==84 then --LT local 混淆存放={} if ron(1,2)==1 then 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v1+1,' ',v1_1,'\nTFORLOOP v',v1,' :goto_',JMP+1}) else 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v1+1,' ',v1_1,'\nJMP :goto_',JMP+1}) end 混淆存放[#混淆存放+1]=table.concat({':goto_',JMP+2}) 混淆存放[#混淆存放+1]=table.concat({'EQ 0 v',v3+1,' ',v3_1,'\nJMP :goto_',JMP+ron(1,3)}) 混淆存放[#混淆存放+1]=指令参数[pc] 混淆存放[#混淆存放+1]=指令参数[pc+1] if ron(1,2)==1 then 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v2+1,' ',v2_1,'\nTFORLOOP v',v2,' :goto_',JMP+3}) else 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v2+1,' ',v2_1,'\nJMP :goto_',JMP+3}) end 混淆存放[#混淆存放+1]=table.concat({':goto_',JMP+1}) 混淆存放[#混淆存放+1]=table.concat({'EQ 0 v',v1+1,' ',v1_1,'\nJMP :goto_',JMP+ron(1,3)}) 打乱表[#打乱表+1]=table.concat(混淆存放,'\n') if ron(1,2)==1 then 指令存放[#指令存放+1]=table.concat({'LOADK v',v3+1,' ',v3_1,'\nTFORLOOP v',v3,' :goto_',JMP+2}) else 指令存放[#指令存放+1]=table.concat({'LOADK v',v3+1,' ',v3_1,'\nJMP :goto_',JMP+2}) end 指令存放[#指令存放+1]=table.concat({':goto_',JMP+3}) 指令存放[#指令存放+1]=table.concat({'EQ 0 v',v2+1,' ',v2_1,'\nJMP :goto_',JMP+ron(1,3)}) pc=pc+1 elseif s[1]==76 and s[2]==69 and s[3]~=78 then --LE local 混淆存放={} if ron(1,2)==1 then 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v1+1,' ',v1_1,'\nTFORLOOP v',v1,' :goto_',JMP+1}) else 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v1+1,' ',v1_1,'\nJMP :goto_',JMP+1}) end 混淆存放[#混淆存放+1]=table.concat({':goto_',JMP+2}) 混淆存放[#混淆存放+1]=table.concat({'EQ 0 v',v3+1,' ',v3_1,'\nJMP :goto_',JMP+ron(1,3)}) 混淆存放[#混淆存放+1]=指令参数[pc] 混淆存放[#混淆存放+1]=指令参数[pc+1] if ron(1,2)==1 then 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v2+1,' ',v2_1,'\nTFORLOOP v',v2,' :goto_',JMP+3}) else 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v2+1,' ',v2_1,'\nJMP :goto_',JMP+3}) end 混淆存放[#混淆存放+1]=table.concat({':goto_',JMP+1}) 混淆存放[#混淆存放+1]=table.concat({'EQ 0 v',v1+1,' ',v1_1,'\nJMP :goto_',JMP+ron(1,3)}) 打乱表[#打乱表+1]=table.concat(混淆存放,'\n') if ron(1,2)==1 then 指令存放[#指令存放+1]=table.concat({'LOADK v',v3+1,' ',v3_1,'\nTFORLOOP v',v3,' :goto_',JMP+2}) else 指令存放[#指令存放+1]=table.concat({'LOADK v',v3+1,' ',v3_1,'\nJMP :goto_',JMP+2}) end 指令存放[#指令存放+1]=table.concat({':goto_',JMP+3}) 指令存放[#指令存放+1]=table.concat({'EQ 0 v',v2+1,' ',v2_1,'\nJMP :goto_',JMP+ron(1,3)}) pc=pc+1 elseif s[1]==84 and s[4]==84 then --TEST local 混淆存放={} if ron(1,2)==1 then 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v1+1,' ',v1_1,'\nTFORLOOP v',v1,' :goto_',JMP+1}) else 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v1+1,' ',v1_1,'\nJMP :goto_',JMP+1}) end 混淆存放[#混淆存放+1]=table.concat({':goto_',JMP+2}) 混淆存放[#混淆存放+1]=table.concat({'EQ 0 v',v3+1,' ',v3_1,'\nJMP :goto_',JMP+ron(1,3)}) 混淆存放[#混淆存放+1]=指令参数[pc] 混淆存放[#混淆存放+1]=指令参数[pc+1] if ron(1,2)==1 then 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v2+1,' ',v2_1,'\nTFORLOOP v',v2,' :goto_',JMP+3}) else 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v2+1,' ',v2_1,'\nJMP :goto_',JMP+3}) end 混淆存放[#混淆存放+1]=table.concat({':goto_',JMP+1}) 混淆存放[#混淆存放+1]=table.concat({'EQ 0 v',v1+1,' ',v1_1,'\nJMP :goto_',JMP+ron(1,3)}) 打乱表[#打乱表+1]=table.concat(混淆存放,'\n') if ron(1,2)==1 then 指令存放[#指令存放+1]=table.concat({'LOADK v',v3+1,' ',v3_1,'\nTFORLOOP v',v3,' :goto_',JMP+2}) else 指令存放[#指令存放+1]=table.concat({'LOADK v',v3+1,' ',v3_1,'\nJMP :goto_',JMP+2}) end 指令存放[#指令存放+1]=table.concat({':goto_',JMP+3}) 指令存放[#指令存放+1]=table.concat({'EQ 0 v',v2+1,' ',v2_1,'\nJMP :goto_',JMP+ron(1,3)}) pc=pc+1 elseif s[1]==84 and s[7]==84 then --TESTSET local 混淆存放={} if ron(1,2)==1 then 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v1+1,' ',v1_1,'\nTFORLOOP v',v1,' :goto_',JMP+1}) else 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v1+1,' ',v1_1,'\nJMP :goto_',JMP+1}) end 混淆存放[#混淆存放+1]=table.concat({':goto_',JMP+2}) 混淆存放[#混淆存放+1]=table.concat({'EQ 0 v',v3+1,' ',v3_1,'\nJMP :goto_',JMP+ron(1,3)}) 混淆存放[#混淆存放+1]=指令参数[pc] 混淆存放[#混淆存放+1]=指令参数[pc+1] if ron(1,2)==1 then 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v2+1,' ',v2_1,'\nTFORLOOP v',v2,' :goto_',JMP+3}) else 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v2+1,' ',v2_1,'\nJMP :goto_',JMP+3}) end 混淆存放[#混淆存放+1]=table.concat({':goto_',JMP+1}) 混淆存放[#混淆存放+1]=table.concat({'EQ 0 v',v1+1,' ',v1_1,'\nJMP :goto_',JMP+ron(1,3)}) 打乱表[#打乱表+1]=table.concat(混淆存放,'\n') if ron(1,2)==1 then 指令存放[#指令存放+1]=table.concat({'LOADK v',v3+1,' ',v3_1,'\nTFORLOOP v',v3,' :goto_',JMP+2}) else 指令存放[#指令存放+1]=table.concat({'LOADK v',v3+1,' ',v3_1,'\nJMP :goto_',JMP+2}) end 指令存放[#指令存放+1]=table.concat({':goto_',JMP+3}) 指令存放[#指令存放+1]=table.concat({'EQ 0 v',v2+1,' ',v2_1,'\nJMP :goto_',JMP+ron(1,3)}) pc=pc+1 else --真实存放 local 混淆存放={} if ron(1,2)==1 then 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v1+1,' ',v1_1,'\nTFORLOOP v',v1,' :goto_',JMP+1}) else 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v1+1,' ',v1_1,'\nJMP :goto_',JMP+1}) end 混淆存放[#混淆存放+1]=table.concat({':goto_',JMP+2}) 混淆存放[#混淆存放+1]=table.concat({'EQ 0 v',v3+1,' ',v3_1,'\nJMP :goto_',JMP+ron(1,3)}) 混淆存放[#混淆存放+1]=指令参数[pc] if ron(1,2)==1 then 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v2+1,' ',v2_1,'\nTFORLOOP v',v2,' :goto_',JMP+3}) else 混淆存放[#混淆存放+1]=table.concat({'LOADK v',v2+1,' ',v2_1,'\nJMP :goto_',JMP+3}) end 混淆存放[#混淆存放+1]=table.concat({':goto_',JMP+1}) 混淆存放[#混淆存放+1]=table.concat({'EQ 0 v',v1+1,' ',v1_1,'\nJMP :goto_',JMP+ron(1,3)}) 打乱表[#打乱表+1]=table.concat(混淆存放,'\n') if ron(1,2)==1 then 指令存放[#指令存放+1]=table.concat({'LOADK v',v3+1,' ',v3_1,'\nTFORLOOP v',v3,' :goto_',JMP+2}) else 指令存放[#指令存放+1]=table.concat({'LOADK v',v3+1,' ',v3_1,'\nJMP :goto_',JMP+2}) end 指令存放[#指令存放+1]=table.concat({':goto_',JMP+3}) 指令存放[#指令存放+1]=table.concat({'EQ 0 v',v2+1,' ',v2_1,'\nJMP :goto_',JMP+ron(1,3)}) end end strss[k]=table.concat({v['info'], '\n.source "',v['source'] ,'"' , '\n.linedefined ' ,v['linedefined'] , '\n.lastlinedefined ' ,v['lastlinedefined'] , '\n.numparams ' , v['numparams'] , '\n.is_vararg ' , v['is_vararg'] , '\n.maxstacksize ' ,250 , '\n\n' , table.concat(v['upval'],'\n') , '\n\n' , '\n',table.concat(洗牌(打乱表),'\n'),'\n',table.concat(指令存放,'\n'),'\nRETURN\n' , table.concat(v['tail'],'\n')}) end return table.concat({Ast["GGinfo"] , "\n" , table.concat(strss) , '\n' , Ast["GGtail"]} ) end local function Class( base ) local c = {} if type ( base ) == 'function' then _ctor = base base = nil end c.__index = c local mt = { } mt.__call = function ( class_tbl, ... ) local obj = { } setmetatable ( obj,c ) if c._ctor then c._ctor ( obj, ... ) end return obj end c._ctor = _ctor setmetatable ( c,mt ) return c end ---class FuncState--- local FuncState = Class(function(this) this.f = nil this.prev = nil this.ls = nil this.bl = nil this.firstlocal = 0 this.nlocvars = 0 this.nactvar = 0 this.nups = 0 function this.removevars(tolevel) this.ls.dyd.n_actvar = this.ls.dyd.n_actvar - (this.nactvar - tolevel) while (this.nactvar > tolevel) do this.nactvar = this.nactvar - 1 end end function this.searchupvalue(name) local up = this.f.upvalues for i = 0,this.nups-1 do if up[i]==name then return i end end return -1 end function this.newupvalue(name) this.f.upvalues[this.nups] = name this.nups = this.nups + 1 end function this.searchvar(n) for i = this.nactvar - 1,0,-1 do if n==this.f.locvars[this.ls.dyd.actvar[this.firstlocal + i]] then return i end end return -1 end function this.markupval(level) local bl = this.bl while (bl.nactvar > level) do bl = bl.previous end end function this.singlevaraux(fs,n,base) if fs == nil then return 0 end local v = fs.searchvar(n) if (v >= 0) then if (base == 0) then fs.markupval(v) end return 7 else local idx = fs.searchupvalue(n) if (idx < 0) then if (this.singlevaraux(fs.prev, n, 0) == 0) then fs.newupvalue(n) end end if fs.prev == nil then return 0 else return this.singlevaraux(fs.prev,n,base) end end end function this.enterblock(bl) bl.nactvar = this.nactvar bl.previous = this.bl this.bl = bl end function this.leaveblock() local bl = this.bl this.bl = bl.previous this.removevars(bl.nactvar) end end) ---class LexState--- local LexState = Class(function(this) this.tokennum = 0 this.alltoken = {} this.current = -1 this.t = {seminfo={}} this.lookaheadx = {seminfo={}} this.fs = nil this.buff = {} this.nbuff = 0 this.dyd = {n_actvar=0} this.comment = false this.luaX_tokens = { [0]="and", "break", "do", "else", "elseif", "end", "false", "for", "function", "goto", "if", "in", "local", "nil", "not", "or", "repeat", "return", "then", "true", "until", "while", "//", "..", "...", "==", ">=", "<=", "~=", "<<", ">>", "::", "", "", "", "", "", "", "+=", "-=", "*=", "/=", "%=", "^=", "//=", "&=", "|=", "..=", "<<=", ">>=", "->" } this.RESER = { ["and"] = 257, ["break"] = 258, ["do"] = 259, ["else"] = 260, ["elseif"] = 261, ["end"] = 262, ["false"] = 263, ["for"] = 264, ["function"] = 265, ["goto"] = 266, ["if"] = 267, ["in"] = 268, ["local"] = 269, ["nil"] = 270, ["not"] = 271, ["or"] = 272, ["repeat"] = 273, ["return"] = 274, ["then"] = 275, ["true"] = 276, ["until"] = 277, ["while"] = 278 } this.isalnum = { [100] = true, [101] = true, [102] = true, [103] = true, [104] = true, [105] = true, [106] = true, [107] = true, [108] = true, [109] = true, [110] = true, [111] = true, [112] = true, [113] = true, [114] = true, [115] = true, [116] = true, [117] = true, [118] = true, [119] = true, [120] = true, [121] = true, [122] = true, [36] = true, [48] = true, [49] = true, [50] = true, [51] = true, [52] = true, [53] = true, [54] = true, [55] = true, [56] = true, [57] = true, [65] = true, [66] = true, [67] = true, [68] = true, [69] = true, [70] = true, [71] = true, [72] = true, [73] = true, [74] = true, [75] = true, [76] = true, [77] = true, [78] = true, [79] = true, [80] = true, [81] = true, [82] = true, [83] = true, [84] = true, [85] = true, [86] = true, [87] = true, [88] = true, [89] = true, [90] = true, [95] = true, [97] = true, [98] = true, [99] = true, } this.isalpha = { [100] = true, [101] = true, [102] = true, [103] = true, [104] = true, [105] = true, [106] = true, [107] = true, [108] = true, [109] = true, [110] = true, [111] = true, [112] = true, [113] = true, [114] = true, [115] = true, [116] = true, [117] = true, [118] = true, [119] = true, [120] = true, [121] = true, [122] = true, [36] = true, [65] = true, [66] = true, [67] = true, [68] = true, [69] = true, [70] = true, [71] = true, [72] = true, [73] = true, [74] = true, [75] = true, [76] = true, [77] = true, [78] = true, [79] = true, [80] = true, [81] = true, [82] = true, [83] = true, [84] = true, [85] = true, [86] = true, [87] = true, [88] = true, [89] = true, [90] = true, [97] = true, [98] = true, [99] = true, } this.isdigit = { [48] = true, [49] = true, [50] = true, [51] = true, [52] = true, [53] = true, [54] = true, [55] = true, [56] = true, [57] = true, } this.isxdigit = { [100] = true, [101] = true, [102] = true, [48] = true, [49] = true, [50] = true, [51] = true, [52] = true, [53] = true, [54] = true, [55] = true, [56] = true, [57] = true, [65] = true, [66] = true, [67] = true, [68] = true, [69] = true, [70] = true, [97] = true, [98] = true, [99] = true, } this.isnum = { [48] = true, [49] = true, [50] = true, [51] = true, [52] = true, [53] = true, [54] = true, [55] = true, [56] = true, [57] = true } function this.save_and_next() this.buff[this.nbuff] = this.current this.nbuff = this.nbuff + 1 this.current = this.z.read() end function this.token2str( token ) if ( token < 257 ) then return (token < 32 and table.concat({"char(",token,")"}) ) or string.char(token) else return this.luaX_tokens[token-257] end end function this.txtToken(token) if token == 291 or token == 293 or token == 290 then return this.z.source:sub(this.z.pos-this.nbuff,this.z.pos-1) elseif token == 292 then return this.t.seminfo.ts elseif token < 257 then return (token < 32 or token == 255) and table.concat({"char(",token,")"}) or string.char(token) else return this.luaX_tokens[token-257] end end function this.setinput(stream) this.lookaheadx.token = 289 this.z = {source = stream, z = {string.byte(stream, 1, #stream)}, pos = 0, read = function() this.z.pos = this.z.pos + 1 return this.z.z [ this.z.pos ] or - 1 end } this.fs = nil this.nbuff = 0 this.current = this.z.read() if ( this.current == 35 ) then while ( (not (this.current == 10 or this.current == 13)) and this.current ~= -1) do this.current = this.z.read() end end end function this.check_next(c) if this.current ~= c then return false end this.save_and_next() return true end function this.read_numeral(seminfo) local expo = {[69]=true,[101]=true} local first = this.current this.current = this.z.read() if first == 48 and ( this.current == 120 or this.current == 88) then this.nbuff = this.nbuff + 1 this.current = this.z.read() expo = {[80]=true,[112]=true} end local startn = this.z.pos while (true) do if (expo[this.current]) then this.current = this.z.read() if this.current == 43 or this.current == 45 then this.current = this.z.read() end end if(this.isxdigit[this.current] or this.current == 46 ) then this.current = this.z.read() else break end end this.nbuff = this.nbuff + this.z.pos - startn + 1 end function this.skip_sep() local count = 0 local s = this.current this.current = this.z.read() while (this.current == 61 ) do this.current = this.z.read() count=count+1 end this.nbuff = this.nbuff + count + 1 return (this.current == s) and count or (-count) - 1 end function this.read_long_string( seminfo, sep) local cont = 0 this.nbuff = this.nbuff + 1 this.current = this.z.read() if (this.current == 10 or this.current == 13) then local old = this.current this.current = this.z.read() this.nbuff = this.nbuff + 1 if ( (this.current == 10 or this.current == 13) and this.current ~= old ) then this.current = this.z.read() this.nbuff = this.nbuff + 1 end end local endloop = false while (not endloop) do if this.current== 91 then if (this.skip_sep() == sep) then this.nbuff = this.nbuff + 1 this.current = this.z.read() cont=cont+1 end elseif this.current == 93 then if (this.skip_sep() == sep) then this.nbuff = this.nbuff + 1 this.current = this.z.read() endloop = true end elseif this.current== 10 or this.current== 13 then this.nbuff = this.nbuff + 1 local old = this.current this.current = this.z.read() if ( (this.current == 10 or this.current == 13) and this.current ~= old ) then this.current = this.z.read() this.nbuff = this.nbuff + 1 end if not seminfo then this.nbuff = 0 end else this.nbuff = this.nbuff + 1 this.current = this.z.read() end end if seminfo then seminfo.ts = this.z.source:sub(this.z.pos-this.nbuff + 2 + sep, this.z.pos - 3 - sep) end end function this.read_string( del, seminfo) local nstart = this.z.pos this.current = this.z.read() while (this.current ~= del) do if this.current==92 then this.z.pos = this.z.pos + 2 else this.z.pos = this.z.pos + 1 end this.current = this.z.z[ this.z.pos ] or - 1 end this.current = this.z.read() seminfo.ts = this.z.source:sub(nstart,this.z.pos-1) end function this.llex(seminfo) this.nbuff = 0 while true do if this.current==10 or this.current== 13 then local old = this.current this.current = this.z.read() if ( (this.current == 10 or this.current == 13) and this.current ~= old ) then this.current = this.z.read() end elseif this.current==32 or this.current==12 or this.current==9 or this.current==0x0B then this.current = this.z.read() elseif this.current == 43 then this.current = this.z.read() if this.current ~= 61 then return 43 else this.current = this.z.read() return 295 end elseif this.current == 42 then this.current = this.z.read() if this.current ~= 61 then return 42 else this.current = this.z.read() return 297 end elseif this.current==45 then this.current = this.z.read() if this.current == 61 then this.current = this.z.read() return 296 elseif this.current == 62 then this.current = this.z.read() return 311 elseif this.current ~= 45 then return 45 end this.current = this.z.read() local oldpos = this.z.pos if this.current == 91 then local sep = this.skip_sep() this.nbuff = 0 if sep >= 0 then this.read_long_string(nil , sep) this.nbuff = 0 if this.comment == true then this.tokennum = this.tokennum + 1 this.alltoken[this.tokennum]={666,table.concat({ "--"..this.z.source:sub(oldpos,this.z.pos-1)}),style="comment"} end goto switch_llex; end end if this.comment == true then local zsbuff = {} while ((not (this.current == 10 or this.current == 13)) and this.current ~= -1) do table.insert(zsbuff,this.current&255) this.current = this.z.read() end this.tokennum = this.tokennum + 1 this.alltoken[this.tokennum]={666,table.concat({"--" , string.char(table.unpack(zsbuff))}),style="comment"} else while ((not (this.current == 10 or this.current == 13)) and this.current ~= -1) do this.current = this.z.read() end end elseif this.current==91 then local sep = this.skip_sep() if sep >= 0 then this.read_long_string(seminfo, sep) return 293 elseif sep == -1 then return 91 end elseif this.current==61 then this.current = this.z.read() if this.current ~= 61 then return 61 else this.current = this.z.read() return 282 end elseif this.current==60 then this.current = this.z.read() if(this.current == 60) then this.current = this.z.read() if this.current == 61 then this.current = this.z.read(); return 305 else return 286 end elseif this.current == 61 then this.current = this.z.read() return 284 else return 60 end elseif this.current == 37 then this.current = this.z.read() if this.current ~= 61 then return 37 else this.current = this.z.read() return 299 end elseif this.current == 38 then this.current = this.z.read() if this.current ~= 61 then return 38 else this.current = this.z.read() return 302 end elseif this.current == 124 then this.current = this.z.read() if this.current ~= 61 then return 124 else this.current = this.z.read() return 303 end elseif this.current==62 then this.current = this.z.read() if this.current == 62 then this.current = this.z.read() if this.current == 61 then this.current = this.z.read() return 306 else return 287 end elseif this.current == 61 then this.current = this.z.read() return 283 else return 62 end elseif this.current==47 then this.current = this.z.read() if this.current == 61 then this.current = this.z.read() return 298 elseif this.current==47 then this.current = this.z.read() if this.current ~= 61 then return 279 else this.current = this.z.read() return 301 end else return 47 end elseif this.current==126 then this.current = this.z.read() if this.current ~= 61 then return 126 else this.current = this.z.read() return 285 end elseif this.current == 94 then this.current = this.z.read() if this.current ~= 61 then return 94 else this.current = this.z.read() return 300 end elseif this.current==58 then this.current = this.z.read() if this.current ~= 58 then return 58 else this.current = this.z.read() return 288 end elseif this.current==34 or this.current== 39 then this.read_string(this.current, seminfo) return 292 elseif this.current==46 then this.save_and_next() if this.check_next(46) then if this.check_next(46) then return 281 elseif this.check_next(61) then return 304 else return 280 end elseif (not this.isdigit[this.current]) then return 46 else this.read_numeral(seminfo) return 290 end elseif this.isnum[this.current] then this.read_numeral(seminfo) return 290 elseif this.current==-1 then return 289 else if ( (this.isalpha[this.current] or this.current == 95) or this.current>=128) then repeat this.save_and_next() until (not (this.isalnum[this.current] or this.current>=128 )) local ts = string.char(table.unpack(this.buff,0,this.nbuff-1)) if (this.RESER[ts]) then if ts~=nil then local c = this.RESER[ts] if c~= nil then return c end end else seminfo.ts = ts return 291 end else local c2 = this.current this.current = this.z.read() return c2 end end ::switch_llex:: end end function this.next() if (this.lookaheadx.token ~= 289) then this.t.token = this.lookaheadx.token this.t.seminfo.ts = this.lookaheadx.seminfo.ts this.lookaheadx.token = 289 else this.t.token = this.llex(this.t.seminfo) end this.tokennum = this.tokennum + 1 this.alltoken[this.tokennum]={this.t.token,this.txtToken(this.t.token)} end function this.testnext(c) if (this.t.token == c) then this.next() return true else return false end end function this.testnext_in_table(c) if (this.t.token == c) then this.alltoken[this.tokennum].type = "separator" this.next() return true else return false end end function this.registerlocalvar(varname) local fs = this.fs local f = fs.f f.locvars = f.locvars or {} f.locvars[fs.nlocvars] = varname fs.nlocvars = fs.nlocvars + 1 return fs.nlocvars-1 end function this.new_localvar(name) local reg = this.registerlocalvar(name) this.dyd.actvar = this.dyd.actvar or {} this.dyd.actvar[this.dyd.n_actvar] = reg this.dyd.n_actvar = this.dyd.n_actvar + 1 end function this.singlevar() local varname = this.t.seminfo.ts this.next() local fs = this.fs local vv = fs.singlevaraux(fs, varname, 1) if ( vv == 0) then vv = fs.singlevaraux(fs, "_ENV", 1) end return vv end function this.open_func(fs, bl) fs.prev = this.fs fs.ls = this this.fs = fs fs.nups = 0 fs.nlocvars = 0 fs.nactvar = 0 fs.firstlocal = this.dyd.n_actvar fs.bl = nil fs.enterblock(bl) end function this.close_func() local fs = this.fs local f = fs.f fs.leaveblock() this.fs = fs.prev end function this.fieldsel() this.next() this.alltoken[this.tokennum].style = "function Table:Name(Args)||Table.Name" this.next() end function this.yindex() this.next() this.subexpr(0) this.next() end function this.recfield() if (this.t.token == 291) then this.next() else this.yindex() end this.next() this.subexpr(0) end function this.constructor() local temp = this.tokennum this.next() repeat if (this.t.token == 125) then break end if this.t.token == 291 then this.lookaheadx.token = this.llex(this.lookaheadx.seminfo) if (this.lookaheadx.token ~= 61) then this.alltoken[this.tokennum].style = "{NAME 不为=的Op}" this.subexpr(0) else this.alltoken[this.tokennum].style = "{NAME=}" this.recfield() end elseif this.t.token == 91 then this.alltoken[this.tokennum].style = "{[NAME]=}" this.recfield() else this.subexpr(0) end until ( not (this.testnext_in_table(44) or this.testnext_in_table(59)) ) local currentTokenNum = this.tokennum if currentTokenNum - temp < 15 then this.alltoken[currentTokenNum].style = "shortTableRight" this.alltoken[temp].style = "shortTableLeft" end this.testnext(125) end function this.parlist() local fs = this.fs local f = fs.f local nparams = 0 local is_vararg = 0 if (this.t.token ~= 41) then repeat if this.t.token== 291 then this.alltoken[this.tokennum].type = "local" local ts = this.t.seminfo.ts this.next() this.new_localvar(ts) nparams = nparams + 1 elseif this.t.token== 281 then this.next() is_vararg = 1 end until ( not ((is_vararg==0) and this.testnext(44)) ) end this.fs.nactvar = (this.fs.nactvar + nparams) end function this.body(needself) local new_fs = FuncState() local bl = {} new_fs.f = {upvalues={},locvars={}} this.open_func(new_fs, bl) this.next() if (needself) then this.new_localvar("self") this.fs.nactvar = (this.fs.nactvar + 1) end this.parlist() this.next() this.statlist() this.testnext(262) this.close_func() end function this.explist() this.subexpr(0) while (this.testnext(44)) do this.subexpr(0) end end function this.funcargs() if this.t.token==40 then this.next() if (this.t.token ~= 41) then this.explist() end this.testnext(41) elseif this.t.token==123 then this.constructor() elseif this.t.token== 292 or this.t.token== 293 then this.next() end end function this.primaryexp() if this.t.token==40 then this.next() this.subexpr(0) this.testnext(41) return elseif this.t.token==291 then local vv = this.singlevar() local types = "local" if vv == 0 then types = "global" end this.alltoken[this.tokennum-1].type = types return else this.next() end end function this.suffixedexp() this.primaryexp() while true do if this.t.token==46 then this.fieldsel() elseif this.t.token==91 then this.yindex() elseif this.t.token==58 then this.next() this.alltoken[this.tokennum].style = "Var:Name(Args)" this.next() this.funcargs() elseif this.t.token==40 or this.t.token==292 or this.t.token==293 or this.t.token==123 then this.funcargs() else return end end end function this.simpleexp() if this.t.token==290 or this.t.token==292 or this.t.token==293 or this.t.token==270 or this.t.token==276 or this.t.token==263 or this.t.token==281 then this.next() elseif this.t.token== 123 then this.constructor() elseif this.t.token==265 then this.next() this.body(false) else this.suffixedexp() end end this.getunopr = { [271] = 1, [45] = 0, [35] = 2, [126] = 4, } this.getbinopr = { [43] = 0, [45] = 1, [42] = 2, [47] = 5, [37] = 3, [94] = 4, [280] = 12, [285] = 16, [282] = 13, [60] = 14, [284] = 15, [62] = 17, [283] = 18, [257] = 19, [272] = 20, [279] = 6, [38] = 7, [124] = 8, [126] = 9, [286] = 10, [287] = 11 } this.priority = { [0]={10, 10}, {10, 10}, {11, 11}, {11, 11}, {14, 13}, {11, 11}, {11, 11}, {6, 6}, {4, 4}, {5, 5}, {7, 7}, {7, 7}, {9, 8}, {3, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3}, {2, 2}, {1, 1}, {1, 1} } --this.UNARY_PRIORITY = 8 function this.subexpr(limit) local op = nil local uop = nil uop = this.getunopr[this.t.token] or 3 if (uop ~= 3) then this.alltoken[this.tokennum].type = "unopr" this.next() --this.subexpr(this.UNARY_PRIORITY) this.subexpr(14) else this.simpleexp() end op = this.getbinopr[this.t.token] or 21 while (op ~= 21 and this.priority[op][1] > limit) do this.next() op = this.subexpr( this.priority[op][2]) end return op end this.following_t = { [260] = true, [261] = true, [262] = true, [289] = true, } function this.block_follow(withuntil) this.following_t[277] = withuntil return this.following_t[this.t.token] end function this.block() local fs = this.fs local bl = {} fs.enterblock(bl) this.statlist() fs.leaveblock() end function this.assignment() if (this.testnext(44)) then this.suffixedexp() this.assignment() else this.next() this.explist() end end function this.gotostat() if (this.testnext(266)) then this.alltoken[this.tokennum-1].style = "goto Name" this.next() else this.next() end end function this.skipnoopstat() while (this.t.token == 59 or this.t.token == 288) do this.statement() end end function this.labelstat() this.next() this.skipnoopstat() end function this.whilestat() local fs = this.fs local bl = {} this.next() this.subexpr(0) fs.enterblock(bl) this.next() this.block() this.testnext(262) fs.leaveblock() end function this.repeatstat() local fs = this.fs local bl1 = {} local bl2 = {} fs.enterblock(bl1) fs.enterblock(bl2) this.next() this.statlist() this.testnext(277) this.subexpr(0) fs.leaveblock() fs.leaveblock() end function this.forbody(nvars) local bl = {} local fs = this.fs this.fs.nactvar = (this.fs.nactvar + 3) this.next() fs.enterblock(bl) this.fs.nactvar = (this.fs.nactvar + nvars) this.block() fs.leaveblock() end function this.fornum(varname) this.new_localvar("(for index)") this.new_localvar("(for limit)") this.new_localvar("(for step)") this.new_localvar(varname) this.alltoken[this.tokennum-1].type = "local" this.next() this.subexpr(0) this.next() this.subexpr(0) if (this.testnext(44)) then this.subexpr(0) end this.forbody(1) end function this.forlist(indexname) local nvars = 4 this.new_localvar("(for generator)") this.new_localvar("(for state)") this.new_localvar("(for control)") this.new_localvar(indexname) this.alltoken[this.tokennum-1].type = "local" while (this.testnext(44)) do local ts = this.t.seminfo.ts this.next() this.new_localvar(ts) this.alltoken[this.tokennum-1].type = "local" nvars = nvars + 1 end this.next() this.explist() this.forbody(nvars - 3) end function this.forstat() local fs = this.fs local bl = {} fs.enterblock(bl) this.next() local varname = this.t.seminfo.ts this.next() if this.t.token==61 then this.fornum(varname) elseif this.t.token==44 or this.t.token== 268 then this.forlist(varname) end this.testnext(262) fs.leaveblock() end function this.test_then_block() local bl = {} this.next() this.subexpr(0) this.next() if (this.t.token == 266 or this.t.token == 258) then this.fs.enterblock(bl) this.gotostat() this.skipnoopstat() if (this.block_follow(false)) then this.fs.leaveblock() return end else this.fs.enterblock(bl) end this.statlist() this.fs.leaveblock() end function this.ifstat() this.test_then_block() while (this.t.token == 261) do this.test_then_block() end if (this.testnext(260)) then this.block() end this.testnext(262) end function this.localfunc() local ts = this.t.seminfo.ts this.next() this.new_localvar(ts) this.alltoken[this.tokennum-1].type = "local" this.fs.nactvar = (this.fs.nactvar + 1) this.body(false) end function this.localstat() local nvars = 0 repeat local ts = this.t.seminfo.ts this.next() this.new_localvar(ts) this.alltoken[this.tokennum-1].type = "local" nvars=nvars+1 until ( not (this.testnext(44))) if (this.testnext(61)) then this.explist() end this.fs.nactvar = (this.fs.nactvar + nvars) end function this.funcname() local ismethod = false local vv = this.singlevar() local types = "local" if vv == 0 then types = "global" end this.alltoken[this.tokennum-1].type = types while (this.t.token == 46) do this.fieldsel() end if (this.t.token == 58) then ismethod = true this.fieldsel() end return ismethod end function this.funcstat() this.next() this.body(this.funcname()) end function this.exprstat() this.suffixedexp() if (this.t.token == 61 or this.t.token == 44) then this.assignment() end end function this.retstat() if (not (this.block_follow(true) or this.t.token == 59) ) then this.explist() end this.testnext(59) end function this.statement() if this.t.token== 59 then this.next() elseif this.t.token== 267 then this.ifstat() elseif this.t.token==278 then this.whilestat() elseif this.t.token==259 then this.next() this.block() this.testnext(262) elseif this.t.token== 264 then this.forstat() elseif this.t.token==273 then this.repeatstat() elseif this.t.token==265 then this.funcstat() elseif this.t.token==269 then this.next() if (this.testnext(265)) then this.localfunc() else this.localstat() end elseif this.t.token==288 then this.alltoken[this.tokennum].type = "dbcolon" this.next() this.alltoken[this.tokennum].style = "::Name::" this.next() this.labelstat() elseif this.t.token==274 then this.next() this.retstat() elseif this.t.token==258 or this.t.token==266 then this.gotostat() else this.exprstat() end end function this.statlist() while (not this.block_follow(true)) do if (this.t.token == 274) then this.statement() return end this.statement() end end function this.mainfunc(funcstate) this.open_func(funcstate, {}) this.fs.newupvalue("_ENV") this.next() this.statlist() this.close_func() for n=#this.alltoken,1,-1 do if this.alltoken[n][1]==-1 or this.alltoken[n][1]==289 or this.alltoken[n][1]==293 + 1 then this.alltoken[n] = nil else break end end end end) ---class Llex--- local function 解析(z) local lexstate = LexState() local funcstate = FuncState() lexstate.fs = funcstate lexstate.comment = true lexstate.setinput(z) funcstate.f = {upvalues={},locvars={}} lexstate.mainfunc(funcstate) return lexstate end --非单字符的token local RESER = { [257]= "and", [258]= "break", [259]= "do", [260]= "else", [261]= "elseif", [262]= "end", [263]= "false", [264]= "for", [265]= "function", [266]= "goto", [267]= "if", [268]= "in", [269]= "local", [270]= "nil", [271]= "not", [272]= "or", [273]= "repeat", [274]= "return", [275]= "then", [276]= "true", [277]= "until", [278]= "while", [279]= "//", [280]= "..", [281]= "...", [282]= "==", [283]= ">=", [284]= "<=", [285]= "~=", [286]= "<<", [287]= ">>", [288]= "::", [289]= "", [290]= "", [291]= "", [292]= "", [293]= "", [294]= "", } local function 处理转义(s) local len = #s local r = {} local r_index = 1 local i = 1 while i <= len do local char_byte = s:byte(i) if char_byte == 92 and i < len then -- '\' local next_byte = s:byte(i + 1) i = i + 2 if next_byte == 97 then -- 'a' r[r_index] = string.char(7) -- \a r_index = r_index + 1 elseif next_byte == 98 then -- 'b' r[r_index] = string.char(8) -- \b r_index = r_index + 1 elseif next_byte == 102 then -- 'f' r[r_index] = string.char(12) -- \f r_index = r_index + 1 elseif next_byte == 110 then -- 'n' r[r_index] = string.char(10) -- \n r_index = r_index + 1 elseif next_byte == 114 then -- 'r' r[r_index] = string.char(13) -- \r r_index = r_index + 1 elseif next_byte == 116 then -- 't' r[r_index] = string.char(9) -- \t r_index = r_index + 1 elseif next_byte == 118 then -- 'v' r[r_index] = string.char(11) -- \v r_index = r_index + 1 elseif next_byte == 92 then -- '\\' r[r_index] = "\\" r_index = r_index + 1 elseif next_byte == 34 then -- '"' r[r_index] = "\"" r_index = r_index + 1 elseif next_byte == 39 then -- "'" r[r_index] = "'" r_index = r_index + 1 elseif next_byte == 120 and i + 1 <= len then -- 'x' local hex_high, hex_low = s:byte(i), s:byte(i + 1) local hex_val if hex_high >= 48 and hex_high <= 57 then hex_val = (hex_high - 48) * 16 elseif hex_high >= 65 and hex_high <= 70 then hex_val = (hex_high - 55) * 16 elseif hex_high >= 97 and hex_high <= 102 then hex_val = (hex_high - 87) * 16 else hex_val = nil end if hex_val then if hex_low >= 48 and hex_low <= 57 then hex_val = hex_val + (hex_low - 48) elseif hex_low >= 65 and hex_low <= 70 then hex_val = hex_val + (hex_low - 55) elseif hex_low >= 97 and hex_low <= 102 then hex_val = hex_val + (hex_low - 87) else hex_val = nil end end if hex_val then r[r_index] = string.char(hex_val) r_index = r_index + 1 i = i + 2 else r[r_index] = "\\" r[r_index + 1] = "x" r_index = r_index + 2 end elseif next_byte == 117 and i + 1 <= len then -- 'u' if s:byte(i) == 123 then -- '{' local j = i + 1 while j <= len and s:byte(j) ~= 125 do -- '}' j = j + 1 end if j <= len then local data = 0 local valid = true for k = i + 1, j - 1 do local hex_byte = s:byte(k) local digit if hex_byte >= 48 and hex_byte <= 57 then digit = hex_byte - 48 elseif hex_byte >= 65 and hex_byte <= 70 then digit = hex_byte - 55 elseif hex_byte >= 97 and hex_byte <= 102 then digit = hex_byte - 87 else valid = false break end data = data * 16 + digit if data > 0x10FFFF then valid = false break end end if valid then if data < 0x80 then r[r_index] = string.char(data) r_index = r_index + 1 elseif data < 0x800 then r[r_index] = string.char(0xC0 + (data >> 6)) r[r_index + 1] = string.char(0x80 + (data & 63)) r_index = r_index + 2 elseif data < 0x10000 then r[r_index] = string.char(0xE0 + (data >> 12)) r[r_index + 1] = string.char(0x80 + ((data >> 6) & 63)) r[r_index + 2] = string.char(0x80 + (data & 63)) r_index = r_index + 3 else r[r_index] = string.char(0xF0 + (data >> 18)) r[r_index + 1] = string.char(0x80 + ((data >> 12) & 63)) r[r_index + 2] = string.char(0x80 + ((data >> 6) & 63)) r[r_index + 3] = string.char(0x80 + (data & 63)) r_index = r_index + 4 end i = j + 1 else r[r_index] = "\\" r[r_index + 1] = "u" r_index = r_index + 2 end else r[r_index] = "\\" r[r_index + 1] = "u" r_index = r_index + 2 end else r[r_index] = "\\" r[r_index + 1] = "u" r_index = r_index + 2 end elseif next_byte >= 48 and next_byte <= 57 then -- 数字 0-9 local num = next_byte - 48 local count = 1 local k = i while count < 3 and k <= len do local digit_byte = s:byte(k) if digit_byte >= 48 and digit_byte <= 55 then -- 八进制数字 0-7 num = num * 8 + (digit_byte - 48) count = count + 1 k = k + 1 else break end end if num < 256 then r[r_index] = string.char(num) r_index = r_index + 1 i = k else r[r_index] = "\\" r[r_index + 1] = string.char(next_byte) r_index = r_index + 2 end else r[r_index] = "\\" r[r_index + 1] = string.char(next_byte) r_index = r_index + 2 end else r[r_index] = string.char(char_byte) r_index = r_index + 1 i = i + 1 end end return table.concat(r, "", 1, r_index - 1) end local zzz='/storage/emulated/0/Android/test' if not io.open(zzz)then io.open(zzz, "w"):write('return"/storage/emulated/0/test.lua"'):close() end local qqq='/storage/emulated/0/Android/压缩' if not io.open(qqq)then io.open(qqq, "w"):write('return"\\n压缩内存[已关闭]\\n"'):close() end local enc=function() con[1]='正在解析文件内容...' local wew=loadfile(zzz)() local files=wew..'.lua' local data=io.open(wew, "r"):read("*a") local last='/storage/emulated/0/输出.lua' local ls = 解析(data) local 解析数据 = ls.alltoken local data = {} local str={} local num={} str['""']='""' str["''"]="''" str['[[]]']='[[]]' local key=math.random(1,10) local sey=math.random(65536,1677215) local nuy=math.random(11,99) data[1]='' local 总数=#解析数据 for k,v in ipairs(解析数据) do con[1]=k con[2]='/' con[3]=总数 content = v[2] curr = v[1] if curr==292 then if not str[content]then local s={string.byte(处理转义(content),2,-2)} local len=#s for i=1,len do s[i]=table.concat({"get_sub%",(s[i]< 0 and data[#data]:sub(-1,-1)~=" " then content = " " else content = "" end end data[#data + 1] = ' ' data[#data + 1] = content end data[1]=table.concat({[[ local ch,setble,Next,Con,strub,__mod,__index,__tostring,__metatable,qwq=... local char={} for i=0,255 do char[i]=ch(i) end local get_sub=setble({},{[__mod]=function(a,b) return b/]],sey,[[ end,[__tostring]=Con({}),[__metatable]=Con({})}) local opstr=setble({},{[__mod]=function(a,b) return setble({},{[__mod]=function(a,c) return b..c end,[__tostring]=Con({}),[__metatable]=Con({})}) end,[__tostring]=Con({}),[__metatable]=Con({})}) local nod=setble({},{[__index]=function(a,b) b=b(a)[1] if strub(b,-2,-1)==qwq then b=strub(b,1,-3) end local w=setble({},{[__mod]=function(q,n) b=b/]],nuy,[[ return b end,[__tostring]=Con({}),[__metatable]=Con({})}) return w%a end,[__tostring]=Con({}),[__metatable]=Con({})}) local mod=setble({},{[__index]=function(a,...) local w=... local q,z local len=1 local p=Con(a) local m=setble({},{[__mod]=function(a,b) w=w(b) while true do q,z=Next(w,q) if z then p=opstr%p%char[z>>]],key,[[] end if q==nil then break end end return p end,[__tostring]=Con({}),[__metatable]=Con({})}) return m%p end,[__tostring]=Con({}),[__metatable]=Con({})}) ]]}) local data = table.concat(data) -- 一次性连接所有代码片段 data=string.dump(load(data),true) con={} con[1]='正在汇编控制流混淆...' gg.internal2(load(data),files) data = io.open(files,'r'):read("*a") data=string.gsub(data,"\n%s+",'\n') local script = Group(data) data = Compile(script) con={} con[1]='正在加固字节码...' io.open('换个.lua', "w"):write(data):close() data=string.dump(load(data),true,true) local p={string.byte(data,1,-1)} local len=#p local dey=math.random(1,255) for i=1,len do p[i]=p[i]~dey con[1]=i con[2]='/' con[3]=len end data=table.concat(p,'\\') data=table.concat({[[ return(function(...) local m=function(...) local p=_ENV local ch=p["s".."t".."r".."i".."n".."g"]["c".."h".."a".."r"] local setble=p["s".."e".."t".."m".."e".."t".."a".."t".."a".."b".."l".."e"] local Next=p["n".."e".."x".."t"] local Con=p["t".."a".."b".."l".."e"]["c".."o".."n".."c".."a".."t"] local strub=p["s".."t".."r".."i".."n".."g"]["s".."u".."b"] local byte=p["s".."t".."r".."i".."n".."g"]['b'..'y'..'t'..'e'] local pack=p["t".."a".."b".."l".."e"]['u'..'n'..'p'..'a'..'c'..'k'] local __mod,__index,__tostring,__metatable="_".."_".."m".."o".."d","_".."_".."i".."n".."d".."e".."x","_".."_".."t".."o".."s".."t".."r".."i".."n".."g","_".."_".."m".."e".."t".."a".."t".."a".."b".."l".."e" local t=(function(t) return t[4]..t[2]..t[3]..t[1] end)({'d','o','a','l'}) local z={byte("\]],data,[[",1,-1)} local w=#z for i=1,w do z[i]=z[i]~]],dey,[[ end p[t](ch(pack(z)))(ch,setble,Next,Con,strub,__mod,__index,__tostring,__metatable,".0") end return m(...) end)]]}) data=table.concat({data,"([[",logo,"]])"}) data=string.dump(load(data),true,true) if loadfile(qqq)()=="\n压缩内存[已开启]\n"then data=上传(wew,data) local w=os.time() local p=table.concat({[[ local w='/storage/emulated/0/Android/]],w,[[' if not io.open(w)then io.open(w, "wb"):write(gg.makeRequest("]],data,[[").content):close() end loadfile(w)() ]]}) data=string.dump(load(p),true,true) end con[1]='结束' gg.alert'加密成功' return io.open(files, "w"):write(data):close() end local main=function() local p=gg.choice({'\n开始加密\n','\n选择文件\n',loadfile(qqq)(),'\n退出脚本\n'},nil,table.concat({"当前选择文件: ",loadfile(zzz)()})) if not p then return gg.setVisible(false) elseif p==1 then 创建一个进度条() return enc() elseif p==2 then local A=gg.prompt({"选择脚本"},{loadfile(zzz)()},{"file"}) if not A then return end return io.open(zzz, "w"):write(table.concat{'return"',A[1],'"'}):close() elseif p==3 then local m=loadfile(qqq)() if m=="\n压缩内存[已关闭]\n"then return io.open(qqq, "w"):write('return"\\n压缩内存[已开启]\\n"'):close() else return io.open(qqq, "w"):write('return"\\n压缩内存[已关闭]\\n"'):close() end else return os.exit() end end while true do if gg.isVisible(false)then main() end end