int main(int argc, char *argv[]) { int argi; char *envarea = NULL; char *critconfig = NULL; char *hffile = "critical"; for (argi = 1; (argi < argc); argi++) { if (argnmatch(argv[argi], "--env=")) { char *p = strchr(argv[argi], '='); loadenv(p+1, envarea); } else if (argnmatch(argv[argi], "--area=")) { char *p = strchr(argv[argi], '='); envarea = strdup(p+1); } else if (strcmp(argv[argi], "--debug") == 0) { debug = 1; } else if (strcmp(argv[argi], "--tooltips") == 0) { usetooltips = 1; } else if (argnmatch(argv[argi], "--acklevel=")) { char *p = strchr(argv[argi], '='); critacklevel = atoi(p+1); } else if (argnmatch(argv[argi], "--config=")) { char *p = strchr(argv[argi], '='); critconfig = strdup(p+1); } else if (argnmatch(argv[argi], "--hffile=")) { char *p = strchr(argv[argi], '='); hffile = strdup(p+1); } } redirect_cgilog("criticalview"); setdocurl(hostsvcurl("%s", xgetenv("INFOCOLUMN"), 1)); parse_query(); load_hostnames(xgetenv("HOSTSCFG"), NULL, get_fqdn()); load_critconfig(critconfig); load_all_links(); fprintf(stdout, "Content-type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); if (loadstatus(maxprio, maxage, mincolor, wantacked) == 0) { use_recentgifs = 1; generate_critpage(stdout, hffile); } else { fprintf(stdout, "Cannot load Xymon status\n"); } return 0; }
int main(int argc, char *argv[]) { int argi; char *envarea = NULL; char **critconfig = NULL; int cccount = 0; char *hffile = "critical"; critconfig = (char **)calloc(1, sizeof(char *)); for (argi = 1; (argi < argc); argi++) { if (argnmatch(argv[argi], "--env=")) { char *p = strchr(argv[argi], '='); loadenv(p+1, envarea); } else if (argnmatch(argv[argi], "--area=")) { char *p = strchr(argv[argi], '='); envarea = strdup(p+1); } else if (strcmp(argv[argi], "--debug") == 0) { debug = 1; } else if (strcmp(argv[argi], "--tooltips") == 0) { usetooltips = 1; } else if (argnmatch(argv[argi], "--acklevel=")) { char *p = strchr(argv[argi], '='); critacklevel = atoi(p+1); } else if (argnmatch(argv[argi], "--config=")) { char *p = strchr(argv[argi], '='); critconfig[cccount] = strdup(p+1); cccount++; critconfig = (char **)realloc(critconfig, (1 + cccount)*sizeof(char *)); critconfig[cccount] = NULL; } else if (argnmatch(argv[argi], "--hffile=")) { char *p = strchr(argv[argi], '='); hffile = strdup(p+1); } } if (!critconfig[0]) { critconfig = (char **)realloc(critconfig, 2*sizeof(char *)); critconfig[0] = (char *)malloc(strlen(xgetenv("XYMONHOME")) + strlen(DEFAULT_CRITCONFIGFN) + 2); sprintf(critconfig[0], "%s/%s", xgetenv("XYMONHOME"), DEFAULT_CRITCONFIGFN); critconfig[1] = NULL; } redirect_cgilog("criticalview"); setdocurl(hostsvcurl("%s", xgetenv("INFOCOLUMN"), 1)); parse_query(); load_hostnames(xgetenv("HOSTSCFG"), NULL, get_fqdn()); load_all_links(); fprintf(stdout, "Content-type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); use_recentgifs = 1; if (getboard(mincolor) == 0) { int i; char *oneconfig, *onename; int *partcolor = NULL, *partprio = NULL; xtreePos_t hhandle; for (i=0; (critconfig[i]); i++) { oneconfig = strchr(critconfig[i], ':'); load_critconfig(oneconfig ? oneconfig+1 : critconfig[i]); loadstatus(maxprio, maxage, mincolor, wantacked); /* Determine background color and max. priority */ if (i == 0) { partcolor = (int *)malloc(sizeof(int)); partprio = (int *)malloc(sizeof(int)); } else { partcolor = (int *)realloc(partcolor, (i+1)*sizeof(int)); partprio = (int *)realloc(partprio, (i+1)*sizeof(int)); } partcolor[i] = COL_GREEN; partprio[i] = 0; for (hhandle = xtreeFirst(rbstate[i]); (hhandle != xtreeEnd(rbstate[i])); hhandle = xtreeNext(rbstate[i], hhandle)) { hstatus_t *itm; itm = (hstatus_t *)xtreeData(rbstate[i], hhandle); if (itm->color > partcolor[i]) partcolor[i] = itm->color; if (itm->config->priority > partprio[i]) partprio[i] = itm->config->priority; } if (partcolor[i] > pagecolor) pagecolor = partcolor[i]; } for (i=0; (critconfig[i]); i++) { oneconfig = strchr(critconfig[i], ':'); if (oneconfig) { *oneconfig = '\0'; oneconfig++; onename = (char *)malloc(strlen("DIVIDERTEXT=") + strlen(critconfig[i]) + 1); sprintf(onename, "DIVIDERTEXT=%s", critconfig[i]); putenv(onename); } else { oneconfig = critconfig[i]; putenv("DIVIDERTEXT="); } generate_critpage(rbstate[i], hostsonpage[i], stdout, (i == 0) ? (critconfig[1] ? "critmulti" : hffile) : "divider", (critconfig[i+1] == NULL) ? hffile : "divider", partcolor[i], partprio[i]); } } else { fprintf(stdout, "Cannot load Xymon status\n"); } return 0; }
void init(int argc, char **argv) { unsigned int i, j; int help = 0; int threads = 2; int archive_type = -1; FILE* totest; char test[300]; xmlInitThreads(); pwdMutex = xmlNewMutex(); finishedMutex = xmlNewMutex(); if (argc == 1) { printf("USAGE: rarcrack encrypted_archive.ext [--threads NUM] [--type rar|zip|7z]\n"); printf(" For more information please run \"rarcrack --help\"\n"); help = 1; } else { for (i = 1; i < argc; i++) { if (strcmp(argv[i],"--help") == 0) { printf("Usage: rarcrack encrypted_archive.ext [--threads NUM] [--type rar|zip|7z]\n\n"); printf("Options: --help: show this screen.\n"); printf(" --type: you can specify the archive program, this needed when\n"); printf(" the program couldn't detect the proper file type\n"); printf(" --threads: you can specify how many threads\n"); printf(" will be run, maximum 12 (default: 2)\n\n"); printf("Info: This program supports only RAR, ZIP and 7Z encrypted archives.\n"); printf(" RarCrack! usually detects the archive type.\n\n"); help = 1; break; } else if (strcmp(argv[i],"--threads") == 0) { if ((i + 1) < argc) { sscanf(argv[++i], "%d", &threads); if (threads < 1) threads = 1; if (threads > 12) { printf("INFO: number of threads adjusted to 12\n"); threads = 12; } } else { printf("ERROR: missing parameter for option: --threads!\n"); help = 1; } } else if (strcmp(argv[i],"--type") == 0) { if ((i + 1) < argc) { sscanf(argv[++i], "%s", &test); for (j = 0; strcmp(TYPE[j], "") != 0; j++) { if (strcmp(TYPE[j], test) == 0) { strcpy(finalcmd, CMD[j]); archive_type = j; break; } } if (archive_type < 0) { printf("WARNING: invalid parameter --type %s!\n", argv[i]); finalcmd[0] = '\0'; } } else { printf("ERROR: missing parameter for option: --type!\n"); help = 1; } } else { strcpy((char*)&filename, argv[i]); } } } if (help == 1) return; sprintf((char*)&statname,"%s.xml",(char*)&filename); totest = fopen(filename,"r"); if (totest == NULL) { printf("ERROR: The specified file (%s) is not exists or \n", filename); printf(" you don't have a right permissions!\n"); return; } else fclose(totest); if (finalcmd[0] == '\0') { //when we specify the file type, the programm will skip the test sprintf((char*)&test, CMD_DETECT, filename); totest = popen(test,"r"); fscanf(totest,"%s",(char*)&test); pclose(totest); for (i = 0; strcmp(MIME[i],"") != 0; i++) { if (strcmp(MIME[i],test) == 0) { strcpy(finalcmd,CMD[i]); archive_type = i; break; } } printf("INFO: detected file type: %s\n", TYPE[archive_type]); } else printf("INFO: the specified archive type: %s\n", TYPE[archive_type]); if (finalcmd[0] == '\0') { printf("ERROR: Couldn't detect archive type\n"); return; } /*else printf("DEBUG: the unpack command is: '%s'\n", finalcmd);*/ printf("INFO: cracking %s, status file: %s\n", filename, statname); if (loadstatus() == 1) { printf("ERROR: The status file (%s) is corrupted!\n", statname); return; } ABCLEN = strlen(ABC); if (password[0] == '\0') password[0] = ABC[0]; crack_start(threads); return; }