prometheus-lua / Prometheus

Lua Obfuscator written in pure Lua
https://levno-710.gitbook.io/prometheus/
GNU Affero General Public License v3.0
202 stars 60 forks source link

[BUG] Unresolved Upvalue in LibDeflate.lua #162

Open sreisjr opened 5 months ago

sreisjr commented 5 months ago

Describe the bug I was testing against https://github.com/SafeteeWoW/LibDeflate/blob/main/LibDeflate.lua and it failed.

To Reproduce .\prometheus.exe --out .\LibDeflate_Obfuscated.lua --preset Medium .\LibDeflate.lua

PROMETHEUS: Applying Obfuscation Pipeline to .\LibDeflate.lua ... PROMETHEUS: Parsing ... PROMETHEUS: Parsing Done in 0.21 seconds PROMETHEUS: Applying Step "Encrypt Strings" ... PROMETHEUS: Step "Encrypt Strings" Done in 0.02 seconds PROMETHEUS: Applying Step "Anti Tamper" ... PROMETHEUS: Step "Anti Tamper" Done in 0.01 seconds PROMETHEUS: Applying Step "Vmify" ... PROMETHEUS: Unresolved Upvalue, this error should not occur!

Zaenalos commented 4 months ago

Try to remove anti tamper sir.

9382 commented 2 months ago

Anti tamper isnt the issue here. The VM is unable to handle certain repeat untils since it doesn't correctly handle how locals work in them. Any local defined during the repeat's body can be referenced in the until even if it wasn't defined before the repeat Take the following code:

local i = 0
repeat
    local x = 5
    i = i + 1
until x == 5 or i >= 3

if i >= 3 or x ~= nil then
    error("Incorrectly handled repeat until")
else
    print("Repeat went just fine")
end

The x in the repeat can be called in the until block, even though it never previously existed. The VM seems to not support this case, and throws an error about upvalues if you attempt to VMify this code. Interestingly enough, minifying seems to handle just fine with this situation, so there's clearly some part of this code which can already handle this