Automate Lua virtualization and obfuscation via the Web API. Dialect auto-detection covers Lua 5.1–5.5 and Luau, and demo mode uses only flat code virtualization.
You can use all of the features of Lua Virtualizer via our Web API interface. The Web API is based on POST requests and emits JSON encoded responses. The endpoint is POST https://www.pelock.com/api/lua-virtualizer/v1.
The same features are also available through a REST interface. GET /api/lua-virtualizer/v1/license checks the activation key. POST /api/lua-virtualizer/v1/virtualize virtualizes a script. POST /api/lua-virtualizer/v1/obfuscate obfuscates a script with the same file contract. Send the key as Authorization: Bearer or X-Api-Key. Upload the script as a multipart file part named file, with the same strategy field names as the POST API. A successful call returns the script bytes as obfuscated.lua. Status and license fields come back in the X-PELock-Result header. REST does not accept compression or a source string.
For faster deployment, installation packages for the Lua Virtualizer Web API have been uploaded to popular repositories (PyPI, Packagist, npm, crates.io, NuGet, PowerShell Gallery, pkg.go.dev, Maven, RubyGems). Source code has also been published on GitHub:
| Repository | Language | Installation | Package | Sources |
|---|---|---|---|---|
![]() |
Python | pip install lua-virtualizer |
PyPI | GitHub |
![]() |
PHP | Run:
or add the following to |
Packagist | GitHub |
![]() |
JavaScript | Run:
or add the following to |
npm | GitHub |
![]() |
Rust | Run:
or add the following to |
Crates | GitHub |
![]() |
C# | Run:
or add to your |
NuGet | GitHub |
![]() |
PowerShell | Run:
or:
|
PowerShell Gallery | GitHub |
![]() |
Go | Run:
or add the following to your |
Go | GitHub |
![]() |
Java | Add this dependency to your pom.xml |
Maven | GitHub |
![]() |
Ruby | Run:
or add the following to your |
RubyGems | GitHub |
#!/usr/bin/env python
###############################################################################
#
# Lua Virtualizer WebApi interface usage example.
#
# In this example we will obfuscate sample source with default options.
#
# Version : v1.0.0
# Language : Python
# Author : Bartosz Wójcik
# Web page : https://www.pelock.com
#
###############################################################################
#
# include Lua Virtualizer module
#
from luavirtualizer import LuaVirtualizer
#
# if you don't want to use Python module, you can import directly from the file
#
#from pelock.luavirtualizer import LuaVirtualizer
#
# create Lua Virtualizer class instance (we are using our activation key)
#
myLuaVirtualizer = LuaVirtualizer("ABCD-ABCD-ABCD-ABCD")
#
# source code in Lua format
#
scriptSourceCode = """local function greet(name)
print("Hello, " .. name)
end
greet("Lua")
"""
#
# by default all obfuscation options are enabled, so we can just simply call
#
result = myLuaVirtualizer.virtualize_script_source(scriptSourceCode)
#
# it's also possible to pass a Lua script file path instead of a string with the source e.g.
#
# result = myLuaVirtualizer.virtualize_script_file("/path/to/project/script.lua")
#
# result[] array holds the obfuscation results as well as other information
#
# result["error"] - error code
# result["output"] - obfuscated code
# result["demo"] - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
# result["license_expiration"] - license end date (Y-m-d), empty if none
# result["usages_total"] - total obfuscations for this activation code
#
if result and "error" in result:
# display obfuscated code
if result["error"] == LuaVirtualizer.ERROR_SUCCESS:
# format output code for HTML display
print(result["output"])
else:
print(f'An error occurred, error code: {result["error"]}')
else:
print("Something unexpected happen while trying to obfuscate the code.")
<?php
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* In this example we will obfuscate sample source with default options.
*
* Version : v1.0
* Language : PHP
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
//
// include Lua Virtualizer class
//
use PELock\LuaVirtualizer\LuaVirtualizer;
//
// if you don't want to use Composer use include_once
//
//include_once "LuaVirtualizer.php";
//
// create Lua Virtualizer class instance (we are using our activation key)
//
$myLuaVirtualizer = new LuaVirtualizer("ABCD-ABCD-ABCD-ABCD");
//
// source code in Lua format
//
$scriptSourceCode = "local function greet(name)
print("Hello, " .. name)
end
greet("Lua")
";
//
// by default all obfuscation options are enabled, so we can just simply call:
//
$result = $myLuaVirtualizer->VirtualizeScriptSource($scriptSourceCode);
//
// it's also possible to pass a Lua script file path instead of a string e.g.
//
// $result = $myLuaVirtualizer->VirtualizeScriptFile("/path/to/project/script.lua");
//
// $result[] array holds the obfuscation results as well as other information
//
// $result["error"] - error code
// $result["output"] - obfuscated code
// $result["demo"] - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
// $result["license_expiration"] - license end date (Y-m-d), empty if none
// $result["usages_total"] - total obfuscations for this activation code
//
if ($result !== false)
{
// display obfuscated code
if ($result["error"] === \PELock\LuaVirtualizer::ERROR_SUCCESS)
{
// format output code for HTML display
echo "<pre>" . htmlentities($result["output"]) . "</pre>";
}
else
{
die("An error occurred, error code: " . $result["error"]);
}
}
else
{
die("Something unexpected happen while trying to obfuscate the code.");
}
?>
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* In this example we will obfuscate sample source with default options.
*
* Version : v1.0.0
* Language : JavaScript
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
import LuaVirtualizer from "lua-virtualizer";
//
// include Lua Virtualizer class
//
//
// when developing from a repository clone without installing the package use:
//
// import LuaVirtualizer from "../src/lua-virtualizer.js";
//
// create Lua Virtualizer class instance (we are using our activation key)
//
const myLuaVirtualizer = new LuaVirtualizer("ABCD-ABCD-ABCD-ABCD");
//
// source code in Lua format
//
const scriptSourceCode = `local function greet(name)
print("Hello, " .. name)
end
greet("Lua")
`;
//
// by default all obfuscation options are enabled, so we can just simply call:
//
const result = await myLuaVirtualizer.virtualizeScriptSource(scriptSourceCode);
//
// it's also possible to pass a Lua script file path instead of a string e.g.
//
// const result = await myLuaVirtualizer.virtualizeScriptFile("/path/to/project/script.lua");
//
// result object holds the obfuscation results as well as other information
//
// result.error - error code
// result.output - obfuscated code
// result.demo - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
// result.license_expiration - license end date (Y-m-d), empty if none
// result.usages_total - total obfuscations for this activation code
//
if (result !== null) {
//
// display obfuscated code
//
if (result.error === LuaVirtualizer.ERROR_SUCCESS) {
console.log(result.output);
} else {
throw new Error("An error occurred, error code: " + result.error);
}
} else {
throw new Error("Something unexpected happen while trying to obfuscate the code.");
}
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* In this example we will obfuscate sample source with default options.
*
* Version : v1.0.0
* Language : Rust
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
use lua_virtualizer::{LuaVirtualizer, LuaVirtualizerResponse};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
//
// include Lua Virtualizer class
//
//
// when developing from a repository clone without installing the package use:
//
// use lua_virtualizer::{LuaVirtualizer, LuaVirtualizerResponse};
// (path dependency in Cargo.toml pointing to this crate)
//
// create Lua Virtualizer class instance (we are using our activation key)
//
let my_lua_virtualizer =
LuaVirtualizer::new(Some("ABCD-ABCD-ABCD-ABCD".to_string()));
//
// source code in Lua format
//
let script_source_code = r#"local function greet(name)
print("Hello, " .. name)
end
greet("Lua")"#;
//
// by default all obfuscation options are enabled, so we can just simply call:
//
let result = my_lua_virtualizer
.virtualize_script_source(script_source_code, true)
.await;
//
// it's also possible to pass a Lua script file path instead of a string e.g.
//
// let result = my_lua_virtualizer
// .virtualize_script_file(std::path::Path::new("/path/to/project/script.lua"), true)
// .await;
//
// result object holds the obfuscation results as well as other information
//
// result.error - error code
// result.output - obfuscated code
// result.demo - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
// result.license_expiration - license end date (Y-m-d), empty if none
// result.usages_total - total obfuscations for this activation code
//
match result {
Some(LuaVirtualizerResponse::Object(obj)) => {
//
// display obfuscated code
//
if obj.error == LuaVirtualizer::ERROR_SUCCESS {
println!("{}", obj.output.unwrap_or_default());
} else {
return Err(
format!("An error occurred, error code: {}", obj.error).into(),
);
}
}
Some(LuaVirtualizerResponse::Json(_)) => {}
None => {
return Err("Something unexpected happen while trying to obfuscate the code.".into());
}
}
Ok(())
}
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* In this example we will obfuscate sample source with default options.
*
* Version : v1.0.0
* Language : C#
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
using PELock.LuaVirtualizer;
//
// create Lua Virtualizer class instance (we are using our activation key)
//
var myLuaVirtualizer = new LuaVirtualizer("ABCD-ABCD-ABCD-ABCD");
//
// source code in Lua format
//
const string ScriptSourceCode =
"""
local function greet(name)
print("Hello, " .. name)
end
greet("Lua")
""";
//
// by default all obfuscation options are enabled, so we can just simply call:
//
var result = await myLuaVirtualizer.VirtualizeScriptSourceAsync(ScriptSourceCode);
//
// it's also possible to pass a Lua script file path instead of a string e.g.
//
// var result = await myLuaVirtualizer.VirtualizeScriptFileAsync("/path/to/project/script.lua");
//
// result object holds the obfuscation results as well as other information
//
// result?.Error - error code (see LuaVirtualizer.Error*)
// result?.Output - obfuscated code
// result?.Demo - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
// result?.LicenseExpiration - license end date (Y-m-d), empty if none
// result?.UsagesTotal - total obfuscations for this activation code
//
if (result is not null)
{
//
// display obfuscated code
//
if (result.Error == LuaVirtualizer.ErrorSuccess && result.Output is not null)
Console.WriteLine(result.Output);
else
throw new InvalidOperationException("An error occurred, error code: " + result.Error);
}
else
{
throw new InvalidOperationException("Something unexpected happen while trying to obfuscate the code.");
}
################################################################################
#
# Lua Virtualizer WebApi interface usage example.
#
# In this example we will obfuscate sample source with default options.
#
# Version : v1.0.0
# Language : PowerShell
# Author : Bartosz Wójcik
# Web page : https://www.pelock.com
#
################################################################################
#
# include Lua Virtualizer module
#
# After Install-Module / Install-PSResource:
# using module LuaVirtualizer
#
using module '..\luavirtualizer\LuaVirtualizer.psd1'
#
# create Lua Virtualizer class instance (we are using our activation key)
#
$myLuaVirtualizer = [LuaVirtualizer]::new('ABCD-ABCD-ABCD-ABCD')
#
# source code in Lua format
#
$scriptSourceCode = @'
local function greet(name)
print("Hello, " .. name)
end
greet("Lua")
'@
#
# by default all obfuscation options are enabled, so we can just simply call
#
$result = $myLuaVirtualizer.VirtualizeScriptSource($scriptSourceCode)
#
# it's also possible to pass a Lua script file path instead of a string with the source e.g.
#
# $result = $myLuaVirtualizer.VirtualizeScriptFile('/path/to/project/script.lua')
#
# $result holds the obfuscation results as well as other information
#
# $result.error - error code
# $result.output - obfuscated code
# $result.demo - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
# $result.license_expiration - license end date (Y-m-d), empty if none
# $result.usages_total - total obfuscations for this activation code
#
if ($result -and $null -ne $result.PSObject.Properties['error']) {
# display obfuscated code
if ($result.error -eq [LuaVirtualizer]::ERROR_SUCCESS) {
Write-Host $result.output
}
else {
Write-Host ("An error occurred, error code: {0}" -f $result.error)
}
}
else {
Write-Host 'Something unexpected happen while trying to obfuscate the code.'
}
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* Version : v1.0.0
* Language : Go
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
package main
import (
"context"
"fmt"
"os"
luavirtualizer "github.com/PELock/Lua-Virtualizer-Go"
)
func main() {
client := luavirtualizer.New("ABCD-ABCD-ABCD-ABCD")
source := `local function greet(name)
print("Hello, " .. name)
end
greet("Lua")
`
result, err := client.VirtualizeScriptSource(context.Background(), source)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
if result.Error != luavirtualizer.ErrorSuccess {
fmt.Fprintf(os.Stderr, "An error occurred, error code: %d\n", result.Error)
os.Exit(1)
}
fmt.Println(result.Output)
}
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* Version : v1.0.0
* Language : Java
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
import com.pelock.luavirtualizer.LuaVirtualizer;
import com.pelock.luavirtualizer.LuaVirtualizerResult;
public class LuaVirtualizerExampleSimple {
public static void main(String[] args) throws Exception {
LuaVirtualizer client = new LuaVirtualizer("ABCD-ABCD-ABCD-ABCD");
String scriptSourceCode =
"local function greet(name)
"
+ " print(\"Hello, \" .. name)
"
+ "end
"
+ "greet(\"Lua\")
";
LuaVirtualizerResult result = client.virtualizeScriptSource(scriptSourceCode);
if (result != null && result.isSuccess() && result.getOutput() != null) {
System.out.println(result.getOutput());
} else {
throw new IllegalStateException(
"An error occurred, error code: " + (result == null ? "null" : result.getError()));
}
}
}
# frozen_string_literal: true
###############################################################################
#
# Lua Virtualizer — default options
#
# Version : v1.0.0
# Language : Ruby
# Author : Bartosz Wójcik
# Web page : https://www.pelock.com
#
###############################################################################
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
require "lua-virtualizer"
client = LuaVirtualizer.new("YOUR-WEB-API-KEY")
source = <<~PY
local function greet(name)
print("Hello, " .. name)
end
greet("Lua")
PY
result = client.virtualize_script_source(source)
if result && result["error"] == LuaVirtualizer::ERROR_SUCCESS
puts result["output"]
else
warn "Error: #{result.inspect}"
end
#!/usr/bin/env bash
###############################################################################
#
# Lua Virtualizer REST interface usage example.
#
# In this example we will virtualize sample source with default options.
#
# Version : v1.0.0
# Language : curl
# Author : Bartosz Wójcik
# Web page : https://www.pelock.com
#
###############################################################################
#
# activation key (empty or invalid key runs demo mode)
#
API_KEY="ABCD-ABCD-ABCD-ABCD"
#
# source file
#
cat > script.lua << 'SRC'
local function greet(name)
print("Hello, " .. name)
end
greet("Lua")
SRC
#
# by default the client enables VM virtualization and every mutating strategy.
# Protection flags stay off, so they are omitted. Compression stays off.
# REST does not accept compression or a source string. The script is the
# multipart part named file.
#
# response body - virtualized script, saved as obfuscated.lua
# X-PELock-Result - JSON status next to the script:
#
# error - error code (0 = success)
# demo - demo mode (invalid or empty activation key)
# license_expiration - license end date, empty if none
# usages_total - total runs for this activation code
# string_limit - max. source code size
#
# a failed call is HTTP 422 and a JSON body instead of the script
curl -sS -D - -o obfuscated.lua \
-H "Authorization: Bearer ${API_KEY}" \
-F "file=@script.lua" \
-F "code_virtualization=vm" \
-F "rename_variables=1" \
-F "rename_parameters=1" \
-F "rename_functions=1" \
-F "rename_function_calls=1" \
-F "shuffle_functions=1" \
-F "resolve_constants=1" \
-F "split_strings=1" \
-F "modify_strings=1" \
-F "encrypt_strings=1" \
-F "string_char_array_vault=1" \
-F "encrypt_integers=1" \
-F "encrypt_floating=1" \
-F "mba_binops=1" \
-F "integers_to_floating=1" \
-F "integers_to_arrays=1" \
-F "floats_to_arrays=1" \
-F "affine_integer_mask=1" \
-F "array_int_crypt=1" \
-F "array_char_crypt=1" \
-F "array_double_crypt=1" \
-F "array_string_crypt=1" \
-F "insert_random_value_bucket=1" \
-F "random_bucket_integers=1" \
-F "random_bucket_arrays=1" \
-F "random_bucket_functions=1" \
-F "random_bucket_characters=1" \
-F "random_bucket_anti_regex=1" \
-F "random_bucket_autostart=1" \
-F "insert_ternary_operators=1" \
-F "complexify_booleans=1" \
-F "opaque_branches=1" \
-F "opaque_mixer_chain=1" \
-F "insert_dead_code=1" \
-F "try_finally_noise=1" \
-F "decoy_functions=1" \
-F "lambda_decoys=1" \
-F "literal_padding=1" \
-F "fake_import_markers=1" \
-F "dynamic_getattr_calls=1" \
-F "obfuscate_imports=1" \
-F "callback_registration_stubs=1" \
-F "remove_comments=1" \
"https://www.pelock.com/api/lua-virtualizer/v1/virtualize"
Omitting target or sending auto detects the dialect. target=luajit or target=5.4 forces that dialect.
#!/usr/bin/env python
###############################################################################
#
# Lua Virtualizer WebApi interface usage example.
#
# In this example we will obfuscate sample source with every public option
# set, so you can see the full client surface and turn flags on or off.
#
# Version : v1.0.0
# Language : Python
# Author : Bartosz Wójcik
# Web page : https://www.pelock.com
#
###############################################################################
#
# include Lua Virtualizer module
#
from luavirtualizer import CodeVirtualization, LuaVirtualizer, RenameStyle
#
# if you don't want to use Python module, you can import directly from the file
#
#from pelock.luavirtualizer import LuaVirtualizer
#
# create Lua Virtualizer class instance (we are using our activation key)
#
myLuaVirtualizer = LuaVirtualizer("ABCD-ABCD-ABCD-ABCD")
#
# should the source code be compressed (both input & compressed)
#
myLuaVirtualizer.enable_compression = False
#
# globals
#
# fixed random seed for reproducible obfuscation output (optional)
#
myLuaVirtualizer.seed = None
#
# randomization density / intensity (0-100)
#
myLuaVirtualizer.randomization_density = None
#
# identifier renaming style: RenameStyle.IL, O0, HEX, or MANGLED
#
myLuaVirtualizer.rename_style = RenameStyle.IL
#
# Lua dialect. "auto" (default) omits the POST field.
# Explicit values: 5.1, 5.2, 5.3, 5.4, 5.5, luajit, luau.
#
myLuaVirtualizer.target = "auto"
#
# code virtualization (exactly one): VM, FSM, WEAVE, FLAT, or RND. RND picks VM, FSM, or WEAVE per run and not FLAT
# set to None to skip virtualization
#
myLuaVirtualizer.code_virtualization = CodeVirtualization.VM
#
# protection (opt-in on the service for --all; shown enabled here so every flag is visible)
#
# protection against tampering with protected code (integrity verification)
#
myLuaVirtualizer.self_defending = True
#
# protection linker (decoy call graph; requires self_defending)
#
myLuaVirtualizer.protection_linker = True
#
# insert anti-debugging detections
#
myLuaVirtualizer.detect_debugger = True
#
# insert virtual machine (anti-VM) detections
#
myLuaVirtualizer.anti_vm = True
#
# insert anti-sandbox detections
#
myLuaVirtualizer.anti_sandbox = True
#
# insert anti-emulators (CPU) detections
#
myLuaVirtualizer.anti_emulator = True
#
# renaming
#
# rename variable names to random string values
#
myLuaVirtualizer.rename_variables = True
#
# rename parameter names to random string values
#
myLuaVirtualizer.rename_parameters = True
#
# rename function names to random string values
#
myLuaVirtualizer.rename_functions = True
#
# rename function call references consistently with renamed functions
#
myLuaVirtualizer.rename_function_calls = True
#
# shuffle function order in the output source
#
myLuaVirtualizer.shuffle_functions = True
#
# fold/resolve constant expressions at obfuscation time
#
myLuaVirtualizer.resolve_constants = True
#
# strings
#
# split strings into concatenated chunks
#
myLuaVirtualizer.split_strings = True
#
# apply light transformations/mutations to string literals
#
myLuaVirtualizer.modify_strings = True
#
# encrypt strings using randomly generated polymorphic encryption algorithms
#
myLuaVirtualizer.encrypt_strings = True
#
# store string fragments in char-code array vaults
#
myLuaVirtualizer.string_char_array_vault = True
#
# numeric
#
# encrypt integers
#
myLuaVirtualizer.encrypt_integers = True
#
# encrypt floating point numbers
#
myLuaVirtualizer.encrypt_floating = True
#
# replace binary operators with mixed boolean-arithmetic (MBA) equivalents
#
myLuaVirtualizer.mba_binops = True
#
# represent integers via floating-point math
#
myLuaVirtualizer.integers_to_floating = True
#
# move integers to arrays
#
myLuaVirtualizer.integers_to_arrays = True
#
# move floats to arrays
#
myLuaVirtualizer.floats_to_arrays = True
#
# apply redundant xor / affine integer masks
#
myLuaVirtualizer.affine_integer_mask = True
#
# encrypted array literals
#
# encrypt integer array literals
#
myLuaVirtualizer.array_int_crypt = True
#
# encrypt character array literals
#
myLuaVirtualizer.array_char_crypt = True
#
# encrypt floating-point array literals
#
myLuaVirtualizer.array_double_crypt = True
#
# encrypt string array literals
#
myLuaVirtualizer.array_string_crypt = True
#
# decoy value pools
#
# insert a shared bucket of random noise values used by other strategies
#
myLuaVirtualizer.insert_random_value_bucket = True
#
# populate the random value bucket with decoy integers
#
myLuaVirtualizer.random_bucket_integers = True
#
# populate the random value bucket with decoy arrays
#
myLuaVirtualizer.random_bucket_arrays = True
#
# populate the random value bucket with decoy functions
#
myLuaVirtualizer.random_bucket_functions = True
#
# populate the random value bucket with decoy characters
#
myLuaVirtualizer.random_bucket_characters = True
#
# populate the random value bucket with anti-regex decoy noise
#
myLuaVirtualizer.random_bucket_anti_regex = True
#
# populate the random value bucket with autostart decoy stubs
#
myLuaVirtualizer.random_bucket_autostart = True
#
# opaque predicates & noise
#
# rewrite selected statements using ternary operators
#
myLuaVirtualizer.insert_ternary_operators = True
#
# replace boolean conditions with equivalent complex expressions
#
myLuaVirtualizer.complexify_booleans = True
#
# insert opaque predicate branches
#
myLuaVirtualizer.opaque_branches = True
#
# insert opaque mixer chains into control flow
#
myLuaVirtualizer.opaque_mixer_chain = True
#
# insert dead code
#
myLuaVirtualizer.insert_dead_code = True
#
# wrap code in try/finally blocks with dead noise
#
myLuaVirtualizer.try_finally_noise = True
#
# decoys
#
# insert decoy functions
#
myLuaVirtualizer.decoy_functions = True
#
# insert decoy lambda expressions
#
myLuaVirtualizer.lambda_decoys = True
#
# insert literal padding noise
#
myLuaVirtualizer.literal_padding = True
#
# insert fake import statement markers
#
myLuaVirtualizer.fake_import_markers = True
#
# use dynamic getattr()-based indirect calls
#
myLuaVirtualizer.dynamic_getattr_calls = True
#
# rewrite absolute imports into __import__ / getattr
#
myLuaVirtualizer.obfuscate_imports = True
#
# insert dead callback/event registration stubs
#
myLuaVirtualizer.callback_registration_stubs = True
#
# other
#
# strip comments from the output source
#
myLuaVirtualizer.remove_comments = True
#
# source code in Lua format
#
scriptSourceCode = """local function greet(name)
print("Hello, " .. name)
end
greet("Lua")
"""
#
# by default all obfuscation options are enabled, so we can just simply call
#
result = myLuaVirtualizer.virtualize_script_source(scriptSourceCode)
#
# it's also possible to pass a Lua script file path instead of a string with the source e.g.
#
# result = myLuaVirtualizer.virtualize_script_file("/path/to/project/script.lua")
#
# result[] array holds the obfuscation results as well as other information
#
# result["error"] - error code
# result["output"] - obfuscated code
# result["demo"] - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
# result["license_expiration"] - license end date (Y-m-d), empty if none
# result["usages_total"] - total obfuscations for this activation code
#
if result and "error" in result:
# display obfuscated code
if result["error"] == LuaVirtualizer.ERROR_SUCCESS:
# format output code for HTML display
print(result["output"])
else:
print(f'An error occurred, error code: {result["error"]}')
else:
print("Something unexpected happen while trying to obfuscate the code.")
#
# Per-function marker (source syntax, not a library import). The marker is the
# first statement of a function. The engine reads it and strips it.
#
# local function f()
# LUAVIRTUALIZER(VM(FSM), ENABLE(encrypt_strings), DISABLE(NUMBERS))
# return 1
# end
#
# VM(VM|FSM|WEAVE|FLAT|NONE|RND) selects the dispatcher. RND picks VM, FSM, or WEAVE for this function on each run. NONE stays native Lua.
# ENABLE(...) replaces the strategy set. ENABLE(ALL) is the --all set.
# DISABLE(...) then removes a group or one strategy. DISABLE(ALL) clears it.
# Clauses apply as VM, then ENABLE, then DISABLE. Names are case-insensitive.
<?php
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* In this example we will obfuscate sample source with every public option
* set, so you can see the full client surface and turn flags on or off.
*
* Version : v1.0
* Language : PHP
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
//
// include Lua Virtualizer class
//
use PELock\LuaVirtualizer\LuaVirtualizer;
use PELock\LuaVirtualizer\CodeVirtualization;
use PELock\LuaVirtualizer\RenameStyle;
use PELock\LuaVirtualizer\Target;
//
// if you don't want to use Composer use include_once
//
//include_once "LuaVirtualizer.php";
//
// create Lua Virtualizer class instance (we are using our activation key)
//
$myLuaVirtualizer = new LuaVirtualizer("ABCD-ABCD-ABCD-ABCD");
//
// should the source code be compressed (both input & compressed)
//
$myLuaVirtualizer->enableCompression = false;
//
// globals
//
// fixed random seed for reproducible obfuscation output (optional)
//
$myLuaVirtualizer->seed = null;
//
// randomization density / intensity (0-100)
//
$myLuaVirtualizer->randomizationDensity = null;
//
// identifier renaming style: RenameStyle::Il, O0, Hex, or Mangled
//
$myLuaVirtualizer->renameStyle = RenameStyle::Il;
//
// Lua dialect. "auto" (default) omits the POST field.
// Explicit values: 5.1, 5.2, 5.3, 5.4, 5.5, luajit, luau.
//
$myLuaVirtualizer->target = Target::Auto;
//
// code virtualization (exactly one): VM, FSM, WEAVE, FLAT, or RND. RND picks VM, FSM, or WEAVE per run and not FLAT
// set to null to skip virtualization
//
$myLuaVirtualizer->codeVirtualization = CodeVirtualization::VM;
//
// protection (opt-in on the service for --all; shown enabled here so every flag is visible)
//
// protection against tampering with protected code (integrity verification)
//
$myLuaVirtualizer->selfDefending = true;
//
// protection linker (decoy call graph; requires selfDefending)
//
$myLuaVirtualizer->protectionLinker = true;
//
// insert anti-debugging detections
//
$myLuaVirtualizer->detectDebugger = true;
//
// insert virtual machine (anti-VM) detections
//
$myLuaVirtualizer->antiVm = true;
//
// insert anti-sandbox detections
//
$myLuaVirtualizer->antiSandbox = true;
//
// insert anti-emulators (CPU) detections
//
$myLuaVirtualizer->antiEmulator = true;
//
// renaming
//
// rename variable names to random string values
//
$myLuaVirtualizer->renameVariables = true;
//
// rename parameter names to random string values
//
$myLuaVirtualizer->renameParameters = true;
//
// rename function names to random string values
//
$myLuaVirtualizer->renameFunctions = true;
//
// rename function call references consistently with renamed functions
//
$myLuaVirtualizer->renameFunctionCalls = true;
//
// shuffle function order in the output source
//
$myLuaVirtualizer->shuffleFunctions = true;
//
// fold/resolve constant expressions at obfuscation time
//
$myLuaVirtualizer->resolveConstants = true;
//
// strings
//
// split strings into concatenated chunks
//
$myLuaVirtualizer->splitStrings = true;
//
// apply light transformations/mutations to string literals
//
$myLuaVirtualizer->modifyStrings = true;
//
// encrypt strings using randomly generated polymorphic encryption algorithms
//
$myLuaVirtualizer->encryptStrings = true;
//
// store string fragments in char-code array vaults
//
$myLuaVirtualizer->stringCharArrayVault = true;
//
// numeric
//
// encrypt integers
//
$myLuaVirtualizer->encryptIntegers = true;
//
// encrypt floating point numbers
//
$myLuaVirtualizer->encryptFloating = true;
//
// replace binary operators with mixed boolean-arithmetic (MBA) equivalents
//
$myLuaVirtualizer->mbaBinops = true;
//
// represent integers via floating-point math
//
$myLuaVirtualizer->integersToFloating = true;
//
// move integers to arrays
//
$myLuaVirtualizer->integersToArrays = true;
//
// move floats to arrays
//
$myLuaVirtualizer->floatsToArrays = true;
//
// apply redundant xor / affine integer masks
//
$myLuaVirtualizer->affineIntegerMask = true;
//
// encrypted array literals
//
// encrypt integer array literals
//
$myLuaVirtualizer->arrayIntCrypt = true;
//
// encrypt character array literals
//
$myLuaVirtualizer->arrayCharCrypt = true;
//
// encrypt floating-point array literals
//
$myLuaVirtualizer->arrayDoubleCrypt = true;
//
// encrypt string array literals
//
$myLuaVirtualizer->arrayStringCrypt = true;
//
// decoy value pools
//
// insert a shared bucket of random noise values used by other strategies
//
$myLuaVirtualizer->insertRandomValueBucket = true;
//
// populate the random value bucket with decoy integers
//
$myLuaVirtualizer->randomBucketIntegers = true;
//
// populate the random value bucket with decoy arrays
//
$myLuaVirtualizer->randomBucketArrays = true;
//
// populate the random value bucket with decoy functions
//
$myLuaVirtualizer->randomBucketFunctions = true;
//
// populate the random value bucket with decoy characters
//
$myLuaVirtualizer->randomBucketCharacters = true;
//
// populate the random value bucket with anti-regex decoy noise
//
$myLuaVirtualizer->randomBucketAntiRegex = true;
//
// populate the random value bucket with autostart decoy stubs
//
$myLuaVirtualizer->randomBucketAutostart = true;
//
// opaque predicates & noise
//
// rewrite selected statements using ternary operators
//
$myLuaVirtualizer->insertTernaryOperators = true;
//
// replace boolean conditions with equivalent complex expressions
//
$myLuaVirtualizer->complexifyBooleans = true;
//
// insert opaque predicate branches
//
$myLuaVirtualizer->opaqueBranches = true;
//
// insert opaque mixer chains into control flow
//
$myLuaVirtualizer->opaqueMixerChain = true;
//
// insert dead code
//
$myLuaVirtualizer->insertDeadCode = true;
//
// wrap code in try/finally blocks with dead noise
//
$myLuaVirtualizer->tryFinallyNoise = true;
//
// decoys
//
// insert decoy functions
//
$myLuaVirtualizer->decoyFunctions = true;
//
// insert decoy lambda expressions
//
$myLuaVirtualizer->lambdaDecoys = true;
//
// insert literal padding noise
//
$myLuaVirtualizer->literalPadding = true;
//
// insert fake import statement markers
//
$myLuaVirtualizer->fakeImportMarkers = true;
//
// use dynamic getattr()-based indirect calls
//
$myLuaVirtualizer->dynamicGetattrCalls = true;
//
// rewrite absolute imports into __import__ / getattr
//
$myLuaVirtualizer->obfuscateImports = true;
//
// insert dead callback/event registration stubs
//
$myLuaVirtualizer->callbackRegistrationStubs = true;
//
// other
//
// strip comments from the output source
//
$myLuaVirtualizer->removeComments = true;
//
// source code in Lua format
//
$scriptSourceCode = "local function greet(name)
print("Hello, " .. name)
end
greet("Lua")
";
//
// by default all obfuscation options are enabled, so we can just simply call:
//
$result = $myLuaVirtualizer->VirtualizeScriptSource($scriptSourceCode);
//
// it's also possible to pass a Lua script file path instead of a string e.g.
//
// $result = $myLuaVirtualizer->VirtualizeScriptFile("/path/to/project/script.lua");
//
// $result[] array holds the obfuscation results as well as other information
//
// $result["error"] - error code
// $result["output"] - obfuscated code
// $result["demo"] - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
// $result["license_expiration"] - license end date (Y-m-d), empty if none
// $result["usages_total"] - total obfuscations for this activation code
//
if ($result !== false)
{
// display obfuscated code
if ($result["error"] === \PELock\LuaVirtualizer::ERROR_SUCCESS)
{
// format output code for HTML display
echo "<pre>" . htmlentities($result["output"]) . "</pre>";
}
else
{
die("An error occurred, error code: " . $result["error"]);
}
}
else
{
die("Something unexpected happen while trying to obfuscate the code.");
}
?>
//
// Per-function marker (source syntax, not a library import). The marker is the
// first statement of a function. The engine reads it and strips it.
//
// local function f()
// LUAVIRTUALIZER(VM(FSM), ENABLE(encrypt_strings), DISABLE(NUMBERS))
// return 1
// end
//
// VM(VM|FSM|WEAVE|FLAT|NONE|RND) selects the dispatcher. RND picks VM, FSM, or WEAVE for this function on each run. NONE stays native Lua.
// ENABLE(...) replaces the strategy set. ENABLE(ALL) is the --all set.
// DISABLE(...) then removes a group or one strategy. DISABLE(ALL) clears it.
// Clauses apply as VM, then ENABLE, then DISABLE. Names are case-insensitive.
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* In this example we will obfuscate sample source with every public option
* set, so you can see the full client surface and turn flags on or off.
*
* Version : v1.0.0
* Language : JavaScript
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
import LuaVirtualizer, { CodeVirtualization, RenameStyle } from "lua-virtualizer";
//
// include Lua Virtualizer class
//
//
// when developing from a repository clone without installing the package use:
//
// import LuaVirtualizer from "../src/lua-virtualizer.js";
//
// create Lua Virtualizer class instance (we are using our activation key)
//
const myLuaVirtualizer = new LuaVirtualizer("ABCD-ABCD-ABCD-ABCD");
//
// should the source code be compressed (both input & compressed)
//
myLuaVirtualizer.enableCompression = false;
//
// globals
//
// fixed random seed for reproducible obfuscation output (optional)
//
myLuaVirtualizer.seed = null;
//
// randomization density / intensity (0-100)
//
myLuaVirtualizer.randomizationDensity = null;
//
// identifier renaming style: RenameStyle.IL, O0, HEX, or MANGLED
//
myLuaVirtualizer.renameStyle = RenameStyle.IL;
//
// Lua dialect. "auto" (default) omits the POST field.
// Explicit values: 5.1, 5.2, 5.3, 5.4, 5.5, luajit, luau.
//
myLuaVirtualizer.target = "auto";
//
// code virtualization (exactly one): VM, FSM, WEAVE, FLAT, or RND. RND picks VM, FSM, or WEAVE per run and not FLAT
// set to null to skip virtualization
//
myLuaVirtualizer.codeVirtualization = CodeVirtualization.VM;
//
// protection (opt-in on the service for --all; shown enabled here so every flag is visible)
//
// protection against tampering with protected code (integrity verification)
//
myLuaVirtualizer.selfDefending = true;
//
// protection linker (decoy call graph; requires selfDefending)
//
myLuaVirtualizer.protectionLinker = true;
//
// insert anti-debugging detections
//
myLuaVirtualizer.detectDebugger = true;
//
// insert virtual machine (anti-VM) detections
//
myLuaVirtualizer.antiVm = true;
//
// insert anti-sandbox detections
//
myLuaVirtualizer.antiSandbox = true;
//
// insert anti-emulators (CPU) detections
//
myLuaVirtualizer.antiEmulator = true;
//
// renaming
//
// rename variable names to random string values
//
myLuaVirtualizer.renameVariables = true;
//
// rename parameter names to random string values
//
myLuaVirtualizer.renameParameters = true;
//
// rename function names to random string values
//
myLuaVirtualizer.renameFunctions = true;
//
// rename function call references consistently with renamed functions
//
myLuaVirtualizer.renameFunctionCalls = true;
//
// shuffle function order in the output source
//
myLuaVirtualizer.shuffleFunctions = true;
//
// fold/resolve constant expressions at obfuscation time
//
myLuaVirtualizer.resolveConstants = true;
//
// strings
//
// split strings into concatenated chunks
//
myLuaVirtualizer.splitStrings = true;
//
// apply light transformations/mutations to string literals
//
myLuaVirtualizer.modifyStrings = true;
//
// encrypt strings using randomly generated polymorphic encryption algorithms
//
myLuaVirtualizer.encryptStrings = true;
//
// store string fragments in char-code array vaults
//
myLuaVirtualizer.stringCharArrayVault = true;
//
// numeric
//
// encrypt integers
//
myLuaVirtualizer.encryptIntegers = true;
//
// encrypt floating point numbers
//
myLuaVirtualizer.encryptFloating = true;
//
// replace binary operators with mixed boolean-arithmetic (MBA) equivalents
//
myLuaVirtualizer.mbaBinops = true;
//
// represent integers via floating-point math
//
myLuaVirtualizer.integersToFloating = true;
//
// move integers to arrays
//
myLuaVirtualizer.integersToArrays = true;
//
// move floats to arrays
//
myLuaVirtualizer.floatsToArrays = true;
//
// apply redundant xor / affine integer masks
//
myLuaVirtualizer.affineIntegerMask = true;
//
// encrypted array literals
//
// encrypt integer array literals
//
myLuaVirtualizer.arrayIntCrypt = true;
//
// encrypt character array literals
//
myLuaVirtualizer.arrayCharCrypt = true;
//
// encrypt floating-point array literals
//
myLuaVirtualizer.arrayDoubleCrypt = true;
//
// encrypt string array literals
//
myLuaVirtualizer.arrayStringCrypt = true;
//
// decoy value pools
//
// insert a shared bucket of random noise values used by other strategies
//
myLuaVirtualizer.insertRandomValueBucket = true;
//
// populate the random value bucket with decoy integers
//
myLuaVirtualizer.randomBucketIntegers = true;
//
// populate the random value bucket with decoy arrays
//
myLuaVirtualizer.randomBucketArrays = true;
//
// populate the random value bucket with decoy functions
//
myLuaVirtualizer.randomBucketFunctions = true;
//
// populate the random value bucket with decoy characters
//
myLuaVirtualizer.randomBucketCharacters = true;
//
// populate the random value bucket with anti-regex decoy noise
//
myLuaVirtualizer.randomBucketAntiRegex = true;
//
// populate the random value bucket with autostart decoy stubs
//
myLuaVirtualizer.randomBucketAutostart = true;
//
// opaque predicates & noise
//
// rewrite selected statements using ternary operators
//
myLuaVirtualizer.insertTernaryOperators = true;
//
// replace boolean conditions with equivalent complex expressions
//
myLuaVirtualizer.complexifyBooleans = true;
//
// insert opaque predicate branches
//
myLuaVirtualizer.opaqueBranches = true;
//
// insert opaque mixer chains into control flow
//
myLuaVirtualizer.opaqueMixerChain = true;
//
// insert dead code
//
myLuaVirtualizer.insertDeadCode = true;
//
// wrap code in try/finally blocks with dead noise
//
myLuaVirtualizer.tryFinallyNoise = true;
//
// decoys
//
// insert decoy functions
//
myLuaVirtualizer.decoyFunctions = true;
//
// insert decoy lambda expressions
//
myLuaVirtualizer.lambdaDecoys = true;
//
// insert literal padding noise
//
myLuaVirtualizer.literalPadding = true;
//
// insert fake import statement markers
//
myLuaVirtualizer.fakeImportMarkers = true;
//
// use dynamic getattr()-based indirect calls
//
myLuaVirtualizer.dynamicGetattrCalls = true;
//
// rewrite absolute imports into __import__ / getattr
//
myLuaVirtualizer.obfuscateImports = true;
//
// insert dead callback/event registration stubs
//
myLuaVirtualizer.callbackRegistrationStubs = true;
//
// other
//
// strip comments from the output source
//
myLuaVirtualizer.removeComments = true;
//
// source code in Lua format
//
const scriptSourceCode = `local function greet(name)
print("Hello, " .. name)
end
greet("Lua")
`;
//
// by default all obfuscation options are enabled, so we can just simply call:
//
const result = await myLuaVirtualizer.virtualizeScriptSource(scriptSourceCode);
//
// it's also possible to pass a Lua script file path instead of a string e.g.
//
// const result = await myLuaVirtualizer.virtualizeScriptFile("/path/to/project/script.lua");
//
// result object holds the obfuscation results as well as other information
//
// result.error - error code
// result.output - obfuscated code
// result.demo - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
// result.license_expiration - license end date (Y-m-d), empty if none
// result.usages_total - total obfuscations for this activation code
//
if (result !== null) {
//
// display obfuscated code
//
if (result.error === LuaVirtualizer.ERROR_SUCCESS) {
console.log(result.output);
} else {
throw new Error("An error occurred, error code: " + result.error);
}
} else {
throw new Error("Something unexpected happen while trying to obfuscate the code.");
}
//
// Per-function marker (source syntax, not a library import). The marker is the
// first statement of a function. The engine reads it and strips it.
//
// local function f()
// LUAVIRTUALIZER(VM(FSM), ENABLE(encrypt_strings), DISABLE(NUMBERS))
// return 1
// end
//
// VM(VM|FSM|WEAVE|FLAT|NONE|RND) selects the dispatcher. RND picks VM, FSM, or WEAVE for this function on each run. NONE stays native Lua.
// ENABLE(...) replaces the strategy set. ENABLE(ALL) is the --all set.
// DISABLE(...) then removes a group or one strategy. DISABLE(ALL) clears it.
// Clauses apply as VM, then ENABLE, then DISABLE. Names are case-insensitive.
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* In this example we will obfuscate sample source with every public option
* set, so you can see the full client surface and turn flags on or off.
*
* Version : v1.0.0
* Language : Rust
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
use lua_virtualizer::{
CodeVirtualization, LuaVirtualizer, LuaVirtualizerResponse, RenameStyle, Target,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
//
// include Lua Virtualizer class
//
//
// when developing from a repository clone without installing the package use:
//
// use lua_virtualizer::{LuaVirtualizer, LuaVirtualizerResponse};
// (path dependency in Cargo.toml pointing to this crate)
//
// create Lua Virtualizer class instance (we are using our activation key)
//
let mut my_lua_virtualizer =
LuaVirtualizer::new(Some("ABCD-ABCD-ABCD-ABCD".to_string()));
//
// should the source code be compressed (both input & compressed)
//
my_lua_virtualizer.enable_compression = false;
//
// globals
//
// fixed random seed for reproducible obfuscation output (optional)
//
my_lua_virtualizer.seed = None;
//
// randomization density / intensity (0-100)
//
my_lua_virtualizer.randomization_density = None;
//
// identifier renaming style: RenameStyle::Il, O0, Hex, or Mangled
//
my_lua_virtualizer.rename_style = Some(RenameStyle::Il);
//
// Lua dialect. Auto (default) omits the POST field.
// Explicit values: 5.1, 5.2, 5.3, 5.4, 5.5, luajit, luau.
//
my_lua_virtualizer.target = Target::Auto;
//
// code virtualization (exactly one): Vm, Fsm, Weave, Flat, or Rnd. Rnd picks Vm, Fsm, or Weave per run and not Flat
// set to None to skip virtualization
//
my_lua_virtualizer.code_virtualization = Some(CodeVirtualization::Vm);
//
// protection (opt-in on the service for --all; shown enabled here so every flag is visible)
//
// protection against tampering with protected code (integrity verification)
//
my_lua_virtualizer.self_defending = true;
//
// protection linker (decoy call graph; requires self_defending)
//
my_lua_virtualizer.protection_linker = true;
//
// insert anti-debugging detections
//
my_lua_virtualizer.detect_debugger = true;
//
// insert virtual machine (anti-VM) detections
//
my_lua_virtualizer.anti_vm = true;
//
// insert anti-sandbox detections
//
my_lua_virtualizer.anti_sandbox = true;
//
// insert anti-emulators (CPU) detections
//
my_lua_virtualizer.anti_emulator = true;
//
// renaming
//
// rename variable names to random string values
//
my_lua_virtualizer.rename_variables = true;
//
// rename parameter names to random string values
//
my_lua_virtualizer.rename_parameters = true;
//
// rename function names to random string values
//
my_lua_virtualizer.rename_functions = true;
//
// rename function call references consistently with renamed functions
//
my_lua_virtualizer.rename_function_calls = true;
//
// shuffle function order in the output source
//
my_lua_virtualizer.shuffle_functions = true;
//
// fold/resolve constant expressions at obfuscation time
//
my_lua_virtualizer.resolve_constants = true;
//
// strings
//
// split strings into concatenated chunks
//
my_lua_virtualizer.split_strings = true;
//
// apply light transformations/mutations to string literals
//
my_lua_virtualizer.modify_strings = true;
//
// encrypt strings using randomly generated polymorphic encryption algorithms
//
my_lua_virtualizer.encrypt_strings = true;
//
// store string fragments in char-code array vaults
//
my_lua_virtualizer.string_char_array_vault = true;
//
// numeric
//
// encrypt integers
//
my_lua_virtualizer.encrypt_integers = true;
//
// encrypt floating point numbers
//
my_lua_virtualizer.encrypt_floating = true;
//
// replace binary operators with mixed boolean-arithmetic (MBA) equivalents
//
my_lua_virtualizer.mba_binops = true;
//
// represent integers via floating-point math
//
my_lua_virtualizer.integers_to_floating = true;
//
// move integers to arrays
//
my_lua_virtualizer.integers_to_arrays = true;
//
// move floats to arrays
//
my_lua_virtualizer.floats_to_arrays = true;
//
// apply redundant xor / affine integer masks
//
my_lua_virtualizer.affine_integer_mask = true;
//
// encrypted array literals
//
// encrypt integer array literals
//
my_lua_virtualizer.array_int_crypt = true;
//
// encrypt character array literals
//
my_lua_virtualizer.array_char_crypt = true;
//
// encrypt floating-point array literals
//
my_lua_virtualizer.array_double_crypt = true;
//
// encrypt string array literals
//
my_lua_virtualizer.array_string_crypt = true;
//
// decoy value pools
//
// insert a shared bucket of random noise values used by other strategies
//
my_lua_virtualizer.insert_random_value_bucket = true;
//
// populate the random value bucket with decoy integers
//
my_lua_virtualizer.random_bucket_integers = true;
//
// populate the random value bucket with decoy arrays
//
my_lua_virtualizer.random_bucket_arrays = true;
//
// populate the random value bucket with decoy functions
//
my_lua_virtualizer.random_bucket_functions = true;
//
// populate the random value bucket with decoy characters
//
my_lua_virtualizer.random_bucket_characters = true;
//
// populate the random value bucket with anti-regex decoy noise
//
my_lua_virtualizer.random_bucket_anti_regex = true;
//
// populate the random value bucket with autostart decoy stubs
//
my_lua_virtualizer.random_bucket_autostart = true;
//
// opaque predicates & noise
//
// rewrite selected statements using ternary operators
//
my_lua_virtualizer.insert_ternary_operators = true;
//
// replace boolean conditions with equivalent complex expressions
//
my_lua_virtualizer.complexify_booleans = true;
//
// insert opaque predicate branches
//
my_lua_virtualizer.opaque_branches = true;
//
// insert opaque mixer chains into control flow
//
my_lua_virtualizer.opaque_mixer_chain = true;
//
// insert dead code
//
my_lua_virtualizer.insert_dead_code = true;
//
// wrap code in try/finally blocks with dead noise
//
my_lua_virtualizer.try_finally_noise = true;
//
// decoys
//
// insert decoy functions
//
my_lua_virtualizer.decoy_functions = true;
//
// insert decoy lambda expressions
//
my_lua_virtualizer.lambda_decoys = true;
//
// insert literal padding noise
//
my_lua_virtualizer.literal_padding = true;
//
// insert fake import statement markers
//
my_lua_virtualizer.fake_import_markers = true;
//
// use dynamic getattr()-based indirect calls
//
my_lua_virtualizer.dynamic_getattr_calls = true;
//
// rewrite absolute imports into __import__ / getattr
//
my_lua_virtualizer.obfuscate_imports = true;
//
// insert dead callback/event registration stubs
//
my_lua_virtualizer.callback_registration_stubs = true;
//
// other
//
// strip comments from the output source
//
my_lua_virtualizer.remove_comments = true;
//
// source code in Lua format
//
let script_source_code = r#"local function greet(name)
print("Hello, " .. name)
end
greet("Lua")"#;
//
// virtualize the source code with the options set above
//
let result = my_lua_virtualizer
.virtualize_script_source(script_source_code, true)
.await;
//
// it's also possible to pass a Lua script file path instead of a string e.g.
//
// let result = my_lua_virtualizer
// .virtualize_script_file(std::path::Path::new("/path/to/project/script.lua"), true)
// .await;
//
// result object holds the obfuscation results as well as other information
//
// result.error - error code
// result.output - obfuscated code
// result.demo - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
// result.license_expiration - license end date (Y-m-d), empty if none
// result.usages_total - total obfuscations for this activation code
//
match result {
Some(LuaVirtualizerResponse::Object(obj)) => {
//
// display obfuscated code
//
if obj.error == LuaVirtualizer::ERROR_SUCCESS {
println!("{}", obj.output.unwrap_or_default());
} else {
return Err(
format!("An error occurred, error code: {}", obj.error).into(),
);
}
}
Some(LuaVirtualizerResponse::Json(_)) => {}
None => {
return Err("Something unexpected happen while trying to obfuscate the code.".into());
}
}
Ok(())
}
//
// Per-function marker (source syntax, not a library import). The marker is the
// first statement of a function. The engine reads it and strips it.
//
// local function f()
// LUAVIRTUALIZER(VM(FSM), ENABLE(encrypt_strings), DISABLE(NUMBERS))
// return 1
// end
//
// VM(VM|FSM|WEAVE|FLAT|NONE|RND) selects the dispatcher. RND picks VM, FSM, or WEAVE for this function on each run. NONE stays native Lua.
// ENABLE(...) replaces the strategy set. ENABLE(ALL) is the --all set.
// DISABLE(...) then removes a group or one strategy. DISABLE(ALL) clears it.
// Clauses apply as VM, then ENABLE, then DISABLE. Names are case-insensitive.
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* In this example we will obfuscate sample source with every public option
* set, so you can see the full client surface and turn flags on or off.
*
* Version : v1.0.0
* Language : C#
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
using PELock.LuaVirtualizer;
//
// create Lua Virtualizer class instance (we are using our activation key)
//
var myLuaVirtualizer = new LuaVirtualizer("ABCD-ABCD-ABCD-ABCD");
//
// should the source code be compressed (both input & compressed)
//
myLuaVirtualizer.EnableCompression = false;
//
// globals
//
// fixed random seed for reproducible obfuscation output (optional)
//
myLuaVirtualizer.Seed = null;
//
// randomization density / intensity (0-100)
//
myLuaVirtualizer.RandomizationDensity = null;
//
// identifier renaming style: RenameStyle.Il, O0, Hex, or Mangled
//
myLuaVirtualizer.RenameStyle = RenameStyle.Il;
//
// Lua dialect. "auto" (default) omits the POST field.
// Explicit values: 5.1, 5.2, 5.3, 5.4, 5.5, luajit, luau.
//
myLuaVirtualizer.Target = "auto";
//
// code virtualization (exactly one): VM, FSM, WEAVE, FLAT, or RND. RND picks VM, FSM, or WEAVE per run and not FLAT
// set to null to skip virtualization
//
myLuaVirtualizer.CodeVirtualization = CodeVirtualization.VM;
//
// protection (opt-in on the service for --all; shown enabled here so every flag is visible)
//
// protection against tampering with protected code (integrity verification)
//
myLuaVirtualizer.SelfDefending = true;
//
// protection linker (decoy call graph; requires SelfDefending)
//
myLuaVirtualizer.ProtectionLinker = true;
//
// insert anti-debugging detections
//
myLuaVirtualizer.DetectDebugger = true;
//
// insert virtual machine (anti-VM) detections
//
myLuaVirtualizer.AntiVm = true;
//
// insert anti-sandbox detections
//
myLuaVirtualizer.AntiSandbox = true;
//
// insert anti-emulators (CPU) detections
//
myLuaVirtualizer.AntiEmulator = true;
//
// renaming
//
// rename variable names to random string values
//
myLuaVirtualizer.RenameVariables = true;
//
// rename parameter names to random string values
//
myLuaVirtualizer.RenameParameters = true;
//
// rename function names to random string values
//
myLuaVirtualizer.RenameFunctions = true;
//
// rename function call references consistently with renamed functions
//
myLuaVirtualizer.RenameFunctionCalls = true;
//
// shuffle function order in the output source
//
myLuaVirtualizer.ShuffleFunctions = true;
//
// fold/resolve constant expressions at obfuscation time
//
myLuaVirtualizer.ResolveConstants = true;
//
// strings
//
// split strings into concatenated chunks
//
myLuaVirtualizer.SplitStrings = true;
//
// apply light transformations/mutations to string literals
//
myLuaVirtualizer.ModifyStrings = true;
//
// encrypt strings using randomly generated polymorphic encryption algorithms
//
myLuaVirtualizer.EncryptStrings = true;
//
// store string fragments in char-code array vaults
//
myLuaVirtualizer.StringCharArrayVault = true;
//
// numeric
//
// encrypt integers
//
myLuaVirtualizer.EncryptIntegers = true;
//
// encrypt floating point numbers
//
myLuaVirtualizer.EncryptFloating = true;
//
// replace binary operators with mixed boolean-arithmetic (MBA) equivalents
//
myLuaVirtualizer.MbaBinops = true;
//
// represent integers via floating-point math
//
myLuaVirtualizer.IntegersToFloating = true;
//
// move integers to arrays
//
myLuaVirtualizer.IntegersToArrays = true;
//
// move floats to arrays
//
myLuaVirtualizer.FloatsToArrays = true;
//
// apply redundant xor / affine integer masks
//
myLuaVirtualizer.AffineIntegerMask = true;
//
// encrypted array literals
//
// encrypt integer array literals
//
myLuaVirtualizer.ArrayIntCrypt = true;
//
// encrypt character array literals
//
myLuaVirtualizer.ArrayCharCrypt = true;
//
// encrypt floating-point array literals
//
myLuaVirtualizer.ArrayDoubleCrypt = true;
//
// encrypt string array literals
//
myLuaVirtualizer.ArrayStringCrypt = true;
//
// decoy value pools
//
// insert a shared bucket of random noise values used by other strategies
//
myLuaVirtualizer.InsertRandomValueBucket = true;
//
// populate the random value bucket with decoy integers
//
myLuaVirtualizer.RandomBucketIntegers = true;
//
// populate the random value bucket with decoy arrays
//
myLuaVirtualizer.RandomBucketArrays = true;
//
// populate the random value bucket with decoy functions
//
myLuaVirtualizer.RandomBucketFunctions = true;
//
// populate the random value bucket with decoy characters
//
myLuaVirtualizer.RandomBucketCharacters = true;
//
// populate the random value bucket with anti-regex decoy noise
//
myLuaVirtualizer.RandomBucketAntiRegex = true;
//
// populate the random value bucket with autostart decoy stubs
//
myLuaVirtualizer.RandomBucketAutostart = true;
//
// opaque predicates & noise
//
// rewrite selected statements using ternary operators
//
myLuaVirtualizer.InsertTernaryOperators = true;
//
// replace boolean conditions with equivalent complex expressions
//
myLuaVirtualizer.ComplexifyBooleans = true;
//
// insert opaque predicate branches
//
myLuaVirtualizer.OpaqueBranches = true;
//
// insert opaque mixer chains into control flow
//
myLuaVirtualizer.OpaqueMixerChain = true;
//
// insert dead code
//
myLuaVirtualizer.InsertDeadCode = true;
//
// wrap code in try/finally blocks with dead noise
//
myLuaVirtualizer.TryFinallyNoise = true;
//
// decoys
//
// insert decoy functions
//
myLuaVirtualizer.DecoyFunctions = true;
//
// insert decoy lambda expressions
//
myLuaVirtualizer.LambdaDecoys = true;
//
// insert literal padding noise
//
myLuaVirtualizer.LiteralPadding = true;
//
// insert fake import statement markers
//
myLuaVirtualizer.FakeImportMarkers = true;
//
// use dynamic getattr()-based indirect calls
//
myLuaVirtualizer.DynamicGetattrCalls = true;
//
// rewrite absolute imports into __import__ / getattr
//
myLuaVirtualizer.ObfuscateImports = true;
//
// insert dead callback/event registration stubs
//
myLuaVirtualizer.CallbackRegistrationStubs = true;
//
// other
//
// strip comments from the output source
//
myLuaVirtualizer.RemoveComments = true;
//
// source code in Lua format
//
const string ScriptSourceCode =
"""
local function greet(name)
print("Hello, " .. name)
end
greet("Lua")
""";
//
// virtualize the source code with the options set above
//
var result = await myLuaVirtualizer.VirtualizeScriptSourceAsync(ScriptSourceCode);
//
// it's also possible to pass a Lua script file path instead of a string e.g.
//
// var result = await myLuaVirtualizer.VirtualizeScriptFileAsync("/path/to/project/script.lua");
//
// result object holds the obfuscation results as well as other information
//
// result?.Error - error code (see LuaVirtualizer.Error*)
// result?.Output - obfuscated code
// result?.Demo - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
// result?.LicenseExpiration - license end date (Y-m-d), empty if none
// result?.UsagesTotal - total obfuscations for this activation code
//
if (result is not null)
{
//
// display obfuscated code
//
if (result.Error == LuaVirtualizer.ErrorSuccess && result.Output is not null)
Console.WriteLine(result.Output);
else
throw new InvalidOperationException("An error occurred, error code: " + result.Error);
}
else
{
throw new InvalidOperationException("Something unexpected happen while trying to obfuscate the code.");
}
//
// Per-function marker (source syntax, not a library import). The marker is the
// first statement of a function. The engine reads it and strips it.
//
// local function f()
// LUAVIRTUALIZER(VM(FSM), ENABLE(encrypt_strings), DISABLE(NUMBERS))
// return 1
// end
//
// VM(VM|FSM|WEAVE|FLAT|NONE|RND) selects the dispatcher. RND picks VM, FSM, or WEAVE for this function on each run. NONE stays native Lua.
// ENABLE(...) replaces the strategy set. ENABLE(ALL) is the --all set.
// DISABLE(...) then removes a group or one strategy. DISABLE(ALL) clears it.
// Clauses apply as VM, then ENABLE, then DISABLE. Names are case-insensitive.
################################################################################
#
# Lua Virtualizer WebApi interface usage example.
#
# In this example we will obfuscate sample source with every public option
# set, so you can see the full client surface and turn flags on or off.
#
# Version : v1.0.0
# Language : PowerShell
# Author : Bartosz Wójcik
# Web page : https://www.pelock.com
#
################################################################################
#
# include Lua Virtualizer module
#
# After Install-Module / Install-PSResource:
# using module LuaVirtualizer
#
using module '..\luavirtualizer\LuaVirtualizer.psd1'
#
# create Lua Virtualizer class instance (we are using our activation key)
#
$myLuaVirtualizer = [LuaVirtualizer]::new('ABCD-ABCD-ABCD-ABCD')
#
# should the source code be compressed (both input & compressed)
#
$myLuaVirtualizer.enable_compression = $false
#
# globals
#
# fixed random seed for reproducible obfuscation output (optional)
#
$myLuaVirtualizer.seed = $null
#
# randomization density / intensity (0-100)
#
$myLuaVirtualizer.randomization_density = $null
#
# identifier renaming style: [RenameStyle]::il, o0, hex, or mangled
#
$myLuaVirtualizer.rename_style = [RenameStyle]::il
#
# Lua dialect. "auto" (default) omits the POST field.
# Explicit values: 5.1, 5.2, 5.3, 5.4, 5.5, luajit, luau.
#
$myLuaVirtualizer.target = 'auto'
#
# code virtualization (exactly one): vm, fsm, weave, flat, or rnd. rnd picks vm, fsm, or weave per run and not flat
# set to $null to skip virtualization
#
$myLuaVirtualizer.code_virtualization = [CodeVirtualization]::vm
#
# protection (opt-in on the service for --all; shown enabled here so every flag is visible)
#
# protection against tampering with protected code (integrity verification)
#
$myLuaVirtualizer.self_defending = $true
#
# protection linker (decoy call graph; requires self_defending)
#
$myLuaVirtualizer.protection_linker = $true
#
# insert anti-debugging detections
#
$myLuaVirtualizer.detect_debugger = $true
#
# insert virtual machine (anti-VM) detections
#
$myLuaVirtualizer.anti_vm = $true
#
# insert anti-sandbox detections
#
$myLuaVirtualizer.anti_sandbox = $true
#
# insert anti-emulators (CPU) detections
#
$myLuaVirtualizer.anti_emulator = $true
#
# renaming
#
# rename variable names to random string values
#
$myLuaVirtualizer.rename_variables = $true
#
# rename parameter names to random string values
#
$myLuaVirtualizer.rename_parameters = $true
#
# rename function names to random string values
#
$myLuaVirtualizer.rename_functions = $true
#
# rename function call references consistently with renamed functions
#
$myLuaVirtualizer.rename_function_calls = $true
#
# shuffle function order in the output source
#
$myLuaVirtualizer.shuffle_functions = $true
#
# fold/resolve constant expressions at obfuscation time
#
$myLuaVirtualizer.resolve_constants = $true
#
# strings
#
# split strings into concatenated chunks
#
$myLuaVirtualizer.split_strings = $true
#
# apply light transformations/mutations to string literals
#
$myLuaVirtualizer.modify_strings = $true
#
# encrypt strings using randomly generated polymorphic encryption algorithms
#
$myLuaVirtualizer.encrypt_strings = $true
#
# store string fragments in char-code array vaults
#
$myLuaVirtualizer.string_char_array_vault = $true
#
# numeric
#
# encrypt integers
#
$myLuaVirtualizer.encrypt_integers = $true
#
# encrypt floating point numbers
#
$myLuaVirtualizer.encrypt_floating = $true
#
# replace binary operators with mixed boolean-arithmetic (MBA) equivalents
#
$myLuaVirtualizer.mba_binops = $true
#
# represent integers via floating-point math
#
$myLuaVirtualizer.integers_to_floating = $true
#
# move integers to arrays
#
$myLuaVirtualizer.integers_to_arrays = $true
#
# move floats to arrays
#
$myLuaVirtualizer.floats_to_arrays = $true
#
# apply redundant xor / affine integer masks
#
$myLuaVirtualizer.affine_integer_mask = $true
#
# encrypted array literals
#
# encrypt integer array literals
#
$myLuaVirtualizer.array_int_crypt = $true
#
# encrypt character array literals
#
$myLuaVirtualizer.array_char_crypt = $true
#
# encrypt floating-point array literals
#
$myLuaVirtualizer.array_double_crypt = $true
#
# encrypt string array literals
#
$myLuaVirtualizer.array_string_crypt = $true
#
# decoy value pools
#
# insert a shared bucket of random noise values used by other strategies
#
$myLuaVirtualizer.insert_random_value_bucket = $true
#
# populate the random value bucket with decoy integers
#
$myLuaVirtualizer.random_bucket_integers = $true
#
# populate the random value bucket with decoy arrays
#
$myLuaVirtualizer.random_bucket_arrays = $true
#
# populate the random value bucket with decoy functions
#
$myLuaVirtualizer.random_bucket_functions = $true
#
# populate the random value bucket with decoy characters
#
$myLuaVirtualizer.random_bucket_characters = $true
#
# populate the random value bucket with anti-regex decoy noise
#
$myLuaVirtualizer.random_bucket_anti_regex = $true
#
# populate the random value bucket with autostart decoy stubs
#
$myLuaVirtualizer.random_bucket_autostart = $true
#
# opaque predicates & noise
#
# rewrite selected statements using ternary operators
#
$myLuaVirtualizer.insert_ternary_operators = $true
#
# replace boolean conditions with equivalent complex expressions
#
$myLuaVirtualizer.complexify_booleans = $true
#
# insert opaque predicate branches
#
$myLuaVirtualizer.opaque_branches = $true
#
# insert opaque mixer chains into control flow
#
$myLuaVirtualizer.opaque_mixer_chain = $true
#
# insert dead code
#
$myLuaVirtualizer.insert_dead_code = $true
#
# wrap code in try/finally blocks with dead noise
#
$myLuaVirtualizer.try_finally_noise = $true
#
# decoys
#
# insert decoy functions
#
$myLuaVirtualizer.decoy_functions = $true
#
# insert decoy lambda expressions
#
$myLuaVirtualizer.lambda_decoys = $true
#
# insert literal padding noise
#
$myLuaVirtualizer.literal_padding = $true
#
# insert fake import statement markers
#
$myLuaVirtualizer.fake_import_markers = $true
#
# use dynamic getattr()-based indirect calls
#
$myLuaVirtualizer.dynamic_getattr_calls = $true
#
# rewrite absolute imports into __import__ / getattr
#
$myLuaVirtualizer.obfuscate_imports = $true
#
# insert dead callback/event registration stubs
#
$myLuaVirtualizer.callback_registration_stubs = $true
#
# other
#
# strip comments from the output source
#
$myLuaVirtualizer.remove_comments = $true
#
# source code in Lua format
#
$scriptSourceCode = @'
local function greet(name)
print("Hello, " .. name)
end
greet("Lua")
'@
#
# by default all obfuscation options are enabled, so we can just simply call
#
$result = $myLuaVirtualizer.VirtualizeScriptSource($scriptSourceCode)
#
# it's also possible to pass a Lua script file path instead of a string with the source e.g.
#
# $result = $myLuaVirtualizer.VirtualizeScriptFile('/path/to/project/script.lua')
#
# $result holds the obfuscation results as well as other information
#
# $result.error - error code
# $result.output - obfuscated code
# $result.demo - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
# $result.license_expiration - license end date (Y-m-d), empty if none
# $result.usages_total - total obfuscations for this activation code
#
if ($result -and $null -ne $result.PSObject.Properties['error']) {
# display obfuscated code
if ($result.error -eq [LuaVirtualizer]::ERROR_SUCCESS) {
Write-Host $result.output
}
else {
Write-Host ("An error occurred, error code: {0}" -f $result.error)
}
}
else {
Write-Host 'Something unexpected happen while trying to obfuscate the code.'
}
#
# Per-function marker (source syntax, not a library import). The marker is the
# first statement of a function. The engine reads it and strips it.
#
# local function f()
# LUAVIRTUALIZER(VM(FSM), ENABLE(encrypt_strings), DISABLE(NUMBERS))
# return 1
# end
#
# VM(VM|FSM|WEAVE|FLAT|NONE|RND) selects the dispatcher. RND picks VM, FSM, or WEAVE for this function on each run. NONE stays native Lua.
# ENABLE(...) replaces the strategy set. ENABLE(ALL) is the --all set.
# DISABLE(...) then removes a group or one strategy. DISABLE(ALL) clears it.
# Clauses apply as VM, then ENABLE, then DISABLE. Names are case-insensitive.
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* Every public option is set so the client surface is visible.
*
* Version : v1.0.0
* Language : Go
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
package main
import (
"context"
"fmt"
"os"
luavirtualizer "github.com/PELock/Lua-Virtualizer-Go"
)
func main() {
client := luavirtualizer.New("ABCD-ABCD-ABCD-ABCD")
client.EnableCompression = false
client.RenameStyle = luavirtualizer.RenameStyleIL
// auto omits the POST field. Explicit: 5.1, 5.2, 5.3, 5.4, 5.5, luajit, luau.
client.Target = luavirtualizer.TargetAuto
// code virtualization (exactly one): VM, FSM, WEAVE, FLAT, or RND. RND picks VM, FSM, or WEAVE per run and not FLAT. Leave unset to skip.
client.CodeVirtualization = luavirtualizer.CodeVirtualizationVM
client.SelfDefending = true
client.ProtectionLinker = true
client.DetectDebugger = true
client.AntiVM = true
client.AntiSandbox = true
client.AntiEmulator = true
client.RenameVariables = true
client.RenameParameters = true
client.RenameFunctions = true
client.RenameFunctionCalls = true
client.ShuffleFunctions = true
client.ResolveConstants = true
client.SplitStrings = true
client.ModifyStrings = true
client.EncryptStrings = true
client.StringCharArrayVault = true
client.EncryptIntegers = true
client.EncryptFloating = true
client.MBABinops = true
client.IntegersToFloating = true
client.IntegersToArrays = true
client.FloatsToArrays = true
client.AffineIntegerMask = true
client.ArrayIntCrypt = true
client.ArrayCharCrypt = true
client.ArrayDoubleCrypt = true
client.ArrayStringCrypt = true
client.InsertRandomValueBucket = true
client.RandomBucketIntegers = true
client.RandomBucketArrays = true
client.RandomBucketFunctions = true
client.RandomBucketCharacters = true
client.RandomBucketAntiRegex = true
client.RandomBucketAutostart = true
client.InsertTernaryOperators = true
client.ComplexifyBooleans = true
client.OpaqueBranches = true
client.OpaqueMixerChain = true
client.InsertDeadCode = true
client.TryFinallyNoise = true
client.DecoyFunctions = true
client.LambdaDecoys = true
client.LiteralPadding = true
client.FakeImportMarkers = true
client.DynamicGetattrCalls = true
client.ObfuscateImports = true
client.CallbackRegistrationStubs = true
client.RemoveComments = true
source := `local function greet(name)
print("Hello, " .. name)
end
greet("Lua")
`
result, err := client.VirtualizeScriptSource(context.Background(), source)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
if result.Error != luavirtualizer.ErrorSuccess {
fmt.Fprintf(os.Stderr, "An error occurred, error code: %d\n", result.Error)
os.Exit(1)
}
fmt.Println(result.Output)
fmt.Println(result.Target)
// Per-function marker (source syntax, not a library import). The marker is
// the first statement of a function. The engine reads it and strips it.
//
// local function f()
// LUAVIRTUALIZER(VM(FSM), ENABLE(encrypt_strings), DISABLE(NUMBERS))
// return 1
// end
//
// VM(VM|FSM|WEAVE|FLAT|NONE|RND) selects the dispatcher. RND picks VM, FSM, or WEAVE for this function on each run. NONE stays native Lua.
// ENABLE(...) replaces the strategy set. ENABLE(ALL) is the --all set.
// DISABLE(...) then removes a group or one strategy. DISABLE(ALL) clears it.
// Clauses apply as VM, then ENABLE, then DISABLE. Names are case-insensitive.}
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* Version : v1.0.0
* Language : Java
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
import com.pelock.luavirtualizer.CodeVirtualization;
import com.pelock.luavirtualizer.LuaVirtualizer;
import com.pelock.luavirtualizer.LuaVirtualizerResult;
import com.pelock.luavirtualizer.RenameStyle;
public class LuaVirtualizerExample {
public static void main(String[] args) throws Exception {
LuaVirtualizer client = new LuaVirtualizer("ABCD-ABCD-ABCD-ABCD");
client.enableCompression = false;
client.renameStyle = RenameStyle.IL;
// auto omits the POST field. Explicit: 5.1, 5.2, 5.3, 5.4, 5.5, luajit, luau.
client.target = "auto";
// code virtualization (exactly one): VM, FSM, WEAVE, FLAT, or RND. RND picks VM, FSM, or WEAVE per run and not FLAT. Leave unset to skip.
client.codeVirtualization = CodeVirtualization.VM;
client.selfDefending = true;
client.protectionLinker = true;
client.detectDebugger = true;
client.antiVm = true;
client.antiSandbox = true;
client.antiEmulator = true;
client.renameVariables = true;
client.renameParameters = true;
client.renameFunctions = true;
client.renameFunctionCalls = true;
client.shuffleFunctions = true;
client.resolveConstants = true;
client.splitStrings = true;
client.modifyStrings = true;
client.encryptStrings = true;
client.stringCharArrayVault = true;
client.encryptIntegers = true;
client.encryptFloating = true;
client.mbaBinops = true;
client.integersToFloating = true;
client.integersToArrays = true;
client.floatsToArrays = true;
client.affineIntegerMask = true;
client.arrayIntCrypt = true;
client.arrayCharCrypt = true;
client.arrayDoubleCrypt = true;
client.arrayStringCrypt = true;
client.insertRandomValueBucket = true;
client.randomBucketIntegers = true;
client.randomBucketArrays = true;
client.randomBucketFunctions = true;
client.randomBucketCharacters = true;
client.randomBucketAntiRegex = true;
client.randomBucketAutostart = true;
client.insertTernaryOperators = true;
client.complexifyBooleans = true;
client.opaqueBranches = true;
client.opaqueMixerChain = true;
client.insertDeadCode = true;
client.tryFinallyNoise = true;
client.decoyFunctions = true;
client.lambdaDecoys = true;
client.literalPadding = true;
client.fakeImportMarkers = true;
client.dynamicGetattrCalls = true;
client.obfuscateImports = true;
client.callbackRegistrationStubs = true;
client.removeComments = true;
String scriptSourceCode =
"local function greet(name)\n"
+ " print(\"Hello, \" .. name)\n"
+ "end\n"
+ "greet(\"Lua\")\n";
LuaVirtualizerResult result = client.virtualizeScriptSource(scriptSourceCode);
if (result != null && result.isSuccess() && result.getOutput() != null) {
System.out.println(result.getOutput());
System.out.println(result.getTarget());
} else {
throw new IllegalStateException(
"An error occurred, error code: " + (result == null ? "null" : result.getError()));
}
}
}
# frozen_string_literal: true
###############################################################################
#
# Lua Virtualizer — every public option
#
# Version : v1.0.0
# Language : Ruby
# Author : Bartosz Wójcik
# Web page : https://www.pelock.com
#
###############################################################################
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
require "lua-virtualizer"
client = LuaVirtualizer.new("YOUR-WEB-API-KEY")
client.enable_compression = false
client.rename_style = LuaVirtualizer::RenameStyle::IL
# auto omits the POST field. Explicit: 5.1, 5.2, 5.3, 5.4, 5.5, luajit, luau.
client.target = LuaVirtualizer::Target::AUTO
# code virtualization (exactly one): VM, FSM, WEAVE, FLAT, or RND. RND picks VM, FSM, or WEAVE per run and not FLAT. Leave unset to skip.
client.code_virtualization = LuaVirtualizer::CodeVirtualization::VM
client.self_defending = true
client.protection_linker = true
client.detect_debugger = true
client.anti_vm = true
client.anti_sandbox = true
client.anti_emulator = true
client.rename_variables = true
client.rename_parameters = true
client.rename_functions = true
client.rename_function_calls = true
client.shuffle_functions = true
client.resolve_constants = true
client.split_strings = true
client.modify_strings = true
client.encrypt_strings = true
client.string_char_array_vault = true
client.encrypt_integers = true
client.encrypt_floating = true
client.mba_binops = true
client.integers_to_floating = true
client.integers_to_arrays = true
client.floats_to_arrays = true
client.affine_integer_mask = true
client.array_int_crypt = true
client.array_char_crypt = true
client.array_double_crypt = true
client.array_string_crypt = true
client.insert_random_value_bucket = true
client.random_bucket_integers = true
client.random_bucket_arrays = true
client.random_bucket_functions = true
client.random_bucket_characters = true
client.random_bucket_anti_regex = true
client.random_bucket_autostart = true
client.insert_ternary_operators = true
client.complexify_booleans = true
client.opaque_branches = true
client.opaque_mixer_chain = true
client.insert_dead_code = true
client.try_finally_noise = true
client.decoy_functions = true
client.lambda_decoys = true
client.literal_padding = true
client.fake_import_markers = true
client.dynamic_getattr_calls = true
client.obfuscate_imports = true
client.callback_registration_stubs = true
client.remove_comments = true
source = <<~LUA
local function greet(name)
print("Hello, " .. name)
end
greet("Lua")
LUA
result = client.virtualize_script_source(source)
if result && result["error"] == LuaVirtualizer::ERROR_SUCCESS
puts result["output"]
puts result["target"]
else
warn "Error: #{result.inspect}"
end
# Per-function marker (source syntax, not a library import). The marker is the
# first statement of a function. The engine reads it and strips it.
#
# local function f()
# LUAVIRTUALIZER(VM(FSM), ENABLE(encrypt_strings), DISABLE(NUMBERS))
# return 1
# end
#
# VM(VM|FSM|WEAVE|FLAT|NONE|RND) selects the dispatcher. RND picks VM, FSM, or WEAVE for this function on each run. NONE stays native Lua.
# ENABLE(...) replaces the strategy set. ENABLE(ALL) is the --all set.
# DISABLE(...) then removes a group or one strategy. DISABLE(ALL) clears it.
# Clauses apply as VM, then ENABLE, then DISABLE. Names are case-insensitive.
#!/usr/bin/env bash
###############################################################################
#
# Lua Virtualizer REST interface usage example.
#
# In this example we will virtualize sample source with custom options.
#
# Version : v1.0.0
# Language : curl
# Author : Bartosz Wójcik
# Web page : https://www.pelock.com
#
###############################################################################
#
# activation key (empty or invalid key runs demo mode)
#
API_KEY="ABCD-ABCD-ABCD-ABCD"
#
# source file
#
cat > script.lua << 'SRC'
local function greet(name)
print("Hello, " .. name)
end
greet("Lua")
SRC
#
# the sample sets rename_style to il and turns protection flags on.
# seed and randomization_density are null, and target is auto, so those
# fields are omitted. Compression stays off.
# REST does not accept compression or a source string.
#
# response body - virtualized script, saved as obfuscated.lua
# X-PELock-Result - JSON status next to the script:
#
# error - error code (0 = success)
# demo - demo mode (invalid or empty activation key)
# license_expiration - license end date, empty if none
# usages_total - total runs for this activation code
# string_limit - max. source code size
#
# a failed call is HTTP 422 and a JSON body instead of the script
curl -sS -D - -o obfuscated.lua \
-H "Authorization: Bearer ${API_KEY}" \
-F "file=@script.lua" \
-F "code_virtualization=vm" \
-F "rename_style=il" \
-F "self_defending=1" \
-F "protection_linker=1" \
-F "detect_debugger=1" \
-F "anti_vm=1" \
-F "anti_sandbox=1" \
-F "anti_emulator=1" \
-F "rename_variables=1" \
-F "rename_parameters=1" \
-F "rename_functions=1" \
-F "rename_function_calls=1" \
-F "shuffle_functions=1" \
-F "resolve_constants=1" \
-F "split_strings=1" \
-F "modify_strings=1" \
-F "encrypt_strings=1" \
-F "string_char_array_vault=1" \
-F "encrypt_integers=1" \
-F "encrypt_floating=1" \
-F "mba_binops=1" \
-F "integers_to_floating=1" \
-F "integers_to_arrays=1" \
-F "floats_to_arrays=1" \
-F "affine_integer_mask=1" \
-F "array_int_crypt=1" \
-F "array_char_crypt=1" \
-F "array_double_crypt=1" \
-F "array_string_crypt=1" \
-F "insert_random_value_bucket=1" \
-F "random_bucket_integers=1" \
-F "random_bucket_arrays=1" \
-F "random_bucket_functions=1" \
-F "random_bucket_characters=1" \
-F "random_bucket_anti_regex=1" \
-F "random_bucket_autostart=1" \
-F "insert_ternary_operators=1" \
-F "complexify_booleans=1" \
-F "opaque_branches=1" \
-F "opaque_mixer_chain=1" \
-F "insert_dead_code=1" \
-F "try_finally_noise=1" \
-F "decoy_functions=1" \
-F "lambda_decoys=1" \
-F "literal_padding=1" \
-F "fake_import_markers=1" \
-F "dynamic_getattr_calls=1" \
-F "obfuscate_imports=1" \
-F "callback_registration_stubs=1" \
-F "remove_comments=1" \
"https://www.pelock.com/api/lua-virtualizer/v1/virtualize"
#!/usr/bin/env python
###############################################################################
#
# Lua Virtualizer WebApi interface usage example.
#
# In this example we will verify our activation key status.
#
# Version : v1.0.0
# Language : Python
# Author : Bartosz Wójcik
# Web page : https://www.pelock.com
#
###############################################################################
#
# include Lua Virtualizer module
#
from luavirtualizer import LuaVirtualizer
#
# if you don't want to use Python module, you can import directly from the file
#
#from pelock.luavirtualizer import LuaVirtualizer
#
# create Lua Virtualizer class instance (we are using our activation key)
#
myLuaVirtualizer = LuaVirtualizer("ABCD-ABCD-ABCD-ABCD")
#
# login to the service
#
result = myLuaVirtualizer.login()
#
# result[] array holds the information about the license
#
# result["demo"] - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
# result["license_expiration"] - license end date (Y-m-d), empty if none
# result["usages_total"] - total obfuscations for this activation code
# result["string_limit"] - max. source code size allowed (it's 1000 bytes for demo mode)
#
if result:
print(f'Demo version status - {"True" if result["demo"] else "False"}')
print(f'License expiration - {result.get("license_expiration")}')
print(f'Total obfuscations - {result.get("usages_total")}')
print(f'Max. source code size - {result["string_limit"]}')
else:
print("Something unexpected happen while trying to login to the service.")
<?php
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* In this example we will verify our activation key status.
*
* Version : v1.0
* Language : PHP
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
//
// include Lua Virtualizer class
//
use PELock\LuaVirtualizer\LuaVirtualizer;
//
// if you don't want to use Composer use include_once
//
//include_once "LuaVirtualizer.php";
//
// create Lua Virtualizer class instance (we are using our activation key)
//
$myLuaVirtualizer = new LuaVirtualizer("ABCD-ABCD-ABCD-ABCD");
//
// login to the service
//
$result = $myLuaVirtualizer->Login();
//
// $result[] array holds the information about the license
//
// $result["demo"] - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
// $result["license_expiration"] - license end date (Y-m-d), empty if none
// $result["usages_total"] - total obfuscations for this activation code
// $result["string_limit"] - Max. source code size allowed (it's 1000 bytes for demo mode)
//
if ($result !== false)
{
echo "Demo version status - " . ($result["demo"] ? "true" : "false") . "<br>";
echo "License expiration - " . $result["license_expiration"] . "<br>";
echo "Total obfuscations - " . $result["usages_total"] . "<br>";
echo "Max. source code size - " . $result["string_limit"] . "<br>";
}
else
{
die("Something unexpected happen while trying to login to the service.");
}
?>
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* In this example we will verify our activation key status.
*
* Version : v1.0.0
* Language : JavaScript
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
import LuaVirtualizer from "lua-virtualizer";
//
// include Lua Virtualizer class
//
//
// when developing from a repository clone without installing the package use:
//
// import LuaVirtualizer from "../src/lua-virtualizer.js";
//
// create Lua Virtualizer class instance (we are using our activation key)
//
const myLuaVirtualizer = new LuaVirtualizer("ABCD-ABCD-ABCD-ABCD");
//
// login to the service
//
const result = await myLuaVirtualizer.login();
//
// result object holds the information about the license
//
// result.demo - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
// result.license_expiration - license end date (Y-m-d), empty if none
// result.usages_total - total obfuscations for this activation code
// result.string_limit - Max. source code size allowed (it's 1000 bytes for demo mode)
//
if (result !== null) {
console.log("Demo version status - " + (result.demo ? "true" : "false"));
console.log("License expiration - " + result.license_expiration);
console.log("Total obfuscations - " + result.usages_total);
console.log("Max. source code size - " + result.string_limit);
} else {
throw new Error("Something unexpected happen while trying to login to the service.");
}
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* In this example we will verify our activation key status.
*
* Version : v1.0.0
* Language : Rust
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
use lua_virtualizer::{LuaVirtualizer, LuaVirtualizerResponse};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
//
// include Lua Virtualizer class
//
//
// if you don't want to use crates.io use a path dependency to this crate
//
// [dependencies]
// lua-virtualizer = { path = ".." }
//
// create Lua Virtualizer class instance (we are using our activation key)
//
let my_lua_virtualizer =
LuaVirtualizer::new(Some("ABCD-ABCD-ABCD-ABCD".to_string()));
//
// login to the service
//
let result = my_lua_virtualizer.login(true).await;
//
// result object holds the information about the license
//
// result.demo - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
// result.license_expiration - license end date (Y-m-d), empty if none
// result.usages_total - total obfuscations for this activation code
// result.string_limit - max. source code size allowed (it's 1000 bytes for demo mode)
//
match result {
Some(LuaVirtualizerResponse::Object(obj)) => {
println!(
"Demo version status - {}",
if obj.demo.unwrap_or(false) {
"true"
} else {
"false"
}
);
println!(
"License expiration - {:?}",
obj.license_expiration
);
println!(
"Total obfuscations - {}",
obj.usages_total.unwrap_or(0)
);
println!(
"Max. source code size - {}",
obj.string_limit.unwrap_or(0)
);
}
Some(LuaVirtualizerResponse::Json(_)) => {}
None => {
return Err("Something unexpected happen while trying to login to the service.".into());
}
}
Ok(())
}
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* In this example we will verify our activation key status.
*
* Version : v1.0.0
* Language : C#
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
using PELock.LuaVirtualizer;
//
// create Lua Virtualizer class instance (we are using our activation key)
//
var myLuaVirtualizer = new LuaVirtualizer("ABCD-ABCD-ABCD-ABCD");
//
// login to the service
//
var result = await myLuaVirtualizer.LoginAsync();
//
// result object holds the information about the license
//
// result?.Demo - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
// result?.LicenseExpiration - license end date (Y-m-d), empty if none
// result?.UsagesTotal - total obfuscations for this activation code
// result?.StringLimit - Max. source code size allowed (it's 1000 bytes for demo mode)
//
if (result is not null)
{
Console.WriteLine("Demo version status - " + (result.Demo == true ? "true" : "false"));
Console.WriteLine("License expiration - " + result.LicenseExpiration);
Console.WriteLine("Total obfuscations - " + result.UsagesTotal);
Console.WriteLine("Max. source code size - " + result.StringLimit);
}
else
{
throw new InvalidOperationException("Something unexpected happen while trying to login to the service.");
}
################################################################################
#
# Lua Virtualizer WebApi interface usage example.
#
# In this example we will verify our activation key status.
#
# Version : v1.0.0
# Language : PowerShell
# Author : Bartosz Wójcik
# Web page : https://www.pelock.com
#
################################################################################
#
# include Lua Virtualizer module
#
# After Install-Module / Install-PSResource:
# using module LuaVirtualizer
#
using module '..\luavirtualizer\LuaVirtualizer.psd1'
#
# create Lua Virtualizer class instance (we are using our activation key)
#
$myLuaVirtualizer = [LuaVirtualizer]::new('ABCD-ABCD-ABCD-ABCD')
#
# login to the service
#
$result = $myLuaVirtualizer.Login()
#
# $result holds the information about the license
#
# $result.demo - demo mode (missing or invalid key); limited to 1000 bytes; the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field
# $result.license_expiration - license end date (Y-m-d), empty if none
# $result.usages_total - total obfuscations for this activation code
# $result.string_limit - max. source code size allowed (it's 1000 bytes for demo mode)
#
if ($result) {
$demoStatus = if ($result.demo) { 'True' } else { 'False' }
Write-Host ("Demo version status - {0}" -f $demoStatus)
Write-Host ("License expiration - {0}" -f $result.license_expiration)
Write-Host ("Total obfuscations - {0}" -f $result.usages_total)
Write-Host ("Max. source code size - {0}" -f $result.string_limit)
}
else {
Write-Host 'Something unexpected happen while trying to login to the service.'
}
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* Version : v1.0.0
* Language : Go
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
package main
import (
"context"
"fmt"
"os"
luavirtualizer "github.com/PELock/Lua-Virtualizer-Go"
)
func main() {
// A missing or invalid key is limited to 1000 bytes and the server applies
// only flat code virtualization (code_virtualization=flat), ignoring every
// other strategy field.
client := luavirtualizer.New("ABCD-ABCD-ABCD-ABCD")
result, err := client.Login(context.Background())
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Printf("Demo version status - %v\n", result.Demo)
fmt.Printf("License expiration - %s\n", result.LicenseExpiration)
fmt.Printf("Total obfuscations - %d\n", result.UsagesTotal)
fmt.Printf("Max. source code size - %d\n", result.StringLimit)
}
/******************************************************************************
* Lua Virtualizer WebApi interface usage example.
*
* A missing or invalid key is limited to 1000 bytes and the server applies
* only flat code virtualization (code_virtualization=flat), ignoring every
* other strategy field.
*
* Version : v1.0.0
* Language : Java
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
import com.pelock.luavirtualizer.LuaVirtualizer;
import com.pelock.luavirtualizer.LuaVirtualizerResult;
public class LuaVirtualizerExampleIsDemo {
public static void main(String[] args) throws Exception {
LuaVirtualizer client = new LuaVirtualizer("ABCD-ABCD-ABCD-ABCD");
LuaVirtualizerResult result = client.login();
if (result == null) {
throw new IllegalStateException("Something unexpected happen while trying to login to the service.");
}
System.out.println("Demo version status - " + result.getDemo());
System.out.println("License expiration - " + result.getLicenseExpiration());
System.out.println("Total obfuscations - " + result.getUsagesTotal());
System.out.println("Max. source code size - " + result.getStringLimit());
System.out.println("Dialect - " + result.getTarget());
}
}
# frozen_string_literal: true
###############################################################################
#
# Lua Virtualizer — login
#
# Version : v1.0.0
# Language : Ruby
# Author : Bartosz Wójcik
# Web page : https://www.pelock.com
#
###############################################################################
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
require "lua-virtualizer"
p LuaVirtualizer.new("YOUR-WEB-API-KEY").login
# A missing or invalid key is limited to 1000 bytes and the server applies only flat code virtualization (code_virtualization=flat), ignoring every other strategy field.
#!/usr/bin/env bash
###############################################################################
#
# Lua Virtualizer REST interface usage example.
#
# In this example we will verify our activation key status.
#
# Version : v1.0.0
# Language : curl
# Author : Bartosz Wójcik
# Web page : https://www.pelock.com
#
###############################################################################
#
# activation key (empty or invalid key runs demo mode)
#
API_KEY="ABCD-ABCD-ABCD-ABCD"
#
# login to the service
#
# JSON body:
#
# demo - demo mode (invalid or empty activation key)
# license_expiration - license end date, empty if none
# usages_total - total runs for this activation code
# string_limit - max. source code size
curl -sS \
-H "Authorization: Bearer ${API_KEY}" \
"https://www.pelock.com/api/lua-virtualizer/v1/license"
command=virtualize)A missing or invalid key enables demo mode, which discards strategy fields and applies only code_virtualization=flat. The demo source limit is 1000 bytes. A licensed key allows 10000000 bytes. When not in demo mode, each strategy is a separate boolean field (defaults are false unless your client sends true, 1, or yes).
command [in]virtualize virtualizes and obfuscates the Lua source in source. obfuscate is still accepted and does the same work. login validates key and returns the license fields without virtualizing.key [in]source [in]compression [in, optional]seed [in, optional]randomization_density [in, optional]rename_style [in, optional]il (identifier-like), o0, hex, or mangled. Ignored in demo mode.code_virtualization [in, optional]vm, fsm, weave, flat, or rnd. rnd picks vm, fsm, or weave for that run. flat is not in the draw. Omit this field to skip virtualization. Demo mode discards the posted value and applies flat.target [in, optional]auto tries the source as Lua 5.1, then 5.2, 5.3, 5.4, 5.5, then Luau, and keeps the oldest dialect that parses. Explicit 5.1, 5.2, 5.3, 5.4, 5.5, luajit, or luau forces that dialect. LuaJIT is never inferred. A script whose only newer feature is goto is detected as 5.2, because goto was introduced in Lua 5.2. Pass luajit when the script must be treated as LuaJIT. Demo mode ignores target.Strategy booleans:
| Virtualization | |
|---|---|
code_virtualization (vm | fsm | weave | flat | rnd, CLI --code-virtualization). rnd picks vm, fsm, or weave for that run. flat is not in the draw. Omit this field to skip virtualization. Demo mode applies flat only. | |
| Protection & renaming | |
self_defending (CLI --self-defending) | protection_linker (CLI --protection-linker, requires self_defending) |
rename_variables | rename_parameters |
rename_functions | rename_function_calls |
shuffle_functions | resolve_constants |
| Strings | |
split_strings | modify_strings |
encrypt_strings | string_char_array_vault |
| Numeric | |
encrypt_integers | mba_binops |
integers_to_floating | encrypt_floating |
integers_to_arrays | floats_to_arrays |
affine_integer_mask | |
| Encrypted array literals | |
array_int_crypt | array_char_crypt |
array_double_crypt | array_string_crypt |
| Decoy value pools | |
insert_random_value_bucket | random_bucket_integers |
random_bucket_arrays | random_bucket_functions |
random_bucket_characters | random_bucket_anti_regex |
random_bucket_autostart | |
| Opaque predicates & noise | |
insert_ternary_operators | complexify_booleans |
opaque_branches | opaque_mixer_chain |
insert_dead_code | try_finally_noise |
| Decoys | |
decoy_functions | lambda_decoys (alias scriptblock_decoys) |
literal_padding | fake_import_markers (alias fake_dot_source_markers) |
dynamic_getattr_calls (alias reflect_invoke_commands) | obfuscate_imports |
callback_registration_stubs (alias event_stub) | |
| Anti-analysis | |
detect_debugger (CLI --detect-debugger) | anti_vm |
anti_sandbox | anti_emulator |
Early probes run at the start of the script and silently terminate on a hit. detect_debugger: debug.gethook() and Windows IsDebuggerPresent. anti_sandbox: CPU cores fewer than 3, Sandboxie DLLs/registry, Joe Sandbox processes, analysis host/user/path/env. anti_vm: VMware / VirtualBox / Parallels / KVM (processes, files, drivers, BIOS registry, MAC OUI, platform; Linux DMI off Windows). anti_emulator: WINE, Bochs/QEMU, XEN, emulator markers and a timing self-check. | |
| Other | |
remove_comments | seed (integer, optional) |
randomization_density (integer 0-100, optional) | rename_style (il | o0 | hex | mangled, optional) |
Legacy field names (scriptblock_decoys, fake_dot_source_markers, reflect_invoke_commands, event_stub) are accepted as backward-compatible aliases and mapped to their primary names.
$result["error"] [out]| Name | Value | Description |
|---|---|---|
| ERROR_SUCCESS | 0 |
Everything went fine. |
| ERROR_INPUT_SIZE | 1 |
Source code size is too big. Demo mode allows 1000 bytes. A licensed key allows 10000000 bytes. |
| ERROR_INPUT | 2 |
Malformed or empty source code. |
| ERROR_PARSING | 3 |
Lua source code parsing error, check the syntax. |
| ERROR_OBFUSCATION | 4 |
Error while virtualizing the parsed Lua code. |
| ERROR_OUTPUT | 5 |
Error while generating virtualized output code. |
$result["output"] [out, optional]$result["demo"] [out]$result["license_expiration"] [out, optional]Y-m-d), empty if the license does not expire.$result["usages_total"] [out, optional]$result["string_limit"] [out, optional]$result["target"] [out, optional]5.1, 5.2, 5.3, 5.4, 5.5, luajit, or luau).The source field is Lua source. These client libraries call the Web API:
| PHP Library | LuaVirtualizer |
| Python 3 Module | LuaVirtualizer |
| JavaScript Module | LuaVirtualizer |
| Rust Crate | LuaVirtualizer |
| C# / .NET Library | PELock.LuaVirtualizer |
Decorators are markers written in the Lua source. There is no separate package and no install command. Put LUAVIRTUALIZER as the first statement of a function body. The marker parses as ordinary Lua. The engine reads it, strips it, and never emits it.
VM(...) selects the dispatcher for that function. ENABLE(...) replaces the function's strategy set with the named groups or strategies. DISABLE(...) then removes the named groups or strategies. Clauses apply as VM, then ENABLE, then DISABLE, whatever order they are written in. Names are case-insensitive. ENABLE(ALL) is the same set --all turns on (every strategy except the four probes). DISABLE(ALL) clears every strategy. self_defending and protection_linker are not decorator names. They stay script-wide.
decoy_functions, every BUCKET strategy, callback_registration_stubs, and the PROTECT probes are inserted once for the whole script. A function ENABLE or DISABLE does not turn those passes on or off. A VM(...) nested inside VM(NONE) stays native Lua.
| Category | Name | Description |
|---|---|---|
| Virtualizations | ||
| Virtualization | VM(VM) |
A word is a permuted opcode plus A, B, C, and Bx. The encrypted blob is a read-only code image. The Lua 5.1 shell fetches __vll_code[pc] and calls __vll_hs[__vll_map[opcode]]. Four decoy handlers share the table. A jump stores an absolute program counter. Exactly one mode applies to a function. |
| Virtualization | VM(FSM) |
Same compiler, blob, and handler table as VM(VM). The outer loop is shifted, and an opaque gate reads the virtual program counter before the live handler. |
| Virtualization | VM(WEAVE) |
Same compiler and encrypted blob. Registers, constants, and instruction words share one table. Three superoperators cover load-and-arithmetic, compare-and-branch, and the call exit. A back-edge rewrites the words it will fetch again. Host calls are the only exit. |
| Virtualization | VM(FLAT) |
Same compiler and handler table. The loop form is shifted again, and the opaque gate mixes the virtual program counter with the running checksum. |
| Virtualization | VM(RND) |
Each run picks VM(VM), VM(FSM), or VM(WEAVE) for this function. VM(FLAT) is not in the draw. The same seed repeats the choice. Nested functions inherit it unless they set their own VM(...). A VM(RND) nested inside VM(NONE) stays native Lua. |
| Virtualization | VM(NONE) |
Leave this function, and every function nested inside it, as ordinary Lua. |
| Groups | ||
| Group | NAMES |
rename_variables, rename_parameters, rename_functions, rename_function_calls, resolve_constants. |
| Group | STRINGS |
split_strings, modify_strings, string_char_array_vault, encrypt_strings, array_string_crypt. |
| Group | NUMBERS |
integers_to_arrays, floats_to_arrays, affine_integer_mask, encrypt_integers, integers_to_floating, encrypt_floating, mba_binops, array_int_crypt, array_char_crypt, array_double_crypt. |
| Group | BOOLEANS |
complexify_booleans, insert_ternary_operators. |
| Group | SHAPE |
decoy_functions, lambda_decoys, insert_dead_code, opaque_branches, opaque_mixer_chain, try_finally_noise, literal_padding, fake_import_markers, shuffle_functions. decoy_functions is inserted for the whole script. |
| Group | BUCKET |
insert_random_value_bucket, random_bucket_integers, random_bucket_arrays, random_bucket_functions, random_bucket_characters, random_bucket_anti_regex, random_bucket_autostart. Inserted for the whole script. |
| Group | CALLS |
dynamic_getattr_calls, obfuscate_imports, callback_registration_stubs. callback_registration_stubs is inserted for the whole script. |
| Group | COMMENTS |
remove_comments. |
| Group | PROTECT |
detect_debugger, anti_vm, anti_sandbox, anti_emulator. Inserted for the whole script. A positive detection ends the process with no error message. |
| Group | ALL |
ENABLE(ALL) selects every strategy except the four probes. DISABLE(ALL) clears every strategy, including the probes. |
| Strategies | ||
| Strategy | rename_variables | NAMES. Local and global variables become random identifiers. Every reference updates together, and scope rules stay intact. |
| Strategy | rename_parameters | NAMES. Parameter names and in-body bindings are rewritten to opaque tokens. |
| Strategy | rename_functions | NAMES. Function definitions are renamed and calls are retargeted. Metamethods such as __index and built-in library functions stay untouched. |
| Strategy | rename_function_calls | NAMES. Direct call sites look up the target through a name table instead of the literal identifier. |
| Strategy | resolve_constants | NAMES. Module-level constants are inlined at every use, and unused declarations are removed. |
| Strategy | split_strings | STRINGS. Literals are split into chunks and joined at runtime, so the whole token is no longer in one place. |
| Strategy | modify_strings | STRINGS. Literals are rewritten as shifted characters and rebuilt by a small runtime transform. |
| Strategy | string_char_array_vault | STRINGS. Strings are rebuilt from numeric character codes instead of quoted text. |
| Strategy | encrypt_strings | STRINGS. Each run emits a unique per-string decryptor. Two outputs do not share the same algorithm shape. |
| Strategy | array_string_crypt | STRINGS. String table elements are encrypted independently and rebuilt on demand. |
| Strategy | integers_to_arrays | NUMBERS. Integers are stored in tables and read by index, with decoy entries mixed in. |
| Strategy | floats_to_arrays | NUMBERS. Floats are lifted into table slots, with decoy values mixed in. |
| Strategy | affine_integer_mask | NUMBERS. Reversible bit masks wrap integers without changing the result. The helper matches the selected dialect. |
| Strategy | encrypt_integers | NUMBERS. Plain integers become equivalent arithmetic or bitwise expressions. |
| Strategy | integers_to_floating | NUMBERS. Whole numbers are reconstructed from math expressions and cast back with math.floor. |
| Strategy | encrypt_floating | NUMBERS. Floating-point literals become equivalent math expressions. |
| Strategy | mba_binops | NUMBERS. Binary operators are replaced with mixed boolean-arithmetic identities. |
| Strategy | array_int_crypt | NUMBERS. Integer table contents are stored encrypted and decoded at runtime. |
| Strategy | array_char_crypt | NUMBERS. Character table literals are stored encrypted and restored by generated decoder code. |
| Strategy | array_double_crypt | NUMBERS. Float table constants are hidden as encoded bit patterns and reconstructed while the program runs. |
| Strategy | complexify_booleans | BOOLEANS. Simple true/false tests are rewritten into longer equivalent conditions. |
| Strategy | insert_ternary_operators | BOOLEANS. Simple branches collapse into and/or conditional expressions. |
| Strategy | decoy_functions | SHAPE. Plausible functions that are never called. Inserted for the whole script. |
| Strategy | lambda_decoys | SHAPE. Unused anonymous functions near the top of the script. They are never called. |
| Strategy | insert_dead_code | SHAPE. Statements under opaque never-true conditions. The result of the script stays the same. |
| Strategy | opaque_branches | SHAPE. Always-false branches that look like real control flow. |
| Strategy | opaque_mixer_chain | SHAPE. Mixer functions and guards that never change the returned value. |
| Strategy | try_finally_noise | SHAPE. Lua has no try/finally, so the pass emits an inert pcall plus cleanup. |
| Strategy | literal_padding | SHAPE. A bulky string constant that live logic never reads. It shifts line numbers and inflates the file. |
| Strategy | fake_import_markers | SHAPE. Comments that mimic extra require calls. remove_comments deletes them. |
| Strategy | shuffle_functions | SHAPE. Permutes top-level function definitions when the execution order stays valid. |
| Strategy | insert_random_value_bucket | BUCKET. Enables the module-level decoy pools. Inserted for the whole script. |
| Strategy | random_bucket_integers | BUCKET. Unused integer decoys in the pool. Inserted for the whole script. |
| Strategy | random_bucket_arrays | BUCKET. Unused table decoys in the pool. Inserted for the whole script. |
| Strategy | random_bucket_functions | BUCKET. Unused function decoys in the pool. Inserted for the whole script. |
| Strategy | random_bucket_characters | BUCKET. Unused character decoys in the pool. Inserted for the whole script. |
| Strategy | random_bucket_anti_regex | BUCKET. Regex-shaped decoy literals. Inserted for the whole script. |
| Strategy | random_bucket_autostart | BUCKET. Decoy strings that resemble autostart paths and are never used by live code. Inserted for the whole script. |
| Strategy | dynamic_getattr_calls | CALLS. Call targets are built from fragments and resolved through a table lookup. |
| Strategy | obfuscate_imports | CALLS. require is rewritten so the module name is built at runtime. Those strings stay available for later string encryption. |
| Strategy | callback_registration_stubs | CALLS. Snippets that resemble callback registration and never wire an event source. Inserted for the whole script. |
| Strategy | remove_comments | COMMENTS. Removes -- comments from the emitted script. |
| Strategy | detect_debugger | PROTECT. Detects a debugger attached to the process (debug.gethook(), and IsDebuggerPresent on Windows). Inserted for the whole script. A positive detection ends the process with no error message. |
| Strategy | anti_vm | PROTECT. Detects VMware, VirtualBox, Parallels, KVM, and Linux DMI product or vendor strings. Inserted for the whole script. |
| Strategy | anti_sandbox | PROTECT. Detects a very low CPU count, Sandboxie, Joe Sandbox, and analysis-host tokens. Inserted for the whole script. |
| Strategy | anti_emulator | PROTECT. Detects WINE, Bochs, QEMU, XEN, and a short timing self-check. Inserted for the whole script. |
Each marker is the first statement of its function. The engine removes the marker before it emits the script.
-- VM(VM): compile this function to the private opcode virtual machine.
local function vm_bonus(points)
LUAVIRTUALIZER(VM(VM))
return math.floor(points * 1.25)
end
-- VM(FSM): run this function as a finite-state machine (FSM).
local function fsm_state(ok)
LUAVIRTUALIZER(VM(FSM))
if ok then return "ready" else return "wait" end
end
-- VM(WEAVE): one mutable tape and three superoperators.
local function weave_inc(n)
LUAVIRTUALIZER(VM(WEAVE))
return n + 1
end
-- VM(FLAT): same handler table, with the gate mixed from pc and the running checksum.
local function flat_add(a, b)
LUAVIRTUALIZER(VM(FLAT))
return a + b
end
-- VM(RND): each run picks VM, FSM, or WEAVE for this function. FLAT is not in the draw.
local function rnd_scale(n)
LUAVIRTUALIZER(VM(RND))
return n * 2
end
-- VM(NONE): leave this function, and functions nested inside it, as ordinary Lua.
local function native_tag(text)
LUAVIRTUALIZER(VM(NONE))
return "[" .. text .. "]"
end
-- ENABLE(ALL): replace this function's set with every strategy --all turns on.
local function keep_all(n)
LUAVIRTUALIZER(ENABLE(ALL))
return n + 1
end
-- DISABLE(ALL): turn off every strategy in this function.
local function clear_text(a, b)
LUAVIRTUALIZER(DISABLE(ALL))
return a .. ":" .. b
end
-- ENABLE(encrypt_strings): one strategy. The rest of the set is replaced, not added.
local function only_one(token)
LUAVIRTUALIZER(ENABLE(encrypt_strings))
return "token=" .. token
end
-- ENABLE(encrypt_strings, mba_binops): a comma list of strategies.
local function only_selected(token, n)
LUAVIRTUALIZER(ENABLE(encrypt_strings, mba_binops))
return token .. ":" .. tostring(n + 2)
end
-- DISABLE(NAMES): leave out the renaming strategies and resolve_constants.
local function keep_names(user, domain)
LUAVIRTUALIZER(DISABLE(NAMES))
return user .. "@" .. domain
end
-- DISABLE(STRINGS): leave out string splitting, rewriting, and encryption.
local function keep_strings(token)
LUAVIRTUALIZER(DISABLE(STRINGS))
return "token=" .. token
end
-- DISABLE(NUMBERS): leave out integer, float, and mixed-boolean arithmetic passes.
local function keep_numbers(price)
LUAVIRTUALIZER(DISABLE(NUMBERS))
return price * 2 + 10
end
-- DISABLE(BOOLEANS): leave out complexify_booleans and insert_ternary_operators.
local function keep_bools(flag)
LUAVIRTUALIZER(DISABLE(BOOLEANS))
if flag then return 1 else return 0 end
end
-- ENABLE(ALL), then DISABLE(STRINGS). Written order does not change the result.
local function enable_minus_strings(token)
LUAVIRTUALIZER(ENABLE(ALL), DISABLE(STRINGS))
return "kept=" .. token
end
-- VM(FSM), then ENABLE(ALL), then DISABLE(encrypt_strings) and the NUMBERS group.
local function mixed(label, n)
LUAVIRTUALIZER(VM(FSM), ENABLE(ALL), DISABLE(encrypt_strings, NUMBERS))
return label .. "=" .. tostring(n)
end
-- DISABLE(SHAPE), DISABLE(CALLS), and DISABLE(COMMENTS) name those groups.
local function keep_shape(n)
LUAVIRTUALIZER(DISABLE(SHAPE))
return n * n
end
local function keep_calls(name)
LUAVIRTUALIZER(DISABLE(CALLS))
return string.upper(name)
end
local function keep_comments(n)
LUAVIRTUALIZER(DISABLE(COMMENTS))
-- this note can survive when comment removal is skipped
return n
end
If you would like to ask me about Lua Virtualizer, or something's not clear, mail me. I'll be happy to answer all of your questions.