/*
   * Constructor
   * --------------------
   */
  adfilter::adfilter() : plugin()
  {
    _name = "adfilter";
    _version_major = "0";
    _version_minor = "1";

    _config_filename = "adfilter-config";

    // Configuration
    _adconfig = new adfilter_configuration(
      seeks_proxy::_datadir.empty() ?
      plugin_manager::_plugin_repository + "adfilter/adfilter-config" :
      seeks_proxy::_datadir + "plugins/adfilter/adfilter-config"
    );
    _configuration = _adconfig;

    // Empty pattern vector for adblocker
    const std::vector<std::string> empty_pattern;

    // Always match pattern
    std::vector<std::string> always_pattern;
    std::string pat = "*";
    for(int i = 0; i < 8; i++)
      {
        pat.append(".*");
        always_pattern.push_back(pat);
      }

    // Create the plugins
    if(_adconfig->_use_filter)
      {
        _filter_plugin      = new adfilter_element(always_pattern, empty_pattern, this); // Filter plugin, everything but blocked URL
      }
    if(_adconfig->_use_blocker)
      {
        _interceptor_plugin = new adblocker_element(always_pattern, empty_pattern, this); // Interceptor plugin, blocked URL only
      }

    // libXML2 mutex
    this->mutexTok = xmlNewMutex();

    // libXML2 memory pre-allocation
    xmlInitParser();
  }
Exemple #2
0
/**
 * xmlInitMemory:
 *
 * Initialize the memory layer.
 *
 * Returns 0 on success
 */
int
xmlInitMemory(void)
{
#ifdef HAVE_STDLIB_H
  char *breakpoint;
#endif
#ifdef DEBUG_MEMORY
  xmlGenericError(xmlGenericErrorContext,
                  "xmlInitMemory()\n");
#endif
  /*
   This is really not good code (see Bug 130419).  Suggestions for
   improvement will be welcome!
  */
  if (xmlMemInitialized) return(-1);
  xmlMemInitialized = 1;
  xmlMemMutex = xmlNewMutex();

#ifdef HAVE_STDLIB_H
  breakpoint = getenv("XML_MEM_BREAKPOINT");
  if (breakpoint != NULL)
  {
    sscanf(breakpoint, "%ud", &xmlMemStopAtBlock);
  }
#endif
#ifdef HAVE_STDLIB_H
  breakpoint = getenv("XML_MEM_TRACE");
  if (breakpoint != NULL)
  {
    sscanf(breakpoint, "%p", &xmlMemTraceBlockAt);
  }
#endif

#ifdef DEBUG_MEMORY
  xmlGenericError(xmlGenericErrorContext,
                  "xmlInitMemory() Ok\n");
#endif
  return(0);
}
Exemple #3
0
/**
 * xmlInitGlobals:
 *
 * Additional initialisation for multi-threading
 */
void xmlInitGlobals()
{
    xmlThrDefMutex = xmlNewMutex();
}
Exemple #4
0
/**
 * xmlInitGlobals:
 *
 * Additional initialisation for multi-threading
 */
void xmlInitGlobals(void)
{
    if (xmlThrDefMutex == NULL)
        xmlThrDefMutex = xmlNewMutex();
}
Exemple #5
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;
}