Subversion Repositories filter_foundry

Rev

Rev 292 | 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
 
292 daniel-mar 15
Defined in **ff.h**, implemented in **obfusc.c**:
267 daniel-mar 16
 
292 daniel-mar 17
    // Only implements V5. Returns a seed that needs to be stored in the executable code.
18
    unsigned int obfusc(PARM_T* pparm);
282 daniel-mar 19
 
20
    // In V1+V2: Seed is hardcoded
292 daniel-mar 21
    // In V3: Seed is in PARM (field "unknown2")
22
    // In V4+V5: 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
 
292 daniel-mar 25
### Obfuscation "Version 5"
26
 
27
Introduced in **Filter Foundry 1.7.0.8**
28
 
29
Obfuscation version 5 is the same as version 4, but there is a constraint
30
that the seed must be equal to the hash of the deobfuscated PARM.
31
This is done to check the integrity of the deobfuscation.
309 daniel-mar 32
Also, the xor-shifting is intentionally incompatible with version 4
33
to avoid downgrade-attacks.
292 daniel-mar 34
 
276 daniel-mar 35
### Obfuscation "Version 4"
36
 
292 daniel-mar 37
Introduced in **Filter Foundry 1.7.0.7**
276 daniel-mar 38
 
39
It is not compiler-dependant, but different between every standalone filter.
40
 
277 daniel-mar 41
Windows version:
276 daniel-mar 42
The binary code of the 8BF file will be manipulated during building
282 daniel-mar 43
to store the seed into the `deobfusc()` function.
44
The placeholder value is `OBFUSC_V4_DEFAULT_SEED 0x52830517`
45
This allows that 32-bit and 64-bit filters are "cross built".
276 daniel-mar 46
 
277 daniel-mar 47
(Theoretical) Macintosh version:
48
Obfuscation and deobfuscation has the seed 0x52830517, since the
49
manipulation of the binary code is not implemented.
50
 
282 daniel-mar 51
Algorithm: XOR-Shift like in version 2, but the seed is individual for
276 daniel-mar 52
each individual built standalone filter.
53
 
282 daniel-mar 54
The DWORD value "0x00000004" will be stored at position 0x30 (this field is not used in the `PARM` resource).
276 daniel-mar 55
 
271 daniel-mar 56
### Obfuscation "Version 3"
57
 
292 daniel-mar 58
Introduced in **Filter Foundry 1.7.0.5**
267 daniel-mar 59
 
60
It is compiler-dependant, therefore the resource cannot be exchanged between plugins!
61
 
270 daniel-mar 62
Algorithm: XOR with a modified `rand()`-stream with seed that is stored at position 0x30
267 daniel-mar 63
(this field is not used in the `PARM` resource).
64
 
270 daniel-mar 65
32 bit plugin is built with OpenWatcom (for Win95 compatibility) which has following formula:
66
 
67
    int rand_openwatcom(unsigned int* seed) {
68
            *seed = *seed * 1103515245L + 12345L;
69
            return (*seed >> 16) & 0x7fff; /* Scale between 0 and RAND_MAX */
70
    }
71
 
271 daniel-mar 72
64 bit plugin is built with Visual C++ which has following formula:
270 daniel-mar 73
 
74
    int rand_msvcc(unsigned int* seed) {
272 daniel-mar 75
            *seed = *seed * 214013L + 2531011L;
76
            return (*seed >> 16) & 0x7fff; /* Scale between 0 and RAND_MAX */
270 daniel-mar 77
    }
78
 
271 daniel-mar 79
### Obfuscation "Version 2"
267 daniel-mar 80
 
292 daniel-mar 81
Introduced in **Filter Foundry 1.7b1**
267 daniel-mar 82
 
83
It is compiler-independant!
84
 
85
Algorithm: [XOR-Shift](https://de.wikipedia.org/wiki/Xorshift "XOR-Shift") with hardcoded seed `0x95d4a68f`.
86
 
87
    x32 = 0x95d4a68f;
88
    for(i = size, p = pparm; i--;) {
272 daniel-mar 89
            x32 ^= x32 << 13;
90
            x32 ^= x32 >> 17;
91
            x32 ^= x32 << 5;
92
            *p++ ^= x32;
267 daniel-mar 93
    }
94
 
271 daniel-mar 95
### Obfuscation "Version 1"
267 daniel-mar 96
 
97
Introduced in **Filter Foundry 1.4b8,9,10**
98
 
99
It is compiler-dependant, therefore the resource cannot be exchanged between plugins!
100
 
101
Algorithm: XOR with `rand()`-stream with hardcoded seed `0xdc43df3c`.
102
 
103
    srand(0xdc43df3c);
104
    for(i = size, p = pparm; i--;) {
272 daniel-mar 105
            *p++ ^= rand();
271 daniel-mar 106
    }
107
 
108
The plugin is built with Visual C++ which has following formula:
109
 
110
    int rand_msvcc(unsigned int* seed) {
272 daniel-mar 111
            *seed = *seed * 214013L + 2531011L;
112
            return (*seed >> 16) & 0x7fff; /* Scale between 0 and RAND_MAX */
271 daniel-mar 113
    }
114