Rev 277 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
267 | daniel-mar | 1 | # Obfuscated filters |
2 | |||
272 | daniel-mar | 3 | ## Resource location |
267 | daniel-mar | 4 | |
5 | Obfuscated standalone filters: |
||
6 | - Windows resource: RCDATA\16001\0 |
||
7 | - MacOS resource: 'DATA' 16001 |
||
8 | |||
9 | Normal standalone filters: |
||
10 | - Windows resource: PARM\16000\0 |
||
11 | - MacOS resource: 'PARM' 16000 |
||
12 | |||
271 | daniel-mar | 13 | ## Implementation |
270 | daniel-mar | 14 | |
271 | daniel-mar | 15 | Defined in **ff.h**, implemented in **make.c**: |
267 | daniel-mar | 16 | |
282 | daniel-mar | 17 | // Only implements V4. Gets a random seed from the calling function. |
276 | daniel-mar | 18 | void obfusc(PARM_T* pparm, unsigned int seed); |
282 | daniel-mar | 19 | |
20 | // In V1+V2: Seed is hardcoded |
||
21 | // In V3: Seed is in PARM |
||
22 | // In V4: Seed is in the program code and will me modified with a binary search+replace |
||
271 | daniel-mar | 23 | void deobfusc(PARM_T* pparm); |
24 | |||
276 | daniel-mar | 25 | ### Obfuscation "Version 4" |
26 | |||
27 | Introduced in **Filter Foundry 1.7.0.7** [08-Aug-2021] |
||
28 | |||
29 | It is not compiler-dependant, but different between every standalone filter. |
||
30 | |||
277 | daniel-mar | 31 | Windows version: |
276 | daniel-mar | 32 | The binary code of the 8BF file will be manipulated during building |
282 | daniel-mar | 33 | to store the seed into the `deobfusc()` function. |
34 | The placeholder value is `OBFUSC_V4_DEFAULT_SEED 0x52830517` |
||
35 | This allows that 32-bit and 64-bit filters are "cross built". |
||
276 | daniel-mar | 36 | |
277 | daniel-mar | 37 | (Theoretical) Macintosh version: |
38 | Obfuscation and deobfuscation has the seed 0x52830517, since the |
||
39 | manipulation of the binary code is not implemented. |
||
40 | |||
282 | daniel-mar | 41 | Algorithm: XOR-Shift like in version 2, but the seed is individual for |
276 | daniel-mar | 42 | each individual built standalone filter. |
43 | |||
282 | daniel-mar | 44 | The DWORD value "0x00000004" will be stored at position 0x30 (this field is not used in the `PARM` resource). |
276 | daniel-mar | 45 | |
271 | daniel-mar | 46 | ### Obfuscation "Version 3" |
47 | |||
267 | daniel-mar | 48 | Introduced in **Filter Foundry 1.7.0.5** [30-Jul-2021] |
49 | |||
50 | It is compiler-dependant, therefore the resource cannot be exchanged between plugins! |
||
51 | |||
270 | daniel-mar | 52 | Algorithm: XOR with a modified `rand()`-stream with seed that is stored at position 0x30 |
267 | daniel-mar | 53 | (this field is not used in the `PARM` resource). |
54 | |||
270 | daniel-mar | 55 | 32 bit plugin is built with OpenWatcom (for Win95 compatibility) which has following formula: |
56 | |||
57 | int rand_openwatcom(unsigned int* seed) { |
||
58 | *seed = *seed * 1103515245L + 12345L; |
||
59 | return (*seed >> 16) & 0x7fff; /* Scale between 0 and RAND_MAX */ |
||
60 | } |
||
61 | |||
271 | daniel-mar | 62 | 64 bit plugin is built with Visual C++ which has following formula: |
270 | daniel-mar | 63 | |
64 | int rand_msvcc(unsigned int* seed) { |
||
272 | daniel-mar | 65 | *seed = *seed * 214013L + 2531011L; |
66 | return (*seed >> 16) & 0x7fff; /* Scale between 0 and RAND_MAX */ |
||
270 | daniel-mar | 67 | } |
68 | |||
271 | daniel-mar | 69 | ### Obfuscation "Version 2" |
267 | daniel-mar | 70 | |
71 | Introduced in **Filter Foundry 1.7b1** [20-Sep-2019] |
||
72 | |||
73 | It is compiler-independant! |
||
74 | |||
75 | Algorithm: [XOR-Shift](https://de.wikipedia.org/wiki/Xorshift "XOR-Shift") with hardcoded seed `0x95d4a68f`. |
||
76 | |||
77 | x32 = 0x95d4a68f; |
||
78 | for(i = size, p = pparm; i--;) { |
||
272 | daniel-mar | 79 | x32 ^= x32 << 13; |
80 | x32 ^= x32 >> 17; |
||
81 | x32 ^= x32 << 5; |
||
82 | *p++ ^= x32; |
||
267 | daniel-mar | 83 | } |
84 | |||
271 | daniel-mar | 85 | ### Obfuscation "Version 1" |
267 | daniel-mar | 86 | |
87 | Introduced in **Filter Foundry 1.4b8,9,10** |
||
88 | |||
89 | It is compiler-dependant, therefore the resource cannot be exchanged between plugins! |
||
90 | |||
91 | Algorithm: XOR with `rand()`-stream with hardcoded seed `0xdc43df3c`. |
||
92 | |||
93 | srand(0xdc43df3c); |
||
94 | for(i = size, p = pparm; i--;) { |
||
272 | daniel-mar | 95 | *p++ ^= rand(); |
271 | daniel-mar | 96 | } |
97 | |||
98 | The plugin is built with Visual C++ which has following formula: |
||
99 | |||
100 | int rand_msvcc(unsigned int* seed) { |
||
272 | daniel-mar | 101 | *seed = *seed * 214013L + 2531011L; |
102 | return (*seed >> 16) & 0x7fff; /* Scale between 0 and RAND_MAX */ |
||
271 | daniel-mar | 103 | } |
104 |