4

I dont use lua and I tried to search on internet, what this do:

assert`(load(Base64Decode(==BASE64 Script but is not Encoded like usualy==), nil, "bt", _ENV))().`

Every encoded message starts with G0x........==. I tried mathematical decoding but I can`t do anything.

So, any help?

β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
ChrystianSandu
  • 73
  • 1
  • 1
  • 9
  • perhaps, provide more information? Which module is providing the `Base64Decode` function? – hjpotter92 Jan 05 '16 at 18:51
  • @hjpotter92, this is only think in that file. Nothing more :( – ChrystianSandu Jan 05 '16 at 18:58
  • What do you mean "not Encoded like usualy"? Where did these scripts come from? What are these scripts supposed to be run by? The standard lua interpreter? Some game? – Etan Reisner Jan 05 '16 at 19:49
  • Example of "[usual decoder](https://eval.in/497832)" in pure Lua. By the way, starting with `G0x` means that is Lua bytecode: "\27Lua" – Egor Skriptunoff Jan 05 '16 at 20:01
  • I tried everything I can and i understand, but none of my decryption methode was good... :( Assert is only a verify script, nothing more, load = load file, but i don`t understand what happen in Base64Decode.... – ChrystianSandu Jan 05 '16 at 20:35
  • Now I remember something, one of code from GitHub was in ASCII, until I opened it, then transform in Base64E,on Google Search Page all codes are in Ascii, so, GitHub can decrypt it and search after "key words". But only this. :( – ChrystianSandu Jan 05 '16 at 20:40
  • @hjpotter92, that function is from an .exe, – ChrystianSandu Jan 05 '16 at 21:03

1 Answers1

12

Easily found a solution googling it up. Making much questions in a row may lead to a temporal "Ask Disable", where you can't ask anything. We could need more information, but, by the title I suppose you want to Encode and Decode from Base64. Source: lua-users wiki: Base64:

local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -- You will need this for encoding/decoding
-- encoding
function enc(data)
    return ((data:gsub('.', function(x) 
        local r,b='',x:byte()
        for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
        return r;
    end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
        if (#x < 6) then return '' end
        local c=0
        for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
        return b:sub(c+1,c+1)
    end)..({ '', '==', '=' })[#data%3+1])
end

-- decoding
function dec(data)
    data = string.gsub(data, '[^'..b..'=]', '')
    return (data:gsub('.', function(x)
        if (x == '=') then return '' end
        local r,f='',(b:find(x)-1)
        for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
        return r;
    end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
        if (#x ~= 8) then return '' end
        local c=0
        for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
            return string.char(c)
    end))
end

This should help. ~TheCrimulo

TheCrimulo
  • 433
  • 1
  • 4
  • 14
  • 1
    This answer does not appear to be an answer to the question "what does this code snippet do", but instead seems to be going purely off an assumption made by reading the question title. – Dewi Morgan Jan 01 '21 at 19:43
  • It's worth noting that this code snippet is **licensed under the terms of the LGPL2**. You may not want to use it in certain situations. – ipid Aug 24 '21 at 08:52