Skip to content

Add rule to obfuscate control-flow #326

@jeparlefrancais

Description

@jeparlefrancais

Sponsor this specific issue! https://ko-fi.com/c/b4839c7924


Add a new darklua rule that performs control-flow obfuscation on Lua/Luau code while preserving the original runtime behavior. I have a working prototype I'd like to improve and complete.

The goal of this rule is to take a sequential block of code and turn it into a new block of that seems out of order.

Control‑flow obfuscation is a code‑transformation technique that keeps the program’s behavior the same while making the execution path harder to follow. It does this by rearranging how code executes at runtime so that the logic is more difficult to analyze, without changing what the code actually does.

As a concrete example, the current prototype I have is able to start from this code:

print('start')
print(1)
print(2)

Into this code

do
	local __darklua_loop_index = -1910019717
	while true do
		if __darklua_loop_index == -1154859086 then
			print(1)
			__darklua_loop_index = __darklua_loop_index + 302133197
		else
			if __darklua_loop_index == -1910019717 then
				print("start")
				__darklua_loop_index = __darklua_loop_index + 755160631
			else
				if __darklua_loop_index == -852725889 then
					do
						print(2)
						break
					end
				end
			end
		end
	end
end

To complete the work, I want to add other transformation strategies that can be picked semi-randomly when processing a code block.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions