Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2e046bd
chore: initial infrastructure
RadonCoding Sep 6, 2026
f39c8a3
fix: marker scanning
RadonCoding Sep 7, 2026
78feeea
Update engine.rs
RadonCoding Sep 8, 2026
35f03d3
fix: fixed marker scanner
RadonCoding Sep 11, 2026
e59935b
chore: large refactors, fixes and a new obfuscation pass
RadonCoding Sep 12, 2026
97792d2
chore: allocator rework for semantic builder
RadonCoding Sep 15, 2026
c34ae67
chore: multiplication via semantics
RadonCoding Sep 16, 2026
43f1655
chore: division via semantics
RadonCoding Sep 19, 2026
1deea2b
chore: rewrote unit testing framework and tons of bug fixes
RadonCoding Sep 20, 2026
7b70705
chore: rewrote unit testing framework and tons of bug fixes
RadonCoding Sep 20, 2026
5ccd323
chore: division via semantics
RadonCoding Sep 20, 2026
3a6050d
fix: fixes to unit tests & handlers
RadonCoding Sep 23, 2026
731456e
fix: unit tests
RadonCoding Sep 26, 2026
661166c
fix: correct discard handler
RadonCoding Sep 26, 2026
48ea8ec
fix: remove uncessary test
RadonCoding Sep 26, 2026
a4f074a
Merge branch 'feat/semantic-handler-generation' of https://github.com…
RadonCoding Sep 26, 2026
48afb02
fix: correct discard
RadonCoding Sep 26, 2026
8df4ff0
chore: cleanup store_register.rs
RadonCoding Sep 26, 2026
1f1ac49
Merge branch 'feat/semantic-handler-generation' of https://github.com…
RadonCoding Sep 26, 2026
56c8b26
fix: anti-tamper to handle functions smaller than 16-bytes
RadonCoding Sep 27, 2026
36dee0f
chore: exception handling tests
RadonCoding Sep 27, 2026
ad56052
fix: fixed CXX exceptions
RadonCoding Sep 27, 2026
a3db664
Update exceptions.rs
RadonCoding Sep 28, 2026
1d7c362
Update exceptions.rs
RadonCoding Sep 28, 2026
1d458b4
Update exceptions.rs
RadonCoding Sep 28, 2026
5a2245b
chore: changed trampolines to calls
RadonCoding Sep 28, 2026
1948a4a
chore: changed markers to use section, improved attestation, implemen…
RadonCoding Sep 30, 2026
c910365
Update anti_tamper.rs
RadonCoding Sep 30, 2026
b977107
fix: fixed attestation and hardened immediate encryption
RadonCoding Oct 3, 2026
1a883d9
Merge branch 'feat/semantic-handler-generation' of https://github.com…
RadonCoding Oct 3, 2026
99d0a76
chore: further hardening of attestation
RadonCoding Oct 3, 2026
9a6465c
chore: improved case shuffle of dispatches
RadonCoding Oct 4, 2026
dd67eb1
chore: MBA
RadonCoding Oct 4, 2026
7a97809
chore: MBA cleanup
RadonCoding Oct 4, 2026
1b0380c
chore: hardened cipher
RadonCoding Oct 4, 2026
7f9b94a
chore: hardened cipher
RadonCoding Oct 5, 2026
fe6563d
chore: shortened attestation window
RadonCoding Oct 5, 2026
989551f
cleanup: refactored some examples and immediates
RadonCoding Oct 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions .github/workflows/generate-templates.yml

This file was deleted.

59 changes: 6 additions & 53 deletions .github/workflows/validate-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,8 @@ on:
- main
types: [opened, synchronize]
jobs:
discover:
runs-on: ubuntu-latest
outputs:
examples: ${{ steps.discover.outputs.examples }}
steps:
- uses: actions/checkout@v4

- id: discover
run: |
examples=$(find examples -mindepth 2 -maxdepth 2 -type d | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "examples=$examples" >> $GITHUB_OUTPUT

validate:
needs: [discover]
runs-on: ubuntu-latest
strategy:
matrix:
example: ${{ fromJson(needs.discover.outputs.examples) }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -44,45 +28,14 @@ jobs:
sudo apt-get update
sudo apt-get install -y mingw-w64 wine wine32 wine64

- name: Generate templates
env:
OUTPUT_DIRECTORY: ${{ github.workspace }}/api/generated
TEMPLATES_DIRECTORY: ${{ github.workspace }}/api/templates
run: cargo build --package markers

- name: Build for Windows
run: cargo build --bin obfuscator --release --target x86_64-pc-windows-gnu

- name: Build examples
run: |
language=$(echo "${{ matrix.example }}" | cut -d/ -f2)
case $language in
rust) cargo build --manifest-path ${{ matrix.example }}/Cargo.toml --release --target x86_64-pc-windows-gnu ;;
cpp) x86_64-w64-mingw32-g++ ${{ matrix.example }}/main.cpp -o ${{ matrix.example }}/example.exe -static-libgcc -static-libstdc++ ;;
esac
- name: Build example
run: x86_64-w64-mingw32-g++ examples/cpp/hello/main.cpp -o example.exe

- name: Obfuscate examples
run: |
language=$(echo "${{ matrix.example }}" | cut -d/ -f2)
case $language in
rust)
name=$(cargo metadata --manifest-path ${{ matrix.example }}/Cargo.toml --no-deps --format-version 1 | jq -r '.packages[0].name')
wine target/x86_64-pc-windows-gnu/release/obfuscator.exe ${{ matrix.example }}/target/x86_64-pc-windows-gnu/release/$name.exe --virtualization
;;
cpp)
wine target/x86_64-pc-windows-gnu/release/obfuscator.exe ${{ matrix.example }}/example.exe --virtualization
;;
esac
- name: Obfuscate example
run: wine target/x86_64-pc-windows-gnu/release/obfuscator.exe example.exe --virtualization

- name: Validate examples
run: |
language=$(echo "${{ matrix.example }}" | cut -d/ -f2)
case $language in
rust)
name=$(cargo metadata --manifest-path ${{ matrix.example }}/Cargo.toml --no-deps --format-version 1 | jq -r '.packages[0].name')
wine ${{ matrix.example }}/target/x86_64-pc-windows-gnu/release/$name.exe
;;
cpp)
wine ${{ matrix.example }}/example.exe
;;
esac
- name: Validate example
run: wine example.exe
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[workspace]
members = ["logger", "obfuscator", "runtime", "tests", "markers"]
members = ["logger", "obfuscator", "runtime", "tests"]
resolver = "2"
exclude = ["examples"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Obfuscator for compiled 64-bit portable executables.
### 1. Obfuscator

#### Analysis
- **Disassembly**: the binary's code section is disassembled and partitioned into basic blocks by tracing all reachable control flow or by scanning for explicit inline markers as shown in the [examples](https://github.com/RadonCoding/binsafe/tree/main/examples).
- **Disassembly**: the binary's code section is disassembled and partitioned into basic blocks by tracing all reachable control flow or by scanning the `.binsafe` section that [marked functions](https://github.com/RadonCoding/binsafe/tree/main/examples) are placed in.

#### Virtualization
- **Lifting**: instructions are translated into bytecode that the runtime interprets.
Expand Down
9 changes: 9 additions & 0 deletions api/binsafe.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#if defined(__GNUC__) || defined(__clang__)
#define BINSAFE __attribute__((section(".binsafe"), noinline))
#elif defined(_MSC_VER)
#define BINSAFE __declspec(code_seg(".binsafe")) __declspec(noinline)
#else
#define BINSAFE
#endif
8 changes: 8 additions & 0 deletions api/binsafe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#[macro_export]
macro_rules! binsafe {
($item:item) => {
#[link_section = ".binsafe"]
#[inline(never)]
$item
};
}
11 changes: 0 additions & 11 deletions api/generated/binsafe.hpp

This file was deleted.

17 changes: 0 additions & 17 deletions api/generated/binsafe.rs

This file was deleted.

11 changes: 0 additions & 11 deletions api/templates/binsafe.hpp

This file was deleted.

17 changes: 0 additions & 17 deletions api/templates/binsafe.rs

This file was deleted.

97 changes: 75 additions & 22 deletions example.ps1
Original file line number Diff line number Diff line change
@@ -1,50 +1,103 @@
using namespace System.IO

param(
[Parameter(Mandatory)]
[string]$Example
)
[Parameter(Mandatory, Position = 0)]
[DirectoryInfo]$Example,

$ErrorActionPreference = "Stop"
[Parameter(Position = 1)]
[ValidateSet("debug", "release")]
[string]$Configuration = "debug",

$language = $Example.Split("/")[1]
[Parameter(Position = 2)]
[string[]]$Arguments
)

$env:OUTPUT_DIRECTORY = "$PWD/api/generated"
$env:TEMPLATES_DIRECTORY = "$PWD/api/templates"
$ErrorActionPreference = "Stop"

cargo build --package markers
$language = Split-Path (Split-Path $Example -Parent) -Leaf

if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

cargo build --bin obfuscator
if ($Configuration -eq "release") {
cargo build --bin obfuscator --release $Arguments
}
else {
cargo build --bin obfuscator $Arguments
}

if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

switch ($language) {
"rust" {
cargo build --manifest-path "$Example/Cargo.toml"
$manifest = Join-Path $Example.FullName "Cargo.toml"

if ($Configuration -eq "release") {
cargo build --manifest-path $manifest --release
}
else {
cargo build --manifest-path $manifest
}

if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

$metadata = cargo metadata --manifest-path "$Example/Cargo.toml" --format-version 1 --no-deps | ConvertFrom-Json
$metadata = cargo metadata `
--manifest-path $manifest `
--format-version 1 `
--no-deps | ConvertFrom-Json

$manifest = [Path]::GetFullPath($manifest)

$package = $metadata.packages[0]
$target = $package.targets | Where-Object { $_.kind -contains "bin" } | Select-Object -First 1
$package = $metadata.packages |
Where-Object {
[Path]::GetFullPath($_.manifest_path) -eq $manifest
} |
Select-Object -First 1

$source = Join-Path $metadata.target_directory "debug\$($target.name).exe"
$target = $package.targets |
Where-Object { $_.kind -contains "bin" } |
Select-Object -First 1

$source = Join-Path `
$metadata.target_directory `
"$Configuration\$($target.name).exe"
}

"cpp" {
g++ "$Example/main.cpp"

$main = Join-Path $Example.FullName "main.cpp"

$source = Join-Path `
$Example.Parent.Parent.FullName `
"$($Example.Name).exe"

if ($Configuration -eq "release") {
g++ $main -o $source -O2
}
else {
g++ $main -o $source -O0 -g
}

if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}

$source = Join-Path $PWD "a.exe"
default {
throw "Unsupported language: $language"
}
}

& "target/debug/obfuscator.exe" --virtualization $source
$source = [Path]::GetFullPath($source)

if (-not (Test-Path -LiteralPath $source -PathType Leaf)) {
throw "Source executable not found: $source"
}

$obfuscator = Join-Path $PWD "target\$Configuration\obfuscator.exe"

& $obfuscator --virtualization -v $source

if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

$destination = [System.IO.Path]::ChangeExtension($source, ".protected.exe")
$destination = [Path]::ChangeExtension(
$source,
".protected.exe"
)

& $destination

Expand All @@ -53,4 +106,4 @@ $code = $LASTEXITCODE
Remove-Item $source -Force -ErrorAction SilentlyContinue
Remove-Item $destination -Force -ErrorAction SilentlyContinue

exit $code
exit $code
Loading
Loading