Subversion Repositories filter_foundry

Rev

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