efrederickson/XFuscator

Incorrect work with random seed

Opened this issue · 0 comments

XFuscator/Step2.lua loses precision of the number which is used as random seed.
This number is created at line 5 and is used at line 12 as-is (with full double precision of 17 digits), while only 14 of its digits (that's the default Lua number format) are saved into obfuscated file on line 6. This inconsistency sometimes leads to different pseudorandom sequence (and hence wrong deobfuscating), the error attempt to call a nil value is raised when trying to run obfuscated program.

BTW, not all Lua implementations are sensitive to fractional part of a number given as an argument to math.randomseed(); for example, PUC Lua simply ignores fractional part, only low 32-bits of integer part are accepted as seed (unfortunately, Lua manual keeps silence about that). So, it is better for the seed to be an integer.

How to fix the error:
Replace line 5

local __X = math.random()

with the following line:

local __X = math.random(1, 9^9)