Zautomatyzuj obfuskację i wirtualizację kodów źródłowych skryptów Python przez elastyczny interfejs Web API dla programistów.
Możesz skorzystać ze wszystkich funkcji Python Obfuscatora poprzez interfejs Web API. Web API bazuje na zapytaniach POST i zwraca odpowiedzi zakodowane w formacie JSON.
W celu szybszego wdrożenia paczki instalacyjne interfejsu Web API Python Obfuscatora zostały wgrane na popularne repozytoria (Packagist, PyPI, npm, crates.io, NuGet). Kody źródłowe zostały dodatkowo opublikowane na GitHubie:
| Repozytorium | Język | Instalacja | Paczka | Źródła |
|---|---|---|---|---|
![]() |
PHP | Uruchom:
lub dodaj poniższy wpis do sekcji |
Packagist | GitHub |
![]() |
Python | pip install python-obfuscator-virtualizer |
PyPI | 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 |
<?php
/******************************************************************************
* Python Obfuscator 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 Python Obfuscator class
//
use PELock\PythonObfuscator;
//
// if you don't want to use Composer use include_once
//
//include_once "PythonObfuscator.php";
//
// create Python Obfuscator class instance (we are using our activation key)
//
$myPythonObfuscator = new PELock\PythonObfuscator("ABCD-ABCD-ABCD-ABCD");
//
// source code in Python format
//
$scriptSourceCode = "label = 'SecretKey'
port = 443
def get_sum(a, b):
return a + b
print(label, port)
r = get_sum(11, 31)
print(r)
";
//
// by default all obfuscation options are enabled, so we can just simply call:
//
$result = $myPythonObfuscator->ObfuscateScriptSource($scriptSourceCode);
//
// it's also possible to pass a Python script file path instead of a string e.g.
//
// $result = $myPythonObfuscator->ObfuscateScriptFile("/path/to/project/script.py");
//
// $result[] array holds the obfuscation results as well as other information
//
// $result["error"] - error code
// $result["output"] - obfuscated code
// $result["demo"] - was it used in demo mode (invalid or empty activation key was used)
// $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\PythonObfuscator::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.");
}
?>
#!/usr/bin/env python
###############################################################################
#
# Python Obfuscator 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 Python Obfuscator module
#
from pythonobfuscator import PythonObfuscator
#
# if you don't want to use Python module, you can import directly from the file
#
#from pelock.pythonobfuscator import PythonObfuscator
#
# create Python Obfuscator class instance (we are using our activation key)
#
myPythonObfuscator = PythonObfuscator("ABCD-ABCD-ABCD-ABCD")
#
# source code in Python format
#
scriptSourceCode = """label = 'SecretKey'
port = 443
def get_sum(a, b):
return a + b
print(label, port)
r = get_sum(11, 31)
print(r)
"""
#
# by default all obfuscation options are enabled, so we can just simply call
#
result = myPythonObfuscator.obfuscate_script_source(scriptSourceCode)
#
# it's also possible to pass a Python script file path instead of a string with the source e.g.
#
# result = myPythonObfuscator.obfuscate_script_file("/path/to/project/script.py")
#
# result[] array holds the obfuscation results as well as other information
#
# result["error"] - error code
# result["output"] - obfuscated code
# result["demo"] - was it used in demo mode (invalid or empty activation key was used)
# 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"] == PythonObfuscator.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.")
/******************************************************************************
* Python Obfuscator 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 PythonObfuscator from "python-obfuscator";
//
// include Python Obfuscator class
//
//
// when developing from a repository clone without installing the package use:
//
// import PythonObfuscator from "../src/python-obfuscator.js";
//
// create Python Obfuscator class instance (we are using our activation key)
//
const myPythonObfuscator = new PythonObfuscator("ABCD-ABCD-ABCD-ABCD");
//
// source code in Python format
//
const scriptSourceCode = `label = 'SecretKey'
port = 443
def get_sum(a, b):
return a + b
print(label, port)
r = get_sum(11, 31)
print(r)
`;
//
// by default all obfuscation options are enabled, so we can just simply call:
//
const result = await myPythonObfuscator.obfuscateScriptSource(scriptSourceCode);
//
// it's also possible to pass a Python script file path instead of a string e.g.
//
// const result = await myPythonObfuscator.obfuscateScriptFile("/path/to/project/script.py");
//
// result object holds the obfuscation results as well as other information
//
// result.error - error code
// result.output - obfuscated code
// result.demo - was it used in demo mode (invalid or empty activation key was used)
// 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 === PythonObfuscator.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.");
}
/******************************************************************************
* Python Obfuscator 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 python_obfuscator::{PythonObfuscator, PythonObfuscatorResponse};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
//
// include Python Obfuscator class
//
//
// when developing from a repository clone without installing the package use:
//
// use python_obfuscator::{PythonObfuscator, PythonObfuscatorResponse};
// (path dependency in Cargo.toml pointing to this crate)
//
// create Python Obfuscator class instance (we are using our activation key)
//
let my_python_obfuscator =
PythonObfuscator::new(Some("ABCD-ABCD-ABCD-ABCD".to_string()));
//
// source code in Python format
//
let script_source_code = r#"label = 'SecretKey'
port = 443
def get_sum(a, b):
return a + b
print(label, port)
r = get_sum(11, 31)
print(r)"#;
//
// by default all obfuscation options are enabled, so we can just simply call:
//
let result = my_python_obfuscator
.obfuscate_script_source(script_source_code, true)
.await;
//
// it's also possible to pass a Python script file path instead of a string e.g.
//
// let result = my_python_obfuscator
// .obfuscate_script_file(std::path::Path::new("/path/to/project/script.py"), true)
// .await;
//
// result object holds the obfuscation results as well as other information
//
// result.error - error code
// result.output - obfuscated code
// result.demo - was it used in demo mode (invalid or empty activation key was used)
// result.license_expiration - license end date (Y-m-d), empty if none
// result.usages_total - total obfuscations for this activation code
//
match result {
Some(PythonObfuscatorResponse::Object(obj)) => {
//
// display obfuscated code
//
if obj.error == PythonObfuscator::ERROR_SUCCESS {
println!("{}", obj.output.unwrap_or_default());
} else {
return Err(
format!("An error occurred, error code: {}", obj.error).into(),
);
}
}
Some(PythonObfuscatorResponse::Json(_)) => {}
None => {
return Err("Something unexpected happen while trying to obfuscate the code.".into());
}
}
Ok(())
}
/******************************************************************************
* Python Obfuscator 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.PythonObfuscator;
//
// create Python Obfuscator class instance (we are using our activation key)
//
var myPythonObfuscator = new PythonObfuscator("ABCD-ABCD-ABCD-ABCD");
//
// source code in Python format
//
const string ScriptSourceCode =
"""
label = 'SecretKey'
port = 443
def get_sum(a, b):
return a + b
print(label, port)
r = get_sum(11, 31)
print(r)
""";
//
// by default all obfuscation options are enabled, so we can just simply call:
//
var result = await myPythonObfuscator.ObfuscateScriptSourceAsync(ScriptSourceCode);
//
// it's also possible to pass a Python script file path instead of a string e.g.
//
// var result = await myPythonObfuscator.ObfuscateScriptFileAsync("/path/to/project/script.py");
//
// result object holds the obfuscation results as well as other information
//
// result?.Error - error code (see PythonObfuscator.Error*)
// result?.Output - obfuscated code
// result?.Demo - was it used in demo mode (invalid or empty activation key was used)
// 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 == PythonObfuscator.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.");
}
<?php
/******************************************************************************
* Python Obfuscator WebApi interface usage example.
*
* In this example we will obfuscate sample source with custom options.
*
* Version : v1.0
* Language : PHP
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
//
// include Python Obfuscator class
//
use PELock\PythonObfuscator;
use PELock\PythonObfuscator\CodeVirtualization;
//
// if you don't want to use Composer use include_once
//
//include_once "PythonObfuscator.php";
//
// create Python Obfuscator class instance (we are using our activation key)
//
$myPythonObfuscator = new PELock\PythonObfuscator("ABCD-ABCD-ABCD-ABCD");
//
// should the source code be compressed (both input & compressed)
//
$myPythonObfuscator->enableCompression = false;
//
// code virtualization mode (exactly one): VM, FSA, or FLAT
// omit / set to null to skip virtualization
//
$myPythonObfuscator->codeVirtualization = CodeVirtualization::VM;
//
// global obfuscation options
//
// you can disable a particular obfuscation strategy globally if it
// fails or you don't want to use it without modifying the source codes
//
// by default all obfuscation strategies are enabled
//
//
// fixed random seed for reproducible obfuscation output (optional)
//
$myPythonObfuscator->seed = null;
//
// randomization density / intensity (0-100)
//
$myPythonObfuscator->randomizationDensity = null;
//
// identifier renaming style: "il", "homoglyph" or "hex"
//
$myPythonObfuscator->renameStyle = null;
//
// protection against tampering with protected code (integrity verification)
//
$myPythonObfuscator->selfDefending = false;
//
// protection linker (decoy call graph)
//
$myPythonObfuscator->protectionLinker = false;
//
// rename variable names to random string values
//
$myPythonObfuscator->renameVariables = true;
//
// rename parameter names to random string values
//
$myPythonObfuscator->renameParameters = true;
//
// rename function names to random string values
//
$myPythonObfuscator->renameFunctions = true;
//
// rename function call references consistently with renamed functions
//
$myPythonObfuscator->renameFunctionCalls = true;
//
// shuffle function order in the output source
//
$myPythonObfuscator->shuffleFunctions = true;
//
// fold/resolve constant expressions at obfuscation time
//
$myPythonObfuscator->resolveConstants = true;
//
//
// split strings into concatenated chunks
//
$myPythonObfuscator->splitStrings = true;
//
// apply light transformations/mutations to string literals
//
$myPythonObfuscator->modifyStrings = true;
//
// encrypt strings using randomly generated polymorphic encryption algorithms
//
$myPythonObfuscator->encryptStrings = true;
//
// store string fragments in char-code array vaults
//
$myPythonObfuscator->stringCharArrayVault = true;
//
// encrypt integers
//
$myPythonObfuscator->encryptIntegers = true;
//
// encrypt floating point numbers
//
$myPythonObfuscator->encryptFloating = true;
//
// replace binary operators with mixed boolean-arithmetic (MBA) equivalents
//
$myPythonObfuscator->mbaBinops = true;
//
// represent integers via floating-point math
//
$myPythonObfuscator->integersToFloating = true;
//
// move integers to arrays
//
$myPythonObfuscator->integersToArrays = true;
//
// move floats to arrays
//
$myPythonObfuscator->floatsToArrays = true;
//
// apply redundant xor / affine integer masks
//
$myPythonObfuscator->affineIntegerMask = true;
//
// encrypt integer array literals
//
$myPythonObfuscator->arrayIntCrypt = true;
//
// encrypt character array literals
//
$myPythonObfuscator->arrayCharCrypt = true;
//
// encrypt floating-point array literals
//
$myPythonObfuscator->arrayDoubleCrypt = true;
//
// encrypt string array literals
//
$myPythonObfuscator->arrayStringCrypt = true;
//
// insert a shared bucket of random noise values used by other strategies
//
$myPythonObfuscator->insertRandomValueBucket = true;
//
// populate the random value bucket with decoy integers
//
$myPythonObfuscator->randomBucketIntegers = true;
//
// populate the random value bucket with decoy arrays
//
$myPythonObfuscator->randomBucketArrays = true;
//
// populate the random value bucket with decoy functions
//
$myPythonObfuscator->randomBucketFunctions = true;
//
// populate the random value bucket with decoy characters
//
$myPythonObfuscator->randomBucketCharacters = true;
//
// populate the random value bucket with anti-regex decoy noise
//
$myPythonObfuscator->randomBucketAntiRegex = true;
//
// populate the random value bucket with autostart decoy stubs
//
$myPythonObfuscator->randomBucketAutostart = true;
//
// rewrite selected statements using ternary operators
//
$myPythonObfuscator->insertTernaryOperators = true;
//
// replace boolean conditions with equivalent complex expressions
//
$myPythonObfuscator->complexifyBooleans = true;
//
// insert opaque predicate branches
//
$myPythonObfuscator->opaqueBranches = true;
//
// insert opaque mixer chains into control flow
//
$myPythonObfuscator->opaqueMixerChain = true;
//
// insert dead code
//
$myPythonObfuscator->insertDeadCode = true;
//
// wrap code in try/finally blocks with dead noise
//
$myPythonObfuscator->tryFinallyNoise = true;
//
// insert decoy functions
//
$myPythonObfuscator->decoyFunctions = true;
//
// insert decoy lambda expressions
//
$myPythonObfuscator->lambdaDecoys = true;
//
// insert literal padding noise
//
$myPythonObfuscator->literalPadding = true;
//
// insert fake import statement markers
//
$myPythonObfuscator->fakeImportMarkers = true;
//
// use dynamic getattr()-based indirect calls
//
$myPythonObfuscator->dynamicGetattrCalls = true;
//
// rewrite absolute imports into __import__ / getattr
//
$myPythonObfuscator->obfuscateImports = true;
//
// insert dead callback/event registration stubs
//
$myPythonObfuscator->callbackRegistrationStubs = true;
//
// insert anti-debugging detections
//
$myPythonObfuscator->detectDebugger = false;
//
// insert virtual machine (anti-VM) detections
//
$myPythonObfuscator->antiVm = false;
//
// insert anti-sandbox detections
//
$myPythonObfuscator->antiSandbox = false;
//
// insert anti-emulators (CPU) detections
//
$myPythonObfuscator->antiEmulator = false;
//
// strip comments from the output source
//
$myPythonObfuscator->removeComments = true;
//
// source code in Python format
//
$scriptSourceCode = "label = 'SecretKey'
port = 443
def get_sum(a, b):
return a + b
print(label, port)
r = get_sum(11, 31)
print(r)
";
//
// by default all obfuscation options are enabled, so we can just simply call:
//
$result = $myPythonObfuscator->ObfuscateScriptSource($scriptSourceCode);
//
// it's also possible to pass a Python script file path instead of a string e.g.
//
// $result = $myPythonObfuscator->ObfuscateScriptFile("/path/to/project/script.py");
//
// $result[] array holds the obfuscation results as well as other information
//
// $result["error"] - error code
// $result["output"] - obfuscated code
// $result["demo"] - was it used in demo mode (invalid or empty activation key was used)
// $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\PythonObfuscator::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.");
}
?>
#!/usr/bin/env python
###############################################################################
#
# Python Obfuscator WebApi interface usage example.
#
# In this example we will obfuscate sample source with custom options.
#
# Version : v1.0.0
# Language : Python
# Author : Bartosz Wójcik
# Web page : https://www.pelock.com
#
###############################################################################
#
# include Python Obfuscator module
#
from pythonobfuscator import CodeVirtualization, PythonObfuscator
#
# if you don't want to use Python module, you can import directly from the file
#
#from pelock.pythonobfuscator import PythonObfuscator
#
# create Python Obfuscator class instance (we are using our activation key)
#
myPythonObfuscator = PythonObfuscator("ABCD-ABCD-ABCD-ABCD")
#
# should the source code be compressed (both input & compressed)
#
myPythonObfuscator.enable_compression = False
#
# code virtualization mode (exactly one): VM, FSA, or FLAT
# omit / set to None to skip virtualization
#
myPythonObfuscator.code_virtualization = CodeVirtualization.VM
#
# global obfuscation options
#
# you can disable a particular obfuscation strategy globally if it
# fails or you don't want to use it without modifying the source codes
#
# by default all obfuscation strategies are enabled
#
#
# fixed random seed for reproducible obfuscation output (optional)
#
myPythonObfuscator.seed = None
#
# randomization density / intensity (0-100)
#
myPythonObfuscator.randomization_density = None
#
# identifier renaming style: RenameStyle.IL, O0, CONFUSABLE, HEX, HOMOGLYPH, or MANGLED
#
myPythonObfuscator.rename_style = None
#
# protection against tampering with protected code (integrity verification)
#
myPythonObfuscator.self_defending = False
#
# protection linker (decoy call graph)
#
myPythonObfuscator.protection_linker = False
#
# rename variable names to random string values
#
myPythonObfuscator.rename_variables = True
#
# rename parameter names to random string values
#
myPythonObfuscator.rename_parameters = True
#
# rename function names to random string values
#
myPythonObfuscator.rename_functions = True
#
# rename function call references consistently with renamed functions
#
myPythonObfuscator.rename_function_calls = True
#
# shuffle function order in the output source
#
myPythonObfuscator.shuffle_functions = True
#
# fold/resolve constant expressions at obfuscation time
#
myPythonObfuscator.resolve_constants = True
#
# split strings into concatenated chunks
#
myPythonObfuscator.split_strings = True
#
# apply light transformations/mutations to string literals
#
myPythonObfuscator.modify_strings = True
#
# encrypt strings using randomly generated polymorphic encryption algorithms
#
myPythonObfuscator.encrypt_strings = True
#
# store string fragments in char-code array vaults
#
myPythonObfuscator.string_char_array_vault = True
#
# encrypt integers
#
myPythonObfuscator.encrypt_integers = True
#
# encrypt floating point numbers
#
myPythonObfuscator.encrypt_floating = True
#
# replace binary operators with mixed boolean-arithmetic (MBA) equivalents
#
myPythonObfuscator.mba_binops = True
#
# represent integers via floating-point math
#
myPythonObfuscator.integers_to_floating = True
#
# move integers to arrays
#
myPythonObfuscator.integers_to_arrays = True
#
# move floats to arrays
#
myPythonObfuscator.floats_to_arrays = True
#
# apply redundant xor / affine integer masks
#
myPythonObfuscator.affine_integer_mask = True
#
# encrypt integer array literals
#
myPythonObfuscator.array_int_crypt = True
#
# encrypt character array literals
#
myPythonObfuscator.array_char_crypt = True
#
# encrypt floating-point array literals
#
myPythonObfuscator.array_double_crypt = True
#
# encrypt string array literals
#
myPythonObfuscator.array_string_crypt = True
#
# insert a shared bucket of random noise values used by other strategies
#
myPythonObfuscator.insert_random_value_bucket = True
#
# populate the random value bucket with decoy integers
#
myPythonObfuscator.random_bucket_integers = True
#
# populate the random value bucket with decoy arrays
#
myPythonObfuscator.random_bucket_arrays = True
#
# populate the random value bucket with decoy functions
#
myPythonObfuscator.random_bucket_functions = True
#
# populate the random value bucket with decoy characters
#
myPythonObfuscator.random_bucket_characters = True
#
# populate the random value bucket with anti-regex decoy noise
#
myPythonObfuscator.random_bucket_anti_regex = True
#
# populate the random value bucket with autostart decoy stubs
#
myPythonObfuscator.random_bucket_autostart = True
#
# rewrite selected statements using ternary operators
#
myPythonObfuscator.insert_ternary_operators = True
#
# replace boolean conditions with equivalent complex expressions
#
myPythonObfuscator.complexify_booleans = True
#
# insert opaque predicate branches
#
myPythonObfuscator.opaque_branches = True
#
# insert opaque mixer chains into control flow
#
myPythonObfuscator.opaque_mixer_chain = True
#
# insert dead code
#
myPythonObfuscator.insert_dead_code = True
#
# wrap code in try/finally blocks with dead noise
#
myPythonObfuscator.try_finally_noise = True
#
# insert decoy functions
#
myPythonObfuscator.decoy_functions = True
#
# insert decoy lambda expressions
#
myPythonObfuscator.lambda_decoys = True
#
# insert literal padding noise
#
myPythonObfuscator.literal_padding = True
#
# insert fake import statement markers
#
myPythonObfuscator.fake_import_markers = True
#
# use dynamic getattr()-based indirect calls
#
myPythonObfuscator.dynamic_getattr_calls = True
#
# rewrite absolute imports into __import__ / getattr
#
myPythonObfuscator.obfuscate_imports = True
#
# insert dead callback/event registration stubs
#
myPythonObfuscator.callback_registration_stubs = True
#
# insert anti-debugging detections
#
myPythonObfuscator.detect_debugger = False
#
# insert virtual machine (anti-VM) detections
#
myPythonObfuscator.anti_vm = False
#
# insert anti-sandbox detections
#
myPythonObfuscator.anti_sandbox = False
#
# insert anti-emulators (CPU) detections
#
myPythonObfuscator.anti_emulator = False
#
# strip comments from the output source
#
myPythonObfuscator.remove_comments = True
#
# source code in Python format
#
scriptSourceCode = """label = 'SecretKey'
port = 443
def get_sum(a, b):
return a + b
print(label, port)
r = get_sum(11, 31)
print(r)
"""
#
# by default all obfuscation options are enabled, so we can just simply call
#
result = myPythonObfuscator.obfuscate_script_source(scriptSourceCode)
#
# it's also possible to pass a Python script file path instead of a string with the source e.g.
#
# result = myPythonObfuscator.obfuscate_script_file("/path/to/project/script.py")
#
# result[] array holds the obfuscation results as well as other information
#
# result["error"] - error code
# result["output"] - obfuscated code
# result["demo"] - was it used in demo mode (invalid or empty activation key was used)
# 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"] == PythonObfuscator.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.")
/******************************************************************************
* Python Obfuscator WebApi interface usage example.
*
* In this example we will obfuscate sample source with custom options.
*
* Version : v1.0.0
* Language : JavaScript
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
import PythonObfuscator, { CodeVirtualization } from "python-obfuscator";
//
// include Python Obfuscator class
//
//
// when developing from a repository clone without installing the package use:
//
// import PythonObfuscator from "../src/python-obfuscator.js";
//
// create Python Obfuscator class instance (we are using our activation key)
//
const myPythonObfuscator = new PythonObfuscator("ABCD-ABCD-ABCD-ABCD");
//
// should the source code be compressed (both input & compressed)
//
myPythonObfuscator.enableCompression = false;
//
// code virtualization mode (exactly one): VM, FSA, or FLAT
// omit / set to null to skip virtualization
//
myPythonObfuscator.codeVirtualization = CodeVirtualization.VM;
//
// global obfuscation options
//
// you can disable a particular obfuscation strategy globally if it
// fails or you don't want to use it without modifying the source codes
//
// by default all obfuscation strategies are enabled
//
//
// fixed random seed for reproducible obfuscation output (optional)
//
myPythonObfuscator.seed = null;
//
// randomization density / intensity (0-100)
//
myPythonObfuscator.randomizationDensity = null;
//
// identifier renaming style: "il", "homoglyph" or "hex"
//
myPythonObfuscator.renameStyle = null;
//
// protection against tampering with protected code (integrity verification)
//
myPythonObfuscator.selfDefending = false;
//
// protection linker (decoy call graph)
//
myPythonObfuscator.protectionLinker = false;
//
// rename variable names to random string values
//
myPythonObfuscator.renameVariables = true;
//
// rename parameter names to random string values
//
myPythonObfuscator.renameParameters = true;
//
// rename function names to random string values
//
myPythonObfuscator.renameFunctions = true;
//
// rename function call references consistently with renamed functions
//
myPythonObfuscator.renameFunctionCalls = true;
//
// shuffle function order in the output source
//
myPythonObfuscator.shuffleFunctions = true;
//
// fold/resolve constant expressions at obfuscation time
//
myPythonObfuscator.resolveConstants = true;
//
//
// split strings into concatenated chunks
//
myPythonObfuscator.splitStrings = true;
//
// apply light transformations/mutations to string literals
//
myPythonObfuscator.modifyStrings = true;
//
// encrypt strings using randomly generated polymorphic encryption algorithms
//
myPythonObfuscator.encryptStrings = true;
//
// store string fragments in char-code array vaults
//
myPythonObfuscator.stringCharArrayVault = true;
//
// encrypt integers
//
myPythonObfuscator.encryptIntegers = true;
//
// encrypt floating point numbers
//
myPythonObfuscator.encryptFloating = true;
//
// replace binary operators with mixed boolean-arithmetic (MBA) equivalents
//
myPythonObfuscator.mbaBinops = true;
//
// represent integers via floating-point math
//
myPythonObfuscator.integersToFloating = true;
//
// move integers to arrays
//
myPythonObfuscator.integersToArrays = true;
//
// move floats to arrays
//
myPythonObfuscator.floatsToArrays = true;
//
// apply redundant xor / affine integer masks
//
myPythonObfuscator.affineIntegerMask = true;
//
// encrypt integer array literals
//
myPythonObfuscator.arrayIntCrypt = true;
//
// encrypt character array literals
//
myPythonObfuscator.arrayCharCrypt = true;
//
// encrypt floating-point array literals
//
myPythonObfuscator.arrayDoubleCrypt = true;
//
// encrypt string array literals
//
myPythonObfuscator.arrayStringCrypt = true;
//
// insert a shared bucket of random noise values used by other strategies
//
myPythonObfuscator.insertRandomValueBucket = true;
//
// populate the random value bucket with decoy integers
//
myPythonObfuscator.randomBucketIntegers = true;
//
// populate the random value bucket with decoy arrays
//
myPythonObfuscator.randomBucketArrays = true;
//
// populate the random value bucket with decoy functions
//
myPythonObfuscator.randomBucketFunctions = true;
//
// populate the random value bucket with decoy characters
//
myPythonObfuscator.randomBucketCharacters = true;
//
// populate the random value bucket with anti-regex decoy noise
//
myPythonObfuscator.randomBucketAntiRegex = true;
//
// populate the random value bucket with autostart decoy stubs
//
myPythonObfuscator.randomBucketAutostart = true;
//
// rewrite selected statements using ternary operators
//
myPythonObfuscator.insertTernaryOperators = true;
//
// replace boolean conditions with equivalent complex expressions
//
myPythonObfuscator.complexifyBooleans = true;
//
// insert opaque predicate branches
//
myPythonObfuscator.opaqueBranches = true;
//
// insert opaque mixer chains into control flow
//
myPythonObfuscator.opaqueMixerChain = true;
//
// insert dead code
//
myPythonObfuscator.insertDeadCode = true;
//
// wrap code in try/finally blocks with dead noise
//
myPythonObfuscator.tryFinallyNoise = true;
//
// insert decoy functions
//
myPythonObfuscator.decoyFunctions = true;
//
// insert decoy lambda expressions
//
myPythonObfuscator.lambdaDecoys = true;
//
// insert literal padding noise
//
myPythonObfuscator.literalPadding = true;
//
// insert fake import statement markers
//
myPythonObfuscator.fakeImportMarkers = true;
//
// use dynamic getattr()-based indirect calls
//
myPythonObfuscator.dynamicGetattrCalls = true;
//
// rewrite absolute imports into __import__ / getattr
//
myPythonObfuscator.obfuscateImports = true;
//
// insert dead callback/event registration stubs
//
myPythonObfuscator.callbackRegistrationStubs = true;
//
// insert anti-debugging detections
//
myPythonObfuscator.detectDebugger = false;
//
// insert virtual machine (anti-VM) detections
//
myPythonObfuscator.antiVm = false;
//
// insert anti-sandbox detections
//
myPythonObfuscator.antiSandbox = false;
//
// insert anti-emulators (CPU) detections
//
myPythonObfuscator.antiEmulator = false;
//
// strip comments from the output source
//
myPythonObfuscator.removeComments = true;
//
// source code in Python format
//
const scriptSourceCode = `label = 'SecretKey'
port = 443
def get_sum(a, b):
return a + b
print(label, port)
r = get_sum(11, 31)
print(r)
`;
//
// by default all obfuscation options are enabled, so we can just simply call:
//
const result = await myPythonObfuscator.obfuscateScriptSource(scriptSourceCode);
//
// it's also possible to pass a Python script file path instead of a string e.g.
//
// const result = await myPythonObfuscator.obfuscateScriptFile("/path/to/project/script.py");
//
// result object holds the obfuscation results as well as other information
//
// result.error - error code
// result.output - obfuscated code
// result.demo - was it used in demo mode (invalid or empty activation key was used)
// 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 === PythonObfuscator.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.");
}
/******************************************************************************
* Python Obfuscator WebApi interface usage example.
*
* In this example we will obfuscate sample source with custom options.
*
* Version : v1.0.0
* Language : Rust
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
use python_obfuscator::{CodeVirtualization, PythonObfuscator, PythonObfuscatorResponse};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
//
// include Python Obfuscator class
//
//
// when developing from a repository clone without installing the package use:
//
// use python_obfuscator::{PythonObfuscator, PythonObfuscatorResponse};
// (path dependency in Cargo.toml pointing to this crate)
//
// create Python Obfuscator class instance (we are using our activation key)
//
let mut my_python_obfuscator =
PythonObfuscator::new(Some("ABCD-ABCD-ABCD-ABCD".to_string()));
//
// should the source code be compressed (both input & compressed)
//
my_python_obfuscator.enable_compression = false;
//
// code virtualization mode (exactly one): Vm, Fsa, or Flat
// omit / set to None to skip virtualization
//
my_python_obfuscator.code_virtualization = CodeVirtualization::Vm;
//
// global obfuscation options
//
// you can disable a particular obfuscation strategy globally if it
// fails or you don't want to use it without modifying the source codes
//
// by default all obfuscation strategies are enabled
//
//
// fixed random seed for reproducible obfuscation output (optional)
//
my_python_obfuscator.seed = None;
//
// randomization density / intensity (0-100)
//
my_python_obfuscator.randomization_density = None;
//
// identifier renaming style: "il", "homoglyph" or "hex"
//
my_python_obfuscator.rename_style = None;
//
// protection against tampering with protected code (integrity verification)
//
my_python_obfuscator.self_defending = false;
//
// protection linker (decoy call graph)
//
my_python_obfuscator.protection_linker = false;
//
// rename variable names to random string values
//
my_python_obfuscator.rename_variables = true;
//
// rename parameter names to random string values
//
my_python_obfuscator.rename_parameters = true;
//
// rename function names to random string values
//
my_python_obfuscator.rename_functions = true;
//
// rename function call references consistently with renamed functions
//
my_python_obfuscator.rename_function_calls = true;
//
// shuffle function order in the output source
//
my_python_obfuscator.shuffle_functions = true;
//
// fold/resolve constant expressions at obfuscation time
//
my_python_obfuscator.resolve_constants = true;
//
//
// split strings into concatenated chunks
//
my_python_obfuscator.split_strings = true;
//
// apply light transformations/mutations to string literals
//
my_python_obfuscator.modify_strings = true;
//
// encrypt strings using randomly generated polymorphic encryption algorithms
//
my_python_obfuscator.encrypt_strings = true;
//
// store string fragments in char-code array vaults
//
my_python_obfuscator.string_char_array_vault = true;
//
// encrypt integers
//
my_python_obfuscator.encrypt_integers = true;
//
// encrypt floating point numbers
//
my_python_obfuscator.encrypt_floating = true;
//
// replace binary operators with mixed boolean-arithmetic (MBA) equivalents
//
my_python_obfuscator.mba_binops = true;
//
// represent integers via floating-point math
//
my_python_obfuscator.integers_to_floating = true;
//
// move integers to arrays
//
my_python_obfuscator.integers_to_arrays = true;
//
// move floats to arrays
//
my_python_obfuscator.floats_to_arrays = true;
//
// apply redundant xor / affine integer masks
//
my_python_obfuscator.affine_integer_mask = true;
//
// encrypt integer array literals
//
my_python_obfuscator.array_int_crypt = true;
//
// encrypt character array literals
//
my_python_obfuscator.array_char_crypt = true;
//
// encrypt floating-point array literals
//
my_python_obfuscator.array_double_crypt = true;
//
// encrypt string array literals
//
my_python_obfuscator.array_string_crypt = true;
//
// insert a shared bucket of random noise values used by other strategies
//
my_python_obfuscator.insert_random_value_bucket = true;
//
// populate the random value bucket with decoy integers
//
my_python_obfuscator.random_bucket_integers = true;
//
// populate the random value bucket with decoy arrays
//
my_python_obfuscator.random_bucket_arrays = true;
//
// populate the random value bucket with decoy functions
//
my_python_obfuscator.random_bucket_functions = true;
//
// populate the random value bucket with decoy characters
//
my_python_obfuscator.random_bucket_characters = true;
//
// populate the random value bucket with anti-regex decoy noise
//
my_python_obfuscator.random_bucket_anti_regex = true;
//
// populate the random value bucket with autostart decoy stubs
//
my_python_obfuscator.random_bucket_autostart = true;
//
// rewrite selected statements using ternary operators
//
my_python_obfuscator.insert_ternary_operators = true;
//
// replace boolean conditions with equivalent complex expressions
//
my_python_obfuscator.complexify_booleans = true;
//
// insert opaque predicate branches
//
my_python_obfuscator.opaque_branches = true;
//
// insert opaque mixer chains into control flow
//
my_python_obfuscator.opaque_mixer_chain = true;
//
// insert dead code
//
my_python_obfuscator.insert_dead_code = true;
//
// wrap code in try/finally blocks with dead noise
//
my_python_obfuscator.try_finally_noise = true;
//
// insert decoy functions
//
my_python_obfuscator.decoy_functions = true;
//
// insert decoy lambda expressions
//
my_python_obfuscator.lambda_decoys = true;
//
// insert literal padding noise
//
my_python_obfuscator.literal_padding = true;
//
// insert fake import statement markers
//
my_python_obfuscator.fake_import_markers = true;
//
// use dynamic getattr()-based indirect calls
//
my_python_obfuscator.dynamic_getattr_calls = true;
//
// rewrite absolute imports into __import__ / getattr
//
my_python_obfuscator.obfuscate_imports = true;
//
// insert dead callback/event registration stubs
//
my_python_obfuscator.callback_registration_stubs = true;
//
// insert anti-debugging detections
//
my_python_obfuscator.detect_debugger = false;
//
// insert virtual machine (anti-VM) detections
//
my_python_obfuscator.anti_vm = false;
//
// insert anti-sandbox detections
//
my_python_obfuscator.anti_sandbox = false;
//
// insert anti-emulators (CPU) detections
//
my_python_obfuscator.anti_emulator = false;
//
// strip comments from the output source
//
my_python_obfuscator.remove_comments = true;
//
// source code in Python format
//
let script_source_code = r#"label = 'SecretKey'
port = 443
def get_sum(a, b):
return a + b
print(label, port)
r = get_sum(11, 31)
print(r)"#;
//
// obfuscate the source code with the options set above
//
let result = my_python_obfuscator
.obfuscate_script_source(script_source_code, true)
.await;
//
// it's also possible to pass a Python script file path instead of a string e.g.
//
// let result = my_python_obfuscator
// .obfuscate_script_file(std::path::Path::new("/path/to/project/script.py"), true)
// .await;
//
// result object holds the obfuscation results as well as other information
//
// result.error - error code
// result.output - obfuscated code
// result.demo - was it used in demo mode (invalid or empty activation key was used)
// result.license_expiration - license end date (Y-m-d), empty if none
// result.usages_total - total obfuscations for this activation code
//
match result {
Some(PythonObfuscatorResponse::Object(obj)) => {
//
// display obfuscated code
//
if obj.error == PythonObfuscator::ERROR_SUCCESS {
println!("{}", obj.output.unwrap_or_default());
} else {
return Err(
format!("An error occurred, error code: {}", obj.error).into(),
);
}
}
Some(PythonObfuscatorResponse::Json(_)) => {}
None => {
return Err("Something unexpected happen while trying to obfuscate the code.".into());
}
}
Ok(())
}
/******************************************************************************
* Python Obfuscator WebApi interface usage example.
*
* In this example we will obfuscate sample source with custom options.
*
* Version : v1.0.0
* Language : C#
* Author : Bartosz Wójcik
* Web page : https://www.pelock.com
*
*****************************************************************************/
using PELock.PythonObfuscator;
//
// create Python Obfuscator class instance (we are using our activation key)
//
var myPythonObfuscator = new PythonObfuscator("ABCD-ABCD-ABCD-ABCD");
//
// should the source code be compressed (both input & compressed)
//
myPythonObfuscator.EnableCompression = false;
//
// code virtualization mode (exactly one): VM, FSA, or FLAT
// omit / set to null to skip virtualization
//
myPythonObfuscator.CodeVirtualization = CodeVirtualization.VM;
//
// global obfuscation options
//
// you can disable a particular obfuscation strategy globally if it
// fails or you don't want to use it without modifying the source codes
//
// by default all obfuscation strategies are enabled
//
//
// fixed random seed for reproducible obfuscation output (optional)
//
myPythonObfuscator.Seed = null;
//
// randomization density / intensity (0-100)
//
myPythonObfuscator.RandomizationDensity = null;
//
// identifier renaming style: "il", "homoglyph" or "hex"
//
myPythonObfuscator.RenameStyle = null;
//
// protection against tampering with protected code (integrity verification)
//
myPythonObfuscator.SelfDefending = false;
//
// protection linker (decoy call graph)
//
myPythonObfuscator.ProtectionLinker = false;
//
// rename variable names to random string values
//
myPythonObfuscator.RenameVariables = true;
//
// rename parameter names to random string values
//
myPythonObfuscator.RenameParameters = true;
//
// rename function names to random string values
//
myPythonObfuscator.RenameFunctions = true;
//
// rename function call references consistently with renamed functions
//
myPythonObfuscator.RenameFunctionCalls = true;
//
// shuffle function order in the output source
//
myPythonObfuscator.ShuffleFunctions = true;
//
// fold/resolve constant expressions at obfuscation time
//
myPythonObfuscator.ResolveConstants = true;
//
//
// split strings into concatenated chunks
//
myPythonObfuscator.SplitStrings = true;
//
// apply light transformations/mutations to string literals
//
myPythonObfuscator.ModifyStrings = true;
//
// encrypt strings using randomly generated polymorphic encryption algorithms
//
myPythonObfuscator.EncryptStrings = true;
//
// store string fragments in char-code array vaults
//
myPythonObfuscator.StringCharArrayVault = true;
//
// encrypt integers
//
myPythonObfuscator.EncryptIntegers = true;
//
// encrypt floating point numbers
//
myPythonObfuscator.EncryptFloating = true;
//
// replace binary operators with mixed boolean-arithmetic (MBA) equivalents
//
myPythonObfuscator.MbaBinops = true;
//
// represent integers via floating-point math
//
myPythonObfuscator.IntegersToFloating = true;
//
// move integers to arrays
//
myPythonObfuscator.IntegersToArrays = true;
//
// move floats to arrays
//
myPythonObfuscator.FloatsToArrays = true;
//
// apply redundant xor / affine integer masks
//
myPythonObfuscator.AffineIntegerMask = true;
//
// encrypt integer array literals
//
myPythonObfuscator.ArrayIntCrypt = true;
//
// encrypt character array literals
//
myPythonObfuscator.ArrayCharCrypt = true;
//
// encrypt floating-point array literals
//
myPythonObfuscator.ArrayDoubleCrypt = true;
//
// encrypt string array literals
//
myPythonObfuscator.ArrayStringCrypt = true;
//
// insert a shared bucket of random noise values used by other strategies
//
myPythonObfuscator.InsertRandomValueBucket = true;
//
// populate the random value bucket with decoy integers
//
myPythonObfuscator.RandomBucketIntegers = true;
//
// populate the random value bucket with decoy arrays
//
myPythonObfuscator.RandomBucketArrays = true;
//
// populate the random value bucket with decoy functions
//
myPythonObfuscator.RandomBucketFunctions = true;
//
// populate the random value bucket with decoy characters
//
myPythonObfuscator.RandomBucketCharacters = true;
//
// populate the random value bucket with anti-regex decoy noise
//
myPythonObfuscator.RandomBucketAntiRegex = true;
//
// populate the random value bucket with autostart decoy stubs
//
myPythonObfuscator.RandomBucketAutostart = true;
//
// rewrite selected statements using ternary operators
//
myPythonObfuscator.InsertTernaryOperators = true;
//
// replace boolean conditions with equivalent complex expressions
//
myPythonObfuscator.ComplexifyBooleans = true;
//
// insert opaque predicate branches
//
myPythonObfuscator.OpaqueBranches = true;
//
// insert opaque mixer chains into control flow
//
myPythonObfuscator.OpaqueMixerChain = true;
//
// insert dead code
//
myPythonObfuscator.InsertDeadCode = true;
//
// wrap code in try/finally blocks with dead noise
//
myPythonObfuscator.TryFinallyNoise = true;
//
// insert decoy functions
//
myPythonObfuscator.DecoyFunctions = true;
//
// insert decoy lambda expressions
//
myPythonObfuscator.LambdaDecoys = true;
//
// insert literal padding noise
//
myPythonObfuscator.LiteralPadding = true;
//
// insert fake import statement markers
//
myPythonObfuscator.FakeImportMarkers = true;
//
// use dynamic getattr()-based indirect calls
//
myPythonObfuscator.DynamicGetattrCalls = true;
//
// rewrite absolute imports into __import__ / getattr
//
myPythonObfuscator.ObfuscateImports = true;
//
// insert dead callback/event registration stubs
//
myPythonObfuscator.CallbackRegistrationStubs = true;
//
// insert anti-debugging detections
//
myPythonObfuscator.DetectDebugger = false;
//
// insert virtual machine (anti-VM) detections
//
myPythonObfuscator.AntiVm = false;
//
// insert anti-sandbox detections
//
myPythonObfuscator.AntiSandbox = false;
//
// insert anti-emulators (CPU) detections
//
myPythonObfuscator.AntiEmulator = false;
//
// strip comments from the output source
//
myPythonObfuscator.RemoveComments = true;
//
// source code in Python format
//
const string ScriptSourceCode =
"""
label = 'SecretKey'
port = 443
def get_sum(a, b):
return a + b
print(label, port)
r = get_sum(11, 31)
print(r)
""";
//
// obfuscate the source code with the options set above
//
var result = await myPythonObfuscator.ObfuscateScriptSourceAsync(ScriptSourceCode);
//
// it's also possible to pass a Python script file path instead of a string e.g.
//
// var result = await myPythonObfuscator.ObfuscateScriptFileAsync("/path/to/project/script.py");
//
// result object holds the obfuscation results as well as other information
//
// result?.Error - error code (see PythonObfuscator.Error*)
// result?.Output - obfuscated code
// result?.Demo - was it used in demo mode (invalid or empty activation key was used)
// 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 == PythonObfuscator.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.");
}
<?php
/******************************************************************************
* Python Obfuscator 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 Python Obfuscator class
//
use PELock\PythonObfuscator;
//
// if you don't want to use Composer use include_once
//
//include_once "PythonObfuscator.php";
//
// create Python Obfuscator class instance (we are using our activation key)
//
$myPythonObfuscator = new PELock\PythonObfuscator("ABCD-ABCD-ABCD-ABCD");
//
// login to the service
//
$result = $myPythonObfuscator->Login();
//
// $result[] array holds the information about the license
//
// $result["demo"] - is it a demo mode (invalid or empty activation key was used)
// $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.");
}
?>
#!/usr/bin/env python
###############################################################################
#
# Python Obfuscator 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 Python Obfuscator module
#
from pythonobfuscator import PythonObfuscator
#
# if you don't want to use Python module, you can import directly from the file
#
#from pelock.pythonobfuscator import PythonObfuscator
#
# create Python Obfuscator class instance (we are using our activation key)
#
myPythonObfuscator = PythonObfuscator("ABCD-ABCD-ABCD-ABCD")
#
# login to the service
#
result = myPythonObfuscator.login()
#
# result[] array holds the information about the license
#
# result["demo"] - is it a demo mode (invalid or empty activation key was used)
# 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.")
/******************************************************************************
* Python Obfuscator 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 PythonObfuscator from "python-obfuscator";
//
// include Python Obfuscator class
//
//
// when developing from a repository clone without installing the package use:
//
// import PythonObfuscator from "../src/python-obfuscator.js";
//
// create Python Obfuscator class instance (we are using our activation key)
//
const myPythonObfuscator = new PythonObfuscator("ABCD-ABCD-ABCD-ABCD");
//
// login to the service
//
const result = await myPythonObfuscator.login();
//
// result object holds the information about the license
//
// result.demo - is it a demo mode (invalid or empty activation key was used)
// 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.");
}
/******************************************************************************
* Python Obfuscator 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 python_obfuscator::{PythonObfuscator, PythonObfuscatorResponse};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
//
// include Python Obfuscator class
//
//
// if you don't want to use crates.io use a path dependency to this crate
//
// [dependencies]
// python-obfuscator = { path = ".." }
//
// create Python Obfuscator class instance (we are using our activation key)
//
let my_python_obfuscator =
PythonObfuscator::new(Some("ABCD-ABCD-ABCD-ABCD".to_string()));
//
// login to the service
//
let result = my_python_obfuscator.login(true).await;
//
// result object holds the information about the license
//
// result.demo - is it a demo mode (invalid or empty activation key was used)
// 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(PythonObfuscatorResponse::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(PythonObfuscatorResponse::Json(_)) => {}
None => {
return Err("Something unexpected happen while trying to login to the service.".into());
}
}
Ok(())
}
/******************************************************************************
* Python Obfuscator 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.PythonObfuscator;
//
// create Python Obfuscator class instance (we are using our activation key)
//
var myPythonObfuscator = new PythonObfuscator("ABCD-ABCD-ABCD-ABCD");
//
// login to the service
//
var result = await myPythonObfuscator.LoginAsync();
//
// result object holds the information about the license
//
// result?.Demo - is it a demo mode (invalid or empty activation key was used)
// 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.");
}
command=obfuscate)Oprócz pól key i source, możesz przesłać compression (wartość logiczna). W trybie demo pola strategii POST są ignorowane; obfuskacja zawsze stosuje integers_to_arrays, mba_binops i encrypt_strings (limit 1000 znaków źródła). Poza trybem demo każda strategia to osobne logiczne pole POST (domyślnie false, chyba że klient wyśle true/1/yes):
| Wirtualizacja | |
|---|---|
code_virtualization (vm | fsa | flat, CLI --code-virtualization). Pomiń to pole, aby wyłączyć wirtualizację. | |
| 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: sys.gettrace() 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. Sprawdzenia Windows używają wyłącznie biblioteki standardowej Pythona (bez WMI). | |
| Inne | |
remove_comments | seed (liczba całkowita, opcjonalne) |
randomization_density (liczba całkowita 0-100, opcjonalne) | rename_style (il | o0 | confusable | hex | homoglyph | mangled, opcjonalne) |
Starsze nazwy pól (scriptblock_decoys, fake_dot_source_markers, reflect_invoke_commands, event_stub) są akceptowane jako wsteczne kompatybilne aliasy i automatycznie mapowane na główne flagi CLI. Serwer przekazuje --remove-comments tylko wtedy, gdy włączona jest przynajmniej jedna strategia i remove_comments ma wartość true.
$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. Najprawdopodobniej osiągnięto limit trybu demo (maks. 1000 znaków). |
| ERROR_INPUT | 2 |
Nieprawidłowy lub pusty kod źródłowy. |
| ERROR_PARSING | 3 |
Błąd parsowania kodu źródłowego Python, sprawdź składnię. |
| ERROR_OBFUSCATION | 4 |
Błąd podczas obfuskacji sparsowanego kodu Python. |
| ERROR_OUTPUT | 5 |
Błąd podczas generowania zobfuskowanego kodu wynikowego. |
| ERROR_EXEC | 6 |
Nie udało się uruchomić silnika obfuscatora na serwerze. |
| ERROR_JSON | 7 |
Nieprawidłowa lub brakująca odpowiedź JSON od silnika obfuscatora. |
$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]| Biblioteka PHP | PythonObfuscator |
| Moduł Python 3 | PythonObfuscator |
| Moduł JavaScript | PythonObfuscator |
| Crate Rust | PythonObfuscator |
| Biblioteka C# / .NET | PELock.PythonObfuscator |
Pakiet Python Obfuscator Decorator służy do oznaczania funkcji i klas, które mają pominąć wybrane strategie obfuskacji. Jest potrzebny wyłącznie do uruchamiania oryginalnego kodu źródłowego. Obfuskator odczytuje @obfuscator.skip z drzewa AST, stosuje pominięcie, a następnie usuwa dekorator i nieużywane linie import obfuscator. Obfuskowany wynik nie zależy od tego pakietu w czasie działania.
Nazwa pakietu do importu: obfuscator. Nazwa dystrybucji na PyPI: python-obfuscator-decorator.
| Repozytorium | Język | Instalacja | Paczka | Źródła |
|---|---|---|---|---|
![]() |
Python | Uruchom:
lub
|
PyPI | GitHub |
import obfuscator
@obfuscator.skip()
def handshake(secret: str) -> str:
"""Skip every mutating strategy on this function."""
return secret
Również poprawne:
@obfuscator.skip(obfuscator.ENCRYPT_STRINGS, obfuscator.CODE_VIRTUALIZATION) — pomija wymienione strategie@obfuscator.skip("encrypt_strings") — klucze tekstowe odpowiadają nazwom strategii silnika@obfuscator.skip (bez wywołania) — pomija każdą mutującą strategię na tym elemencieimport obfuscator as alias a następnie @alias.skip(...)CODE_VIRTUALIZATION pomija wszystkie tryby wirtualizacji (VM, FSA, spłaszczenie) na danej funkcji lub klasie. Wygenerowane skrypty nie importują pakietu obfuscator — znaczniki są usuwane z emitowanego kodu.
Jeśli masz jakieś pytania dotyczące Python Obfuscatora, masz jakieś uwagi, coś jest niejasne, napisz do mnie, chętnie odpowiem na każde Twoje pytanie.