Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
b5597d8
build: bump zasm version
es3n1n Feb 1, 2024
26a9bce
fix(scripts): fix opaque gen substitution
es3n1n Feb 1, 2024
687b07d
refactor: getting rid of useless casts
es3n1n Feb 1, 2024
70ae6bf
refactor: use std::views in bb_decomp insert_jmps
es3n1n Feb 1, 2024
b7ed8e6
build: remove redundant include
es3n1n Feb 1, 2024
b2d4dd7
refactor: remove useless initializers in pe types
es3n1n Feb 1, 2024
9ca6a4f
refactor: add new clang-tidy checks
es3n1n Feb 1, 2024
4f7236c
docs: add shared_ptr and optional access checks notice
es3n1n Feb 1, 2024
324533c
fix(analysis): handle exceptions with no successors #12
es3n1n Feb 5, 2024
0cea3eb
fix(analysis): store only known registers in LRUReg #12
es3n1n Feb 5, 2024
b4f17da
docs: update note for lru_reg
es3n1n Feb 5, 2024
b34cd7e
fix(analysis): push newly created labels #12
es3n1n Feb 6, 2024
579d450
build: minor tweaks in cmkr
es3n1n Feb 6, 2024
b826e86
build: change targets iteration
es3n1n Feb 6, 2024
69bd6f3
revert: add .hpp files back to source dir
es3n1n Feb 6, 2024
47bdd78
refactor: make argv constant
es3n1n Feb 6, 2024
7955c6f
feat(obfuscator): add .run method
es3n1n Feb 6, 2024
6174d1c
refactor: remove invalid code from tests
es3n1n Feb 6, 2024
38ea2b2
fix(pe): skip absolute relocations
es3n1n Feb 6, 2024
7d97421
chore: add pdb S_EXPORT todo
es3n1n Feb 6, 2024
40ebd05
refactor: add more stuff to test_util
es3n1n Feb 6, 2024
8ac6db3
feat(func_parser): add function name demangler
es3n1n Feb 6, 2024
088e6ea
perf(func_parser): get rid of some copying
es3n1n Feb 6, 2024
b30feb0
feat(func_parser): add pdb S_PUB32 parser
es3n1n Feb 6, 2024
7032ca2
test: comment out invalid tests
es3n1n Feb 6, 2024
1d0672f
fix(pe): fix relocations rebuilder, we should check rva too
es3n1n Feb 6, 2024
bd872e9
fix(lru_reg): fix x86 registers initialization
es3n1n Feb 6, 2024
b6d08c1
fix(platform): fix win64 detection
es3n1n Feb 6, 2024
99b4a22
feat(platform): add proper unix/posix detection
es3n1n Feb 6, 2024
86dfe60
fix(analysis): assert instruction minimal size
es3n1n Feb 6, 2024
8eff62d
build: minor changes to cmkr configuration
es3n1n Feb 6, 2024
4884051
refactor(reg_convert): use zasm's builtin reg converter
es3n1n Feb 12, 2024
488a0d3
BREAKING: refactor(reg_convert): use r16 instead of r8
es3n1n Feb 12, 2024
2a2e7f8
refactor(misc): "properly" handle push operand size calculations
es3n1n Feb 12, 2024
1c1d9ca
build: fix compilation on latest clang/libc++
es3n1n Feb 23, 2025
50aa7f8
build(deps): use es3n1n/common
es3n1n Feb 23, 2025
fc5cf88
refactor: migrate more stuff to es3n1n/common
es3n1n Feb 23, 2025
b4f2c46
test(func_parser): implement map/pdb tests
es3n1n Feb 24, 2025
f8cd52d
refactor: minor refactoring
es3n1n Feb 24, 2025
37db1d1
ci: merge ci from /common
es3n1n Feb 24, 2025
5cc2a72
Merge branch 'master' into dev
es3n1n Feb 24, 2025
18886d9
ci: checkout with submodules
es3n1n Feb 24, 2025
62ac076
ci: various ci fixes
es3n1n Feb 24, 2025
a24aaa9
fix: various clang tidy fixes
es3n1n Feb 24, 2025
9e9560b
fix: various clang tidy fixes
es3n1n Feb 25, 2025
bb6e7cc
refactor: un-constexpr some default ctors
es3n1n Feb 25, 2025
767194b
refactor(config): set chance default value to 100 (#27)
lustman Apr 3, 2025
773e087
add seed as optional argument (#31)
sovissa Apr 8, 2025
d16b671
feat(pe): add metadata clean pass (#29)
lustman Apr 8, 2025
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
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# es3n1n's clang-format, last upd 29 jun 2023 11:20:59
# es3n1n's clang-format -- 29 jun 2023 11:20:59 -- https://pastebin.com/4mtxipKe
---
AlignAfterOpenBracket: Align
AlignEscapedNewlines: Left
Expand All @@ -20,7 +20,7 @@ BasedOnStyle: WebKit
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: None
BraceWrapping:
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
Expand Down
63 changes: 47 additions & 16 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,27 +1,58 @@
# es3n1n's clang-tidy -- 09 oct 2024 19:56:40 -- https://pastebin.com/Zqj501X6
Checks: >
bugprone-*,
-bugprone-easily-swappable-parameters,
clang-diagnostic-*,
cert-*,
clang-analyzer-*,
clang-diagnostic-*,
concurrency-*,
cppcoreguidelines-*,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-non-private-member-variables-in-classes,
mpi-*,
modernize-*,
-modernize-use-trailing-return-type,
-modernize-use-nodiscard,
google-*,
hicpp-*,
misc-*,
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
modernize-*,
mpi-*,
performance-*,
portability-*,
readability-*,
-readability-function-cognitive-complexity,
-bugprone-easily-swappable-parameters,
-bugprone-exception-escape,
-bugprone-unchecked-optional-access,
-bugprone-macro-parentheses,
-cert-err58-cpp,
-concurrency-mt-unsafe,
-clang-analyzer-optin.core.EnumCastOutOfRange,
-clang-analyzer-security.insecureAPI.rand,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-init-variables,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-special-member-functions,
-hicpp-avoid-c-arrays,
-hicpp-special-member-functions,
-misc-include-cleaner,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-modernize-avoid-c-arrays,
-modernize-use-trailing-return-type,
-readability-convert-member-functions-to-static,
WarningsAsErrors: ''
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-magic-numbers,
WarningsAsErrors: '*'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: file
CheckOptions:
cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: '1'
modernize-use-nullptr.NullMacros: 'NULL'
- key: 'modernize-use-nullptr.NullMacros'
value: '1'
- key: 'misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic'
value: '1'
- key: 'readability-redundant-access-specifiers.CheckFirstDeclaration'
value: '1'
33 changes: 33 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: clang-format

on:
pull_request:
paths:
- '.github/workflows/clang-format.yml'
- 'cmake/**'
- 'src/**'
- 'vendor/**'
- '**/CMakeLists.txt'
push:
branches:
- master
paths:
- '.github/workflows/clang-format.yml'
- 'cmake/**'
- 'src/**'
- 'vendor/**'
- '**/CMakeLists.txt'

jobs:
test_cxx:
name: Run
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'

- uses: jidicula/clang-format-action@v4.14.0
with:
clang-format-version: '19'
check-path: 'src/'
66 changes: 66 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: clang-tidy

on:
pull_request:
paths:
- '.github/workflows/clang-tidy.yml'
- 'cmake/**'
- 'src/**'
- 'vendor/**'
- '**/CMakeLists.txt'
push:
branches:
- master
paths:
- '.github/workflows/clang-tidy.yml'
- 'cmake/**'
- 'src/**'
- 'vendor/**'
- '**/CMakeLists.txt'

jobs:
test_cxx:
name: Run
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'

- name: Setup clang and libc++
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 19
sudo apt-get install -yq --no-install-recommends libc++-19-dev libc++abi-19-dev clang-tidy-19
echo "CC=clang-19" >> $GITHUB_ENV
echo "CXX=clang++-19" >> $GITHUB_ENV

- name: Generate build
run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DOBFUSCATOR_BUILD_TESTS=ON -DCMKR_SKIP_GENERATION=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Adjust compile commands
run: python3 scripts/adjust_compile_commands.py build/compile_commands.json

- name: Adjust dependencies' .clang-tidy
run: |
echo "Checks: '-*'" > build/.clang-tidy
echo "Checks: '-*'" > vendor/zasm/.clang-tidy

- name: Run clang tidy
run: |
wget https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/release/19.x/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
python3 run-clang-tidy.py \
-clang-tidy-binary clang-tidy-19 \
-p build \
-j 12 \
-extra-arg="-std=c++23" \
-extra-arg="-stdlib=libc++" \
-header-filter="src/lib|src/bin|src/tests" \
-q \
-allow-no-checks
80 changes: 80 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Tests

on:
pull_request:
paths:
- '.github/workflows/tests.yml'
- 'cmake/**'
- 'src/**'
- 'vendor/**'
- 'CMakeLists.txt'
push:
branches:
- master
paths:
- '.github/workflows/tests.yml'
- 'cmake/**'
- 'src/**'
- 'vendor/**'
- '**/CMakeLists.txt'

jobs:
test_cxx:
name: ${{ matrix.os }}, ${{ matrix.compiler }}, ${{ matrix.buildtype }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
compiler: [gcc, clang, msvc]
buildtype: [Debug, Release]
exclude:
# Windows is extremely slow so we will test it only with msvc
- os: windows-latest
compiler: gcc
- os: windows-latest
compiler: clang
# No msvc on ubuntu, duh
- os: ubuntu-latest
compiler: msvc
env:
BUILD_TYPE: ${{ matrix.buildtype }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'

- name: Setup clang and libc++
if: contains(matrix.os, 'ubuntu') && matrix.compiler == 'clang'
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 19
sudo apt-get install -yq --no-install-recommends libc++-19-dev libc++abi-19-dev
echo "CC=clang-19" >> $GITHUB_ENV
echo "CXX=clang++-19" >> $GITHUB_ENV

- name: Setup gcc and libstdc++
if: contains(matrix.os, 'ubuntu') && matrix.compiler == 'gcc'
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo add-apt-repository ppa:apt-fast/stable
sudo apt-get update
sudo apt-get install -yq --no-install-recommends apt-fast
sudo apt-fast install -yq --no-install-recommends gcc-14 g++-14 libstdc++-14-dev
echo "CC=gcc-14" >> $GITHUB_ENV
echo "CXX=g++-14" >> $GITHUB_ENV

- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DOBFUSCATOR_BUILD_TESTS=ON -DCMKR_SKIP_GENERATION=ON

- name: Build
run: cmake --build build --config ${{env.BUILD_TYPE}} --parallel

- name: Test (Unix)
if: contains(matrix.os, 'ubuntu')
run: ./build/src/obfuscator-tests

- name: Test (Windows)
if: contains(matrix.os, 'windows')
run: .\build\src\${{ env.BUILD_TYPE }}\obfuscator-tests.exe
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ samples/
# infer
infer-out/**
cmake/infer-build

# clang tidy
__clang_tidy_build/
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@
[submodule "vendor/gtest"]
path = vendor/gtest
url = https://github.com/google/googletest
[submodule "vendor/LLVMDemangle"]
path = vendor/LLVMDemangle
url = https://github.com/es3n1n/LLVMDemangle.git
[submodule "vendor/common"]
path = vendor/common
url = https://github.com/es3n1n/common
18 changes: 18 additions & 0 deletions CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ Available options:
-t [name] -- Start new transform configuration
-g [name] -- Start new transform global configuration
-v [name] [value] -- Push value
-seed [value] -- Set random seed

Examples:
obfuscator hehe.exe -f main -t TransformName -v SomeName 1337
obfuscator hehe.exe -f main -t TransformName -v SomeName 1337 -g TransformName -v SomeGlobalName 1337
obfuscator hehe.exe -f main -t TransformName -v SomeName 1337 -v SomeName0 1337 -g TransformName -v SomeGlobalName 1337
obfuscator hehe.exe -map mymap.map -pdb mypdb.pdb -f main -t TransformName -v SomeName 1337 -v SomeName0 1337 -g TransformName -v SomeGlobalName 1337
obfuscator hehe.exe -map mymap.map -pdb mypdb.pdb -f main -seed 0xcb91ccbef7cbcdc1
```

In case of unexpected exit without any error message or in case you feel lucky, try adjusting the chances. E.g.:
```commandline
obfuscator hehe.exe -pdb hehe.pdb -f main -t ConstantCrypt -v chance 55
```

## Writeup
Expand Down
22 changes: 22 additions & 0 deletions cmake.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,25 @@ build-tests = "OBFUSCATOR_BUILD_TESTS"

[subdir.vendor]
[subdir.src]

# Ugly fix for Zydis collisions :/
cmake-after = """
function(get_all_targets var)
set(targets)
get_all_targets_recursive(targets ${CMAKE_CURRENT_SOURCE_DIR})
set(${var} ${targets} PARENT_SCOPE)
endfunction()

macro(get_all_targets_recursive targets dir)
get_property(subdirectories DIRECTORY ${dir} PROPERTY SUBDIRECTORIES)
foreach(subdir ${subdirectories})
get_all_targets_recursive(${targets} ${subdir})
endforeach()

get_property(current_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS)
list(APPEND ${targets} ${current_targets})
endmacro()

get_all_targets(all_targets)
set_target_properties(${all_targets} PROPERTIES VS_GLOBAL_VcpkgEnabled false)
"""
2 changes: 1 addition & 1 deletion cmake/cmkr.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include_guard()

# Change these defaults to point to your infrastructure if desired
set(CMKR_REPO "https://github.com/build-cpp/cmkr" CACHE STRING "cmkr git repository" FORCE)
set(CMKR_TAG "v0.2.24" CACHE STRING "cmkr git tag (this needs to be available forever)" FORCE)
set(CMKR_TAG "v0.2.26" CACHE STRING "cmkr git tag (this needs to be available forever)" FORCE)
set(CMKR_COMMIT_HASH "" CACHE STRING "cmkr git commit hash (optional)" FORCE)

# To bootstrap/generate a cmkr project: cmake -P cmkr.cmake
Expand Down
19 changes: 19 additions & 0 deletions scripts/adjust_compile_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import json
from sys import argv


if len(argv) <= 1:
exit(1)


with open(argv[1], 'r') as f:
data = json.load(f)

data = [
item
for item in data
if not item['output'].startswith('_deps/')
]

with open(argv[1], 'w') as f:
json.dump(data, f)
3 changes: 3 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
cmake -S . -B __clang_tidy_build -DCMAKE_C_COMPILER=clang-17 -DCMAKE_CXX_COMPILER=clang++-17 -DCMAKE_EXPORT_COMPILE_COMMANDS=1
python3 scripts/run_clang_tidy.py -clang-tidy-binary clang-tidy-17 -p __clang_tidy_build -j 25 -extra-arg="-std=c++23" -extra-arg="-stdlib=libc++" -q
Loading