-
Notifications
You must be signed in to change notification settings - Fork 191
Better Antitamper, EncStrings & Wrapinfunction #225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,8 +89,11 @@ function AntiTamper:apply(ast, pipeline) | |
| local code = generateSanityCheck() | ||
| if self.UseDebug then | ||
| local string = RandomStrings.randomString() | ||
| local timeCheckThreshold = math.random(50, 200) / 1000 | ||
| code = code | ||
| .. [[ | ||
| local startTime = os.clock and os.clock() or os.time(); | ||
|
|
||
| -- Anti Beautify | ||
| local sethook = debug and debug.sethook or function() end; | ||
| local allowedLine = nil; | ||
|
|
@@ -151,6 +154,11 @@ function AntiTamper:apply(ast, pipeline) | |
| c = c + 1; | ||
| end | ||
| valid = valid and c >= 2; | ||
|
|
||
| local elapsedTime = (os.clock and os.clock() or os.time()) - startTime; | ||
| if elapsedTime > ]] .. tostring(timeCheckThreshold) .. [[ then | ||
| valid = false; | ||
| end | ||
| ]] | ||
| end | ||
| code = code .. [[ | ||
|
|
@@ -202,6 +210,16 @@ function AntiTamper:apply(ast, pipeline) | |
| end | ||
| valid = valid and acc1 == acc2; | ||
|
|
||
| local containerFuncCheck = pcall(function() | ||
| local testFunc = function() end; | ||
| if debug and debug.getinfo then | ||
| local info = debug.getinfo(testFunc); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be guarded by self.UseDebug. Then it should be made to fail, if debug is not available |
||
| if info.what ~= "Lua" then | ||
| valid = false; | ||
| end | ||
| end | ||
| end); | ||
|
|
||
| if valid then else | ||
| repeat | ||
| return (function() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,19 +25,53 @@ WrapInFunction.SettingsDescriptor = { | |
|
|
||
| function WrapInFunction:init(_) end | ||
|
|
||
| local function createWrapper(scope, body, mode) | ||
| if mode == 1 then | ||
| return Ast.Block({ | ||
| Ast.ReturnStatement({ | ||
| Ast.FunctionCallExpression( | ||
| Ast.FunctionLiteralExpression({Ast.VarargExpression()}, body), | ||
| {Ast.VarargExpression()} | ||
| ) | ||
| }) | ||
| }, scope) | ||
|
|
||
| elseif mode == 2 then | ||
| local f = scope:addVariable() | ||
| return Ast.Block({ | ||
| Ast.LocalVariableDeclaration(scope, {f}, { | ||
| Ast.FunctionLiteralExpression({Ast.VarargExpression()}, body) | ||
| }), | ||
| Ast.ReturnStatement({ | ||
| Ast.FunctionCallExpression( | ||
| Ast.VariableExpression(scope, f), | ||
| {Ast.VarargExpression()} | ||
| ) | ||
| }) | ||
| }, scope) | ||
|
|
||
| else | ||
| return Ast.Block({ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same as mode 1. I like the Idea of having multiple modes, but the third one should be removed
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can edit it a bit if you want, for me this just worked better so yea |
||
| Ast.ReturnStatement({ | ||
| Ast.FunctionCallExpression( | ||
| Ast.FunctionLiteralExpression({Ast.VarargExpression()}, body), | ||
| {Ast.VarargExpression()} | ||
| ) | ||
| }) | ||
| }, scope) | ||
| end | ||
| end | ||
|
|
||
| function WrapInFunction:apply(ast) | ||
| for i = 1, self.Iterations, 1 do | ||
| local body = ast.body; | ||
| local body = ast.body | ||
| local scope = Scope:new(ast.globalScope) | ||
| body.scope:setParent(scope) | ||
|
|
||
| local scope = Scope:new(ast.globalScope); | ||
| body.scope:setParent(scope); | ||
| local mode = math.random(1, 3) | ||
|
|
||
| ast.body = Ast.Block({ | ||
| Ast.ReturnStatement({ | ||
| Ast.FunctionCallExpression(Ast.FunctionLiteralExpression({Ast.VarargExpression()}, body), {Ast.VarargExpression()}) | ||
| }); | ||
| }, scope); | ||
| ast.body = createWrapper(scope, body, mode) | ||
| end | ||
| end | ||
|
|
||
| return WrapInFunction; | ||
| return WrapInFunction; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure, whether checking elapsed time is a good idea. If the obfuscated script runs, while the computer is doing other heavy calculations (e.g. a Game), the script might overflow the threshold, even though there was no tamper