Skip to content

Commit 456e574

Browse files
committed
Arguments format changed
1 parent 7f41cd6 commit 456e574

File tree

3 files changed

+47
-37
lines changed

3 files changed

+47
-37
lines changed

README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ This will automatically obfuscate your code during compilation, ensuring protect
2121

2222
> Available options for protection configuring:
2323
> ```c
24-
> // Additional options
25-
> #define cflow_v2 1 // More powerful Control Flow obfuscation (slowly!)
26-
> #define antidebug_v2 1 // Use better dynamic anti-debugging protection
27-
> #define fake_signs 1 // Adds fake signatures of various protectors or packers
28-
>
2924
> // Advanced code protection (see the "Virtualization" part of the documentation!)
30-
> #define virt 1 // Allows you to use the functions of a math VM
25+
> #define VIRT 1 // Allows you to use the functions of a math VM
26+
>
27+
> // Additional options
28+
> #define CFLOW_V2 1 // More powerful Control Flow obfuscation (slowly!)
29+
> #define ANTIDEBUG_V2 1 // Use better dynamic anti-debugging protection
30+
> #define FAKE_SIGNS 1 // Adds fake signatures of various protectors or packers
3131
>
3232
> // Disabling default features
33-
> #define no_cflow 1 // Don't use Control-Flow obfuscation
34-
> #define no_antidebug 1 // Don't build in debugging protection
33+
> #define NO_CFLOW 1 // Don't use Control-Flow obfuscation
34+
> #define NO_ANTIDEBUG 1 // Don't build in debugging protection
3535
> ```
3636
> or use it with compiler args:
3737
>
3838
> ```
39-
> tcc "app.c" -w -D no_cflow -D antidebug_v2 -D fake_signs
39+
> tcc "app.c" -w -D NO_CFLOW -D ANTIDEBUG_V2 -D FAKE_SIGNS
4040
> ```
4141
4242
⚠️ When compiling an application with obfuscation, use the `-w` argument to suppress warnings. Otherwise, the console will display numerous intimidating logs that have no impact on the final result. There's no need to be alarmed by them.
@@ -51,7 +51,7 @@ if (!licenseExpired()) {
5151
```
5252
5353
## 👺 Virtualization
54-
This is a protection technique in which certain calculations are performed through an embedded virtual machine upon command. Makes analysis of mathematical operations **very difficult**! It will work with the `virt` option enabled (and only!). Otherwise, all virtual machine commands will be replaced by ordinary mathematical operators.
54+
This is a protection technique in which certain calculations are performed through an embedded virtual machine upon command. Makes analysis of mathematical operations **very difficult**! It will work with the `VIRT` option enabled (and only!). Otherwise, all virtual machine commands will be replaced by ordinary mathematical operators.
5555
5656
⚠️ Virtualization in critical locations can impact optimization. Use with caution only in areas where it is really needed
5757
@@ -81,7 +81,7 @@ This is a protection technique in which certain calculations are performed throu
8181
A simple example of using virtualization::
8282
```c
8383
// ...
84-
#define virt 1
84+
#define VIRT 1
8585
// ...
8686
8787
if (VM_EQU(VM_ADD(2, 2), 4)) {
@@ -93,20 +93,20 @@ if (VM_EQU(VM_ADD(2, 2), 4)) {
9393
You can find examples of using all the functions of a virtual machine in the file [tests/virtualmachine.c](tests/virtualmachine.c)
9494
9595
## ❓ Example of using
96-
If you need advanced protection against skilled reversers, use `cflow_v2` and `antidebug_v2` options.
96+
If you need advanced protection against skilled reversers, use `CFLOW_V2` and `ANTIDEBUG_V2` options.
9797
```c
9898
// Let's obfuscate your code!
9999
100100
#include <stdio.h>
101101
102-
#define virt 1 // [+] Use math virtual machine
102+
#define VIRT 1 // [+] Use math virtual machine
103103
104-
#define cflow_v2 1 // [+] ControlFlow v2
105-
#define fake_signs 1 // [+] Fake signatures
106-
#define antidebug_v2 1 // [+] AntiDebug v2
104+
#define CFLOW_V2 1 // [+] ControlFlow v2
105+
#define FAKE_SIGNS 1 // [+] Fake signatures
106+
#define ANTIDEBUG_V2 1 // [+] AntiDebug v2
107107
108-
#define no_cflow 0 // [-] Disable ControlFlow
109-
#define no_antidebug 0 // [-] Disable AntiDebug
108+
#define NO_CFLOW 0 // [-] Disable ControlFlow
109+
#define NO_ANTIDEBUG 0 // [-] Disable AntiDebug
110110
111111
112112
#include "obfus.h"
@@ -122,6 +122,7 @@ void main() {
122122
printf("Error!\n");
123123
}
124124
125+
free(out);
125126
126127
int result = VM_ADD(5, 7); // 5 + 7
127128

include/obfus.h

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,35 @@
1010
Coded by (C) DosX, 2024
1111
1212
[Additional options]
13-
~ cflow_v2 = more powerful Control Flow obfuscation (slowly!)
14-
~ antidebug_v2 = use better dynamic anti-debugging protection
15-
~ fake_signs = adds fake signatures of various protectors or packers
13+
~ CFLOW_V2 = more powerful Control Flow obfuscation (slowly!)
14+
~ ANTIDEBUG_V2 = use better dynamic anti-debugging protection
15+
~ FAKE_SIGNS = adds fake signatures of various protectors or packers
1616
1717
[Advanced code protection]
18-
~ virt = allows you to use the functions of a math VM
18+
~ VIRT = allows you to use the functions of a math VM
1919
2020
[Disabling default features]
21-
~ no_cflow = disable control flow obfuscation
22-
~ no_antidebug = disable antidebug protection
21+
~ NO_CFLOW = disable control flow obfuscation
22+
~ NO_ANTIDEBUG = disable antidebug protection
2323
24-
~ no_obf = disable obfuscation
24+
~ NO_OBF = disable obfuscation
2525
2626
GitHub:
2727
-> https://github.com/DosX-dev/obfus.h
2828
2929
*/
3030

31+
// legacy args support
32+
#define ANTIDEBUG_V2 antidebug_v2
33+
#define NO_ANTIDEBUG no_antidebug
34+
#define FAKE_SIGNS fake_signs
35+
#define CFLOW_V2 cflow_v2
36+
#define NO_CFLOW no_cflow
37+
#define NO_OBF no_obf
38+
#define VIRT virt
39+
3140
// if virtualization disabled
32-
#if no_obf == 1 || virt != 1
41+
#if NO_OBF == 1 || VIRT != 1
3342
#define VM_ADD(num1, num2) num1 + num2
3443
#define VM_SUB(num1, num2) num1 - num2
3544
#define VM_MUL(num1, num2) num1 *num2
@@ -49,7 +58,7 @@
4958
#define VM_GTR_DBL(num1, num2) num1 > num2
5059
#endif
5160

52-
#if !no_obf
61+
#if !NO_OBF
5362

5463
#include <conio.h>
5564
#include <stdio.h>
@@ -69,7 +78,7 @@
6978
#define SECTION_ATTRIBUTE(NAME) __attribute__((section(NAME)))
7079

7180
// Fake signatures ;)
72-
#if defined(fake_signs) && (fake_signs != 0) && SUPPORTED
81+
#if defined(FAKE_SIGNS) && (FAKE_SIGNS != 0) && SUPPORTED
7382

7483
static const char FAKE_ENIGMAVM_1[] SECTION_ATTRIBUTE(".enigma1") = {0};
7584
static const char FAKE_ENIGMAVM_2[] SECTION_ATTRIBUTE(".enigma2") = {0};
@@ -353,7 +362,7 @@ int condition_Proxy(int junk, int condition) {
353362

354363
// =============================================================
355364
// Anti-Tamper for Control-Flow obfuscation (beta!)
356-
#if antitamper == 1 && no_cflow != 1
365+
#if antitamper == 1 && NO_CFLOW != 1
357366
int obfhIsBlockValidated = 0;
358367
int validateBlock() { // returns false
359368
obfhIsBlockValidated = 1;
@@ -374,9 +383,9 @@ int isBlockValidated() { // returns true if validateBlock() executed
374383

375384
// =============================================================
376385
// Control Flow (global)
377-
#if no_cflow != 1
386+
#if NO_CFLOW != 1
378387

379-
#if cflow_v2 == 1 // Control flow obfuscation for 'if' & 'for', V2 (strong!)
388+
#if CFLOW_V2 == 1 // Control flow obfuscation for 'if' & 'for', V2 (strong!)
380389

381390
// if (V2)
382391
#define if(condition) \
@@ -433,7 +442,7 @@ int isBlockValidated() { // returns true if validateBlock() executed
433442

434443
// =============================================================
435444
// Virtualization (global)
436-
#if virt == 1
445+
#if VIRT == 1
437446
typedef enum {
438447
OP__ADD = RND(0, 900) * __COUNTER__ * 5,
439448
OP__SUB = RND(1000, 1900) * __COUNTER__ * 5,
@@ -781,9 +790,9 @@ char *LoadLibraryA_Proxy(LPCSTR lpLibFileName) {
781790

782791
// =============================================================
783792
// Anti-Debug (global)
784-
#if no_antidebug != 1
793+
#if NO_ANTIDEBUG != 1
785794

786-
#if antidebug_v2 == 1 // for antidebug_v2
795+
#if ANTIDEBUG_V2 == 1 // for ANTIDEBUG_V2
787796
void ad_ZeroDRs(PCONTEXT pCtx) {
788797
BREAK_STACK_1;
789798
pCtx->Dr0 = _0;
@@ -841,7 +850,7 @@ int IsDebuggerPresent_Proxy() {
841850
BREAK_STACK_1;
842851
NOP_FLOOD;
843852
BREAK_STACK_2;
844-
#if antidebug_v2 == 1
853+
#if ANTIDEBUG_V2 == 1
845854

846855
// Registers validation
847856
HANDLE hMainThread;
@@ -929,7 +938,7 @@ void loop() {
929938
__asm__ __volatile("ret"); \
930939
crash(); \
931940
} else { \
932-
0.0 / !IsDebuggerPresent(); \
941+
0.0 / !IsDebuggerPresent(); \
933942
};
934943

935944
#else

tests/virtualmachine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <string.h>
33
#include <windows.h>
44

5-
#define virt 1
5+
#define VIRT 1
66
#include "../include/obfus.h"
77

88
void main() {

0 commit comments

Comments
 (0)