-
Notifications
You must be signed in to change notification settings - Fork 5
/
cfiscrypted.c
68 lines (55 loc) · 1.69 KB
/
cfiscrypted.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* CFISCRYPTED: Checks to see if stdin is a template encrypted with CFCRYPT
Matt Chapman <[email protected]>
Usage: cfdecrypt <encrypted.cfm >decrypted.cfm
Requires a DES encryption library to compile.
Compile:
Put this file in ~/openssl_ver/crypto/des
~/openssl-1.0.0d/crypto/des> gcc -static ~/openssl-1.0.0d/crypto/des/des_old.c -lcrypto ~/openssl-1.0.0d/crypto/des/cfdecrypt.c -o cfdecrypt
*/
#include <stdio.h>
//#include "des.h"
int main(void)
{
char *header = "Allaire Cold Fusion Template\012Header Size: ";
char buffer[54];
int debug = 0;
int headsize, outlen, seek_pos;
//int skip_header;
//int len, i;
/* Note: This IS the encryption key! It is meant to look like an error. */
//char *keystr = "Error: cannot open template file--\"%s\". Please, try again!\012\012";
/*des_cblock key;
des_cblock input;
des_cblock output;
des_key_schedule schedule;
*/
if ((fread(buffer, 1, 54, stdin) < 54) || (memcmp(buffer, header, 42)))
{
if(debug) fprintf(stderr, "File is not an encrypted template\n");
return 1;
}
if (!memcmp(&buffer[42], "New Version", 11))
{
if(debug) fprintf(stderr, "\nEncrypted with 'New Version'\n");
headsize = 69;
//skip_header = 1;
}
else
{
if(debug) fprintf(stderr, "\nEncrypted with 'Old Version'\n");
headsize = atoi(&buffer[42]);
//skip_header = 0;
}
seek_pos = fseek(stdin, headsize, SEEK_SET);
if ((headsize < 54) || seek_pos < 0)
{
if(debug){
fprintf(stderr, "Error in file format.\n Head size: %i\n",headsize);
if (headsize < 54){ fprintf(stderr, "Error: Head Size < 54");}
if (seek_pos < 0){ fprintf(stderr, "Couldn't set seek position: %i",seek_pos);}
fprintf(stderr, "\n");
}
return 1;
}
return 0;
}