int checkdevice( char *device_in ) { int i, found = FALSE; StrToUpperCase( device_in ); for( i = 0 ; i < DEVICE_COUNT; i++ ) { if( DBG ) fprintf( stderr, "Input %s ref %s\n",device_in, DEVICE_TABLE[i] ); if( !strcmp( DEVICE_TABLE[i], device_in ) ) { found = TRUE; DEVICE = device_in; if( DBG ) fprintf( stderr,"DEVICE %s\n",DEVICE ); if( !strcmp( "GIF_ANIMATION" , device_in ) || !strcmp( "KML", device_in ) ) { ANIM_FLAG = 1; STEP_FREQ = 1; } return 0; } } if( !found ) cdoWarning( " Device specified with Improper value!\n" ); return 1; }
int checkstyle( char *style_in ) { int i, found = FALSE; StrToUpperCase( style_in ); for( i = 0 ; i < STYLE_COUNT; i++ ) { if( DBG ) fprintf( stderr, "Input %s ref %s\n",style_in, STYLE_TABLE[i] ); if( !strcmp( STYLE_TABLE[i], style_in ) ) { found = TRUE; STYLE = style_in; return 0; } } if( !found ) cdoWarning( " Style specified with Improper value!\n" ); return 1; }
/////////////////////////////////////////////////////////////////////////////// // Skype ACL KeyGen // Input: // lpUserName : skype accountname // lpFileName : full path of plugin // Output: All fields are encrypted! // lpOutKey1 : Key1 // lpOutKey2 : Key2 // lpOutKey3 : Key3 // lpOutKey4 : Key4 // lpOutPath : Path // BOOL SkypeACLKeyGen(char *lpUserName, char *lpFileName, char *lpOutKey1, char *lpOutKey2, char *lpOutKey3, char *lpOutKey4, char *lpOutKey5, char *lpOutKey6, char *lpOutPath, BOOL isOld) { char szPluginDigest_SHA256[(32*2) * 2]; char szPluginDigest_MD5[17 * 2]; char *szPassphrase1 = "Element'ry!penguiNs;-)SingingHarekrishna_"; char *szPassphrase2 = "Element'ry!penguiNs;-)SingingHareKrishna_"; const int username_len = strlen(lpUserName); SHA256_Plugin(lpFileName, szPluginDigest_SHA256, isOld); MD5_Plugin(lpFileName, szPluginDigest_MD5); char *szUSERNAME = (char *) malloc(strlen(lpUserName)+1); char *szFILENAME = (char *) malloc(strlen(lpFileName)+1); RtlZeroMemory(szUSERNAME, strlen(lpUserName)+1); RtlZeroMemory(szFILENAME, strlen(lpFileName)+1); StrToUpperCase(szFILENAME, lpFileName); StrToUpperCase(szUSERNAME, lpUserName); char *result = NULL; char temp[512]; char tmp[1024]; // /Client/Key1 char _md5_filename[MD5_DIGEST_SIZE * 2 + 1]; char _md5_key1_0[MD5_DIGEST_SIZE * 2 + 1]; char _md5_key1_1[MD5_DIGEST_SIZE * 2 + 1]; char _md5_key1[MD5_DIGEST_SIZE * 4 + 1]; char passSBOX[4][MD5_DIGEST_SIZE*2+1]; RtlZeroMemory(_md5_filename, MD5_DIGEST_SIZE * 2 + 1); MD5_Array(_md5_filename, szFILENAME, strlen(szFILENAME)); if(isOld) { sprintf(tmp, "%s%s", _md5_filename, szPassphrase1); MD5_Array(_md5_key1_0, tmp, strlen(tmp)); sprintf(tmp, "%s%s", szPluginDigest_MD5, szPassphrase1); MD5_Array(_md5_key1_1, tmp, strlen(tmp)); } else { sprintf(tmp, "%s%s", _md5_filename, szPassphrase2); MD5_Array(_md5_key1_0, tmp, strlen(tmp)); sprintf(tmp, "%s%s", szPluginDigest_MD5, szPassphrase2); MD5_Array(_md5_key1_1, tmp, strlen(tmp)); } sprintf(_md5_key1, "%s%s", _md5_key1_0, _md5_key1_1); // Encrypt sha256 /Client/Key1 result = Encrypt(lpUserName, _md5_key1); RtlCopyMemory(lpOutKey1, result, strlen(result)); free(result); //// Encrypt sha256 /Client/Key2 //sprintf(tmp, "%s%s%s%s", szUSERNAME, "ke:", szFILENAME, "1a"); //RtlZeroMemory(temp, sizeof(temp)); //MD5_Array(temp, tmp, strlen(tmp)); //result = Encrypt(lpUserName, temp); //RtlCopyMemory(lpOutKey2, result, strlen(result)); //free(result); // generate all keys to find correct! sprintf(tmp, "%s%s%s%s", szUSERNAME, "ke:", szFILENAME, "1a"); RtlZeroMemory(temp, sizeof(temp)); MD5_Array(passSBOX[0], tmp, strlen(tmp)); sprintf(tmp, "%s%s%s%s", "1u", szFILENAME, "ba", szUSERNAME); RtlZeroMemory(temp, sizeof(temp)); MD5_Array(passSBOX[1], tmp, strlen(tmp)); sprintf(tmp, "%s%s%s%s", "ky", szUSERNAME, "s1", szFILENAME); RtlZeroMemory(temp, sizeof(temp)); MD5_Array(passSBOX[2], tmp, strlen(tmp)); sprintf(tmp, "%s%s%s%s", "p0", szUSERNAME, "1e", szFILENAME); RtlZeroMemory(temp, sizeof(temp)); MD5_Array(passSBOX[3], tmp, strlen(tmp)); // Encrypt sha256 /Client/Key2 result = Encrypt(lpUserName, passSBOX[1]); RtlCopyMemory(lpOutKey2, result, strlen(result)); free(result); // Encrypt sha256 /Client/Key3 result = Encrypt(lpUserName, passSBOX[3]); RtlCopyMemory(lpOutKey3, result, strlen(result)); free(result); // Encrypt sha256 /Client/Key4 RtlZeroMemory(temp, sizeof(temp)); StrToUpperCase(temp, szPluginDigest_SHA256); result = Encrypt(lpUserName, temp); RtlCopyMemory(lpOutKey4, result, strlen(result)+1); free(result); // Encrypt path //Client/Path result = Encrypt(lpUserName, lpFileName); RtlCopyMemory(lpOutPath, result, strlen(result)); free(result); // encrypt date char today[32]; SYSTEMTIME sys_time; GetSystemTime(&sys_time); GetDateFormatA(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &sys_time, NULL, today, sizeof(today)); char count[4]; count[0] = '3'; count[1] = 0x00; count[2] = 0x00; count[3] = 0x00; result = Encrypt(lpUserName, today); RtlCopyMemory(lpOutKey5, result, strlen(result)); free(result); result = Encrypt(lpUserName, count); RtlCopyMemory(lpOutKey6, result, strlen(result)); free(result); free(szUSERNAME); free(szFILENAME); return TRUE; }
void VerifyPlotParameters( int num_param, char **param_names, int opID ) { int i, j, k; int found = FALSE, syntax = TRUE, halt_flag = FALSE, /* file_found = TRUE, */ split_str_count; int param_count; char **params; char **split_str = NULL, **split_str1 = NULL; char *sep_char = "="; char *temp_str; char orig_char = ';', rep_char = ','; FILE *fp; /* char *contour_params[] = {"ymin","ymax","count","interval","list","colour","thickness","style"}; char *shaded_params[] = {"ymin","ymax","count","interval","list","colour_min","colour_max","colortable","step_freq"}; char *grfill_params[] = {"ymin","ymax","count","interval","list","colour_min","colour_max","colortable","resolution"}; */ for ( i = 0; i < num_param; ++i ) { split_str_count = 0; found = FALSE; syntax = TRUE; split_str_count = StringSplitWithSeperator( param_names[i], sep_char, &split_str ); if( DBG ) fprintf( stderr, "Verifying params!\n"); if( split_str_count > 1 ) { if( opID == CONTOUR ) { param_count = contour_param_count; params = contour_params; } else if( opID == SHADED ) { param_count = shaded_param_count; params = shaded_params; } else if( opID == GRFILL ) { param_count = grfill_param_count; params = grfill_params; } for ( j = 0; j < param_count; ++j ) { if( !strcmp( split_str[0], params[j] ) ) { found = TRUE; if( !strcmp( split_str[0],"colour" ) || !strcmp( split_str[0],"style" ) || !strcmp( split_str[0],"colour_min" ) || !strcmp( split_str[0],"colour_max" ) || !strcmp( split_str[0],"RGB" ) || !strcmp( split_str[0],"colour_triad" )|| !strcmp( split_str[0],"device") || !strcmp( split_str[0],"file_split" ) ) { if( IsNumeric( split_str[1] ) ) syntax = FALSE; else { if( !strcmp( split_str[0],"RGB" ) || !strcmp( split_str[0],"file_split") ) { temp_str = strdup( split_str[1] ); StrToUpperCase( temp_str ); if( strcmp( temp_str,"TRUE" ) && strcmp( temp_str,"FALSE" ) ) syntax = FALSE; else { if( !strcmp( split_str[0],"RGB" ) ) { if( !strcmp( temp_str,"TRUE" ) ) isRGB = TRUE; else isRGB = FALSE; } else if( !strcmp( split_str[0],"file_split" ) ) { if( !strcmp( temp_str,"TRUE" ) ) FILE_SPLIT = TRUE; else FILE_SPLIT = FALSE; } } } else if( !strcmp( split_str[0],"style" ) ) { if( checkstyle( split_str[1] ) ) syntax = FALSE; } else if( !strcmp( split_str[0],"colour" ) || !strcmp( split_str[0],"colour_min" ) || !strcmp( split_str[0],"colour_max" ) ) { if( checkcolour( split_str[1] ) ) syntax = FALSE; else { if( !strcmp( split_str[0],"colour" ) ) { temp_str = strdup( split_str[1] ); if( !isRGB ) StrToLowerCase( temp_str ); else { StrToUpperCase( temp_str ); StrReplaceChar( temp_str, orig_char, rep_char ); /* replace ';' in RGB format to ',' */ } COLOUR = temp_str; if( DBG ) fprintf(stderr,"COLOUR %s\n",COLOUR ); } if( !strcmp( split_str[0],"colour_min" ) ) { temp_str = strdup( split_str[1] ); if( !isRGB ) StrToLowerCase( temp_str ); else { StrToUpperCase( temp_str ); StrReplaceChar( temp_str, orig_char, rep_char ); /* replace ';' in RGB format to ',' */ } COLOUR_MIN = temp_str; if( DBG ) fprintf(stderr,"COLOUR %s\n",COLOUR_MIN ); } if( !strcmp( split_str[0],"colour_max" ) ) { temp_str = strdup( split_str[1] ); if( !isRGB ) StrToLowerCase( temp_str ); else { StrToUpperCase( temp_str ); StrReplaceChar( temp_str, orig_char, rep_char ); /* replace ';' in RGB format to ',' */ } COLOUR_MAX = temp_str; if( DBG ) fprintf(stderr,"COLOUR %s\n",COLOUR_MAX ); } } } else if( !strcmp( split_str[0],"device" ) ) { if( checkdevice( split_str[1] ) ) syntax = FALSE; } else if( !strcmp( split_str[0],"colour_triad" ) ) { temp_str = strdup( split_str[1] ); StrToUpperCase( temp_str ); if( strcmp( temp_str,"CW" ) && strcmp( temp_str,"ACW" ) ) syntax = FALSE; else { if( DBG ) fprintf( stderr, "TRIAD check %s!\n",temp_str); if( !strcmp( temp_str,"CW" ) ) COLOUR_TRIAD = "clockwise"; else COLOUR_TRIAD = "anti_clockwise"; } } } } if( !strcmp( split_str[0],"min" ) || !strcmp( split_str[0],"max" ) || !strcmp( split_str[0],"count" ) || !strcmp( split_str[0],"interval" ) || !strcmp( split_str[0],"thickness" ) || !strcmp( split_str[0],"resolution" ) || !strcmp( split_str[0],"step_freq" ) ) { if( !IsNumeric( split_str[1] ) ) syntax = FALSE; else { if( !strcmp( split_str[0],"min" ) ) { YMIN = atof( split_str[1] ); } if( !strcmp( split_str[0],"max" ) ) { YMAX = atof( split_str[1] ); } if( !strcmp( split_str[0],"count" ) ) { COUNT = atoi( split_str[1] ); } if( !strcmp( split_str[0],"interval" ) ) { INTERVAL = atof( split_str[1] ); } if( !strcmp( split_str[0],"thickness" ) ) { THICKNESS = atoi( split_str[1] ); } if( !strcmp( split_str[0],"resolution" ) ) { RESOLUTION = atoi( split_str[1] ); } if( !strcmp( split_str[0],"step_freq" ) ) { STEP_FREQ = atoi( split_str[1] ); } } } if( !strcmp( split_str[0],"colourtable" ) ) { if( ( fp = fopen( split_str[1],"r") ) == NULL ) { fprintf( stderr,"Input Color Table File not found in specified path '%s'\n", split_str[1] ); halt_flag = TRUE; } else { ReadColourTable ( split_str[1] ); } } if( !strcmp( split_str[0],"list" ) ) { sep_char = ";"; split_str_count = StringSplitWithSeperator( split_str[1], sep_char, &split_str1 ); if( !split_str_count ) { syntax = FALSE; } else { for( k = 0; k < split_str_count; k++ ) { if( !IsNumeric( split_str1[k] ) ) syntax = FALSE; } if( syntax == TRUE ) { NUM_LEVELS = split_str_count; LEV_LIST = (double*) malloc( sizeof( double ) * split_str_count ); for( k = 0; k < split_str_count; k++ ) { LEV_LIST[k] = atof( split_str1[k] ); } free( split_str1 ); } } } sep_char = "="; } /*** if( !strcmp( split_str[0], params[j] ) ) ***/ } /*** Loop over param count ***/ } /*** ( split_str_count > 1 ) ***/ else { syntax = FALSE; } if( found == FALSE ) { halt_flag = TRUE; fprintf( stderr,"Invalid parameter '%s'\n", param_names[i] ); } if( found == TRUE && syntax == FALSE ) { halt_flag = TRUE; fprintf( stderr,"Invalid parameter specification '%s'\n", param_names[i] ); } if( split_str ) free( split_str ); } /*** Loop over params ****/ if( halt_flag == TRUE ) { exit(0); } }