Zautomatyzuj wirtualizację i obfuskację skryptów Lua przez Web API. Automatyczne wykrywanie dialektu obejmuje Lua 5.1–5.5 i Luau, a tryb demo stosuje wyłącznie płaską wirtualizację kodu.
Możesz skorzystać ze wszystkich funkcji programu Lua Virtualizer poprzez interfejs Web API. Web API bazuje na zapytaniach POST i zwraca odpowiedzi zakodowane w formacie JSON. Punkt końcowy to POST https://www.pelock.com/api/lua-virtualizer/v1.
W celu szybszego wdrożenia paczki instalacyjne interfejsu Web API programu Lua Virtualizer zostały wgrane na popularne repozytoria (PyPI, Packagist, npm, crates.io, NuGet, PowerShell Gallery, pkg.go.dev, Maven, RubyGems). Kody źródłowe zostały dodatkowo opublikowane na GitHubie:
| Repozytorium | Język | Instalacja | Paczka | Źródła |
|---|---|---|---|---|
![]() |
Python | pip install lua-virtualizer |
PyPI | GitHub |
![]() |
PHP | Uruchom:
lub dodaj poniższy wpis do sekcji |
Packagist | GitHub |
![]() |
JavaScript | Uruchom:
lub dodaj poniższy wpis do sekcji |
npm | GitHub |
![]() |
Rust | Uruchom:
lub dodaj poniższy wpis do sekcji |
Crates | GitHub |
![]() |
C# | Uruchom:
lub dodaj do pliku |
NuGet | GitHub |
![]() |
PowerShell | Uruchom:
lub:
|
PowerShell Gallery | GitHub |
![]() |
Go | Uruchom:
lub dodaj poniższy wpis do pliku |
Go | GitHub |
![]() |
Java | Dodaj tę zależność do pliku pom.xml |
Maven | GitHub |
![]() |
Ruby | Uruchom:
lub dodaj poniższy wpis do pliku |
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
Pominięcie pola target albo wysłanie auto wykrywa dialekt. target=luajit albo target=5.4 wymusza ten dialekt.
#!/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 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.
command=virtualize)Brakujący albo nieprawidłowy key włącza tryb demo, który odrzuca pola strategii i stosuje wyłącznie code_virtualization=flat. Limit źródła w trybie demo to 1000 bajtów. Licencja pozwala na 10000000 bajtów. Poza trybem demo każda strategia to osobne logiczne pole (domyślnie false, chyba że klient wyśle true, 1 albo yes).
command [in]virtualize wirtualizuje i obfuskuje kod Lua w polu source. obfuscate jest nadal akceptowane i robi to samo. login sprawdza key i zwraca pola licencji bez wirtualizacji.key [in]source [in]compression [in, opcjonalne]seed [in, opcjonalne]randomization_density [in, opcjonalne]rename_style [in, opcjonalne]il (podobny do identyfikatora), o0, hex albo mangled. W trybie demo pole jest ignorowane.code_virtualization [in, opcjonalne]vm, fsm, weave, flat albo rnd. rnd wybiera vm, fsm albo weave dla tego przebiegu. flat nie wchodzi do losowania. Pomiń to pole, aby wyłączyć wirtualizację. Tryb demo odrzuca przesłaną wartość i stosuje flat.target [in, opcjonalne]auto próbuje źródła jako Lua 5.1, potem 5.2, 5.3, 5.4, 5.5, a następnie Luau i zostawia najstarszy dialekt, który się parsuje. Jawne 5.1, 5.2, 5.3, 5.4, 5.5, luajit albo luau wymusza ten dialekt. LuaJIT nigdy nie jest wnioskowany. Skrypt, którego jedyną nowszą cechą jest goto, jest wykrywany jako 5.2, bo goto wprowadzono w Lua 5.2. Podaj luajit, gdy skrypt ma być traktowany jako LuaJIT. Tryb demo ignoruje target.Logiczne pola strategii:
| Wirtualizacja | |
|---|---|
code_virtualization (vm | fsm | weave | flat | rnd, CLI --code-virtualization). rnd wybiera vm, fsm albo weave dla tego przebiegu. flat nie wchodzi do losowania. Pomiń to pole, aby wyłączyć wirtualizację. Tryb demo stosuje wyłącznie flat. | |
| Ochrona i zmiana nazw | |
self_defending (CLI --self-defending) | protection_linker (CLI --protection-linker, wymaga self_defending) |
rename_variables | rename_parameters |
rename_functions | rename_function_calls |
shuffle_functions | resolve_constants |
| Ciągi znakowe | |
split_strings | modify_strings |
encrypt_strings | string_char_array_vault |
| Wartości numeryczne | |
encrypt_integers | mba_binops |
integers_to_floating | encrypt_floating |
integers_to_arrays | floats_to_arrays |
affine_integer_mask | |
| Szyfrowane literały tablicowe | |
array_int_crypt | array_char_crypt |
array_double_crypt | array_string_crypt |
| Pule wartości-przynęt | |
insert_random_value_bucket | random_bucket_integers |
random_bucket_arrays | random_bucket_functions |
random_bucket_characters | random_bucket_anti_regex |
random_bucket_autostart | |
| Nieprzezroczyste predykaty i szum | |
insert_ternary_operators | complexify_booleans |
opaque_branches | opaque_mixer_chain |
insert_dead_code | try_finally_noise |
| Przynęty | |
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) | |
| Ochrona przed analizą | |
detect_debugger (CLI --detect-debugger) | anti_vm |
anti_sandbox | anti_emulator |
Sondy uruchamiane na początku skryptu; przy trafieniu proces jest zamykany po cichu. detect_debugger: debug.gethook() oraz Windows IsDebuggerPresent. anti_sandbox: mniej niż 3 rdzenie CPU, DLL/rejestr Sandboxie, procesy Joe Sandbox, host/użytkownik/ścieżki/środowisko analizy. anti_vm: VMware / VirtualBox / Parallels / KVM (procesy, pliki, sterowniki, rejestr BIOS, MAC OUI, platforma; Linux DMI poza Windows). anti_emulator: WINE, Bochs/QEMU, XEN, znaczniki emulatora i test czasu. | |
| Inne | |
remove_comments | seed (liczba całkowita, opcjonalne) |
randomization_density (liczba całkowita 0-100, opcjonalne) | rename_style (il | o0 | hex | mangled, opcjonalne) |
Starsze nazwy pól (scriptblock_decoys, fake_dot_source_markers, reflect_invoke_commands, event_stub) są akceptowane jako wstecznie kompatybilne aliasy i mapowane na główne nazwy.
$result["error"] [out]| Nazwa | Wartość | Opis |
|---|---|---|
| ERROR_SUCCESS | 0 |
Wszystko przebiegło pomyślnie. |
| ERROR_INPUT_SIZE | 1 |
Kod źródłowy jest zbyt duży. Tryb demo pozwala na 1000 bajtów. Licencja pozwala na 10000000 bajtów. |
| ERROR_INPUT | 2 |
Nieprawidłowy lub pusty kod źródłowy. |
| ERROR_PARSING | 3 |
Błąd parsowania kodu źródłowego Lua, sprawdź składnię. |
| ERROR_OBFUSCATION | 4 |
Błąd podczas wirtualizacji sparsowanego kodu Lua. |
| ERROR_OUTPUT | 5 |
Błąd podczas generowania zwirtualizowanego kodu wynikowego. |
$result["output"] [out, opcjonalne]$result["demo"] [out]$result["license_expiration"] [out, opcjonalne]Y-m-d), pusta jeśli licencja nie wygasa.$result["usages_total"] [out, opcjonalne]$result["string_limit"] [out, opcjonalne]$result["target"] [out, opcjonalne]5.1, 5.2, 5.3, 5.4, 5.5, luajit albo luau).Pole source zawiera źródło Lua. Poniższe biblioteki klienckie wywołują Web API:
| Biblioteka PHP | LuaVirtualizer |
| Moduł Python 3 | LuaVirtualizer |
| Moduł JavaScript | LuaVirtualizer |
| Crate Rust | LuaVirtualizer |
| Biblioteka C# / .NET | PELock.LuaVirtualizer |
Dekoratory to znaczniki zapisane w źródle Lua. Nie ma osobnego pakietu i nie ma polecenia instalacji. Umieść LUAVIRTUALIZER jako pierwszą instrukcję ciała funkcji. Znacznik parsuje się jak zwykły kod Lua. Silnik odczytuje go, usuwa i nigdy nie emituje.
VM(...) wybiera dyspozytor dla tej funkcji. ENABLE(...) zastępuje zestaw strategii funkcji nazwanymi grupami albo strategiami. DISABLE(...) następnie usuwa nazwane grupy albo strategie. Klauzule działają jako VM, potem ENABLE, potem DISABLE, niezależnie od kolejności w źródle. Nazwy nie rozróżniają wielkości liter. ENABLE(ALL) to ten sam zestaw, który włącza --all (każda strategia poza czterema sondami). DISABLE(ALL) czyści każdą strategię. self_defending i protection_linker nie są nazwami dekoratorów. Dotyczą całego skryptu.
decoy_functions, każda strategia BUCKET, callback_registration_stubs i sondy PROTECT są wstawiane raz dla całego skryptu. ENABLE albo DISABLE na funkcji nie włącza i nie wyłącza tych przebiegów. VM(...) zagnieżdżone w VM(NONE) zostaje natywnym kodem Lua.
| Kategoria | Nazwa | Opis |
|---|---|---|
| Wirtualizacje | ||
| Wirtualizacja | VM(VM) |
Słowo to permutowany opcode oraz A, B, C i Bx. Zaszyfrowany blob jest obrazem kodu tylko do odczytu. Powłoka Lua 5.1 pobiera __vll_code[pc] i wywołuje __vll_hs[__vll_map[opcode]]. Cztery fałszywe handlery dzielą tabelę. Skok zapisuje bezwzględny licznik programu. Na funkcję przypada dokładnie jeden tryb. |
| Wirtualizacja | VM(FSM) |
Ten sam kompilator, blob i tabela handlerów co VM(VM). Pętla zewnętrzna jest przesunięta, a nieprzezroczysta bramka czyta wirtualny licznik programu przed żywym handlerem. |
| Wirtualizacja | VM(WEAVE) |
Ten sam kompilator i zaszyfrowany blob. Rejestry, stałe i słowa instrukcji dzielą jedną tabelę. Trzy superoperatory pokrywają ładowanie z arytmetyką, porównanie ze skokiem i wyjście wywołania. Krawędź powrotna ponownie zapisuje słowa, które zaraz pobierze. Wywołania hosta są jedynym wyjściem. |
| Wirtualizacja | VM(FLAT) |
Ten sam kompilator i ta sama tabela handlerów. Kształt pętli jest przesunięty ponownie, a nieprzezroczysta bramka miesza wirtualny licznik programu z bieżącą sumą kontrolną. |
| Wirtualizacja | VM(RND) |
Każdy przebieg wybiera VM(VM), VM(FSM) albo VM(WEAVE) dla tej funkcji. VM(FLAT) nie wchodzi do losowania. Ten sam seed powtarza wybór. Funkcje zagnieżdżone dziedziczą go, chyba że ustawią własne VM(...). VM(RND) zagnieżdżone w VM(NONE) zostaje natywnym kodem Lua. |
| Wirtualizacja | VM(NONE) |
Zostawia tę funkcję i każdą funkcję w niej zagnieżdżoną jako zwykły kod Lua. |
| Grupy | ||
| Grupa | NAMES |
rename_variables, rename_parameters, rename_functions, rename_function_calls, resolve_constants. |
| Grupa | STRINGS |
split_strings, modify_strings, string_char_array_vault, encrypt_strings, array_string_crypt. |
| Grupa | 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. |
| Grupa | BOOLEANS |
complexify_booleans, insert_ternary_operators. |
| Grupa | 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 jest wstawiane dla całego skryptu. |
| Grupa | BUCKET |
insert_random_value_bucket, random_bucket_integers, random_bucket_arrays, random_bucket_functions, random_bucket_characters, random_bucket_anti_regex, random_bucket_autostart. Wstawiane dla całego skryptu. |
| Grupa | CALLS |
dynamic_getattr_calls, obfuscate_imports, callback_registration_stubs. callback_registration_stubs jest wstawiane dla całego skryptu. |
| Grupa | COMMENTS |
remove_comments. |
| Grupa | PROTECT |
detect_debugger, anti_vm, anti_sandbox, anti_emulator. Wstawiane dla całego skryptu. Pozytywna detekcja kończy proces bez komunikatu błędu. |
| Grupa | ALL |
ENABLE(ALL) wybiera każdą strategię poza czterema sondami. DISABLE(ALL) czyści każdą strategię, łącznie z sondami. |
| Strategie | ||
| Strategia | rename_variables | NAMES. Zmienne lokalne i globalne otrzymują losowe identyfikatory. Wszystkie odwołania są poprawiane razem, a zasięg zostaje zachowany. |
| Strategia | rename_parameters | NAMES. Nazwy parametrów i powiązania w ciele funkcji są zastępowane nieczytelnymi tokenami. |
| Strategia | rename_functions | NAMES. Definicje funkcji zmieniają nazwy, a wywołania są przekierowywane. Metametody takie jak __index i wbudowane funkcje bibliotek pozostają nietknięte. |
| Strategia | rename_function_calls | NAMES. Bezpośrednie wywołania szukają celu w tabeli nazw zamiast po jawnym identyfikatorze. |
| Strategia | resolve_constants | NAMES. Stałe z poziomu modułu są wstawiane w miejscu użycia, a nieużywane deklaracje usuwane. |
| Strategia | split_strings | STRINGS. Literały są dzielone na fragmenty i składane w trakcie działania, więc cały token nie stoi już w jednym miejscu. |
| Strategia | modify_strings | STRINGS. Literały są zapisywane jako przesunięte znaki i odtwarzane niewielką transformacją w czasie działania. |
| Strategia | string_char_array_vault | STRINGS. Łańcuchy są odtwarzane z kodów znaków zamiast tekstu w cudzysłowie. |
| Strategia | encrypt_strings | STRINGS. Każde uruchomienie generuje unikalny deszyfrator ciągu. Dwa wyniki nie mają tego samego kształtu algorytmu. |
| Strategia | array_string_crypt | STRINGS. Elementy tablic tekstowych są szyfrowane niezależnie i odtwarzane na żądanie. |
| Strategia | integers_to_arrays | NUMBERS. Liczby całkowite trafiają do tablic i są odczytywane po indeksie, razem z wpisami-przynętami. |
| Strategia | floats_to_arrays | NUMBERS. Liczby zmiennoprzecinkowe są przenoszone do tablic, z celowo zaciemnionymi wartościami pomiędzy. |
| Strategia | affine_integer_mask | NUMBERS. Odwracalne maski bitowe otaczają liczby całkowite bez zmiany wyniku. Helper jest dobierany do wybranego dialektu. |
| Strategia | encrypt_integers | NUMBERS. Proste liczby całkowite stają się równoważnymi wyrażeniami arytmetycznymi albo bitowymi. |
| Strategia | integers_to_floating | NUMBERS. Liczby całkowite są odtwarzane z wyrażeń biblioteki math i rzutowane przez math.floor. |
| Strategia | encrypt_floating | NUMBERS. Literały zmiennoprzecinkowe stają się równoważnymi wyrażeniami math. |
| Strategia | mba_binops | NUMBERS. Operatory binarne są zastępowane tożsamościami mieszanymi boolowsko-arytmetycznymi. |
| Strategia | array_int_crypt | NUMBERS. Zawartość tablic liczb całkowitych jest przechowywana w formie zaszyfrowanej i dekodowana w trakcie działania. |
| Strategia | array_char_crypt | NUMBERS. Literały tablic znaków są przechowywane zaszyfrowane i odtwarzane przez wygenerowany kod dekodujący. |
| Strategia | array_double_crypt | NUMBERS. Stałe tablic zmiennoprzecinkowych są ukrywane jako zakodowane wzorce bitowe i odtwarzane w trakcie działania. |
| Strategia | complexify_booleans | BOOLEANS. Proste testy true/false są przepisywane na dłuższe, równoważne warunki. |
| Strategia | insert_ternary_operators | BOOLEANS. Proste rozgałęzienia zwijają się w wyrażenia warunkowe and/or. |
| Strategia | decoy_functions | SHAPE. Wiarygodnie wyglądające funkcje, które nigdy nie są wywoływane. Wstawiane dla całego skryptu. |
| Strategia | lambda_decoys | SHAPE. Nieużywane funkcje anonimowe przy początku skryptu. Nigdy nie są wywoływane. |
| Strategia | insert_dead_code | SHAPE. Instrukcje pod zawsze fałszywymi warunkami. Wynik skryptu się nie zmienia. |
| Strategia | opaque_branches | SHAPE. Zawsze fałszywe gałęzie, które wyglądają jak prawdziwy przepływ sterowania. |
| Strategia | opaque_mixer_chain | SHAPE. Funkcje-miksery i zabezpieczenia, które nie zmieniają zwracanej wartości. |
| Strategia | try_finally_noise | SHAPE. Lua nie ma try/finally, więc przebieg wstawia obojętne pcall i sprzątanie. |
| Strategia | literal_padding | SHAPE. Duża stała tekstowa, której żywa logika nigdy nie czyta. Przesuwa numery linii i powiększa plik. |
| Strategia | fake_import_markers | SHAPE. Komentarze imitujące dodatkowe wywołania require. remove_comments je usuwa. |
| Strategia | shuffle_functions | SHAPE. Przestawia definicje funkcji najwyższego poziomu, gdy kolejność wykonania nadal jest poprawna. |
| Strategia | insert_random_value_bucket | BUCKET. Włącza pule przynęt na poziomie modułu. Wstawiane dla całego skryptu. |
| Strategia | random_bucket_integers | BUCKET. Nieużywane przynęty liczbowe w puli. Wstawiane dla całego skryptu. |
| Strategia | random_bucket_arrays | BUCKET. Nieużywane przynęty w postaci tablic. Wstawiane dla całego skryptu. |
| Strategia | random_bucket_functions | BUCKET. Nieużywane funkcje-przynęty w puli. Wstawiane dla całego skryptu. |
| Strategia | random_bucket_characters | BUCKET. Nieużywane przynęty znakowe w puli. Wstawiane dla całego skryptu. |
| Strategia | random_bucket_anti_regex | BUCKET. Literały o kształcie wyrażeń regularnych. Wstawiane dla całego skryptu. |
| Strategia | random_bucket_autostart | BUCKET. Przynęty tekstowe przypominające ścieżki autostartu, nigdy nieużywane przez żywy kod. Wstawiane dla całego skryptu. |
| Strategia | dynamic_getattr_calls | CALLS. Cele wywołań są budowane z fragmentów i rozwiązywane przez odczyt z tabeli. |
| Strategia | obfuscate_imports | CALLS. require jest przepisywane tak, aby nazwa modułu powstawała w czasie działania. Te ciągi zostają pod późniejsze szyfrowanie. |
| Strategia | callback_registration_stubs | CALLS. Fragmenty przypominają rejestrację callbacków i nigdy nie podpinają źródła zdarzeń. Wstawiane dla całego skryptu. |
| Strategia | remove_comments | COMMENTS. Usuwa komentarze -- z wygenerowanego skryptu. |
| Strategia | detect_debugger | PROTECT. Wykrywa debugger podłączony do procesu (debug.gethook() oraz IsDebuggerPresent w Windows). Wstawiane dla całego skryptu. Pozytywna detekcja kończy proces bez komunikatu błędu. |
| Strategia | anti_vm | PROTECT. Wykrywa VMware, VirtualBox, Parallels, KVM oraz ciągi DMI produktu lub producenta w Linuksie. Wstawiane dla całego skryptu. |
| Strategia | anti_sandbox | PROTECT. Wykrywa bardzo małą liczbę rdzeni, Sandboxie, Joe Sandbox i tokeny hostów analitycznych. Wstawiane dla całego skryptu. |
| Strategia | anti_emulator | PROTECT. Wykrywa WINE, Bochs, QEMU, XEN i krótki samotest czasu. Wstawiane dla całego skryptu. |
Każdy znacznik jest pierwszą instrukcją swojej funkcji. Silnik usuwa znacznik, zanim wyemituje skrypt.
-- VM(VM): kompiluje tę funkcję do prywatnej maszyny wirtualnej.
local function vm_bonus(points)
LUAVIRTUALIZER(VM(VM))
return math.floor(points * 1.25)
end
-- VM(FSM): uruchamia tę funkcję jako skończony automat stanów (FSM).
local function fsm_state(ok)
LUAVIRTUALIZER(VM(FSM))
if ok then return "ready" else return "wait" end
end
-- VM(WEAVE): jedna mutowalna taśma i trzy superoperatory.
local function weave_inc(n)
LUAVIRTUALIZER(VM(WEAVE))
return n + 1
end
-- VM(FLAT): ta sama tabela handlerów, bramka z pc i bieżącej sumy kontrolnej.
local function flat_add(a, b)
LUAVIRTUALIZER(VM(FLAT))
return a + b
end
-- VM(NONE): zostawia tę funkcję i funkcje w niej zagnieżdżone jako zwykły kod Lua.
-- VM(RND): każdy przebieg wybiera VM, FSM albo WEAVE dla tej funkcji. FLAT nie wchodzi do losowania.
local function rnd_scale(n)
LUAVIRTUALIZER(VM(RND))
return n * 2
end
local function native_tag(text)
LUAVIRTUALIZER(VM(NONE))
return "[" .. text .. "]"
end
-- ENABLE(ALL): zastępuje zestaw tej funkcji każdą strategią, którą włącza --all.
local function keep_all(n)
LUAVIRTUALIZER(ENABLE(ALL))
return n + 1
end
-- DISABLE(ALL): wyłącza każdą strategię w tej funkcji.
local function clear_text(a, b)
LUAVIRTUALIZER(DISABLE(ALL))
return a .. ":" .. b
end
-- ENABLE(encrypt_strings): jedna strategia. Reszta zestawu jest zastępowana, nie dokładana.
local function only_one(token)
LUAVIRTUALIZER(ENABLE(encrypt_strings))
return "token=" .. token
end
-- ENABLE(encrypt_strings, mba_binops): lista strategii rozdzielona przecinkami.
local function only_selected(token, n)
LUAVIRTUALIZER(ENABLE(encrypt_strings, mba_binops))
return token .. ":" .. tostring(n + 2)
end
-- DISABLE(NAMES): pomija strategie zmiany nazw i resolve_constants.
local function keep_names(user, domain)
LUAVIRTUALIZER(DISABLE(NAMES))
return user .. "@" .. domain
end
-- DISABLE(STRINGS): pomija dzielenie, przepisywanie i szyfrowanie ciągów.
local function keep_strings(token)
LUAVIRTUALIZER(DISABLE(STRINGS))
return "token=" .. token
end
-- DISABLE(NUMBERS): pomija przebiegi liczb całkowitych, zmiennoprzecinkowych i mieszanej arytmetyki.
local function keep_numbers(price)
LUAVIRTUALIZER(DISABLE(NUMBERS))
return price * 2 + 10
end
-- DISABLE(BOOLEANS): pomija complexify_booleans i insert_ternary_operators.
local function keep_bools(flag)
LUAVIRTUALIZER(DISABLE(BOOLEANS))
if flag then return 1 else return 0 end
end
-- ENABLE(ALL), potem DISABLE(STRINGS). Kolejność w źródle nie zmienia wyniku.
local function enable_minus_strings(token)
LUAVIRTUALIZER(ENABLE(ALL), DISABLE(STRINGS))
return "kept=" .. token
end
-- VM(FSM), potem ENABLE(ALL), potem DISABLE(encrypt_strings) i grupa NUMBERS.
local function mixed(label, n)
LUAVIRTUALIZER(VM(FSM), ENABLE(ALL), DISABLE(encrypt_strings, NUMBERS))
return label .. "=" .. tostring(n)
end
-- DISABLE(SHAPE), DISABLE(CALLS) i DISABLE(COMMENTS) nazywają te grupy.
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))
-- ta notatka może zostać, gdy pomijane jest usuwanie komentarzy
return n
end
Jeśli masz jakieś pytania dotyczące programu Lua Virtualizer, masz jakieś uwagi, coś jest niejasne, napisz do mnie, chętnie odpowiem na każde Twoje pytanie.