bool_t createRainbowTableUsingIni(const char * hashName,
				  const char * prefix,
				  const char * rule,
				  const char * iniFilename) {
	bool_t ret = FALSE;
	const char * keys[] = {	"dictionary_name",
				"rainbow_chain_length",
				"entires_in_hash_table",
				"bucket_block_length" };
	const char * values[sizeof(keys) / sizeof(*keys)] = {0};
	const uint_t numKeys = sizeof(keys) / sizeof(*keys);
	char * iniContent = NULL;
	
	/* Parse INI file */
	CHECK(verifyFileExists(iniFilename));
	iniContent = readEntireTextFile(iniFilename);
	CHECK(NULL != iniContent);
	CHECK(parseIni(iniContent, keys, values, numKeys));
	
	/* Invoke rainbow table creation */
	ret = createRainbowTable(hashName, prefix, rule, values[0], values[1], values[2], values[3]);

LBL_ERROR:
	FREE(iniContent);
	return ret;
}
Exemple #2
0
void IniConfigT::parseIniFromFile(ConstStrW fname, natural openFlags, bool ignoreErrors) {

	IniIncludeLoader loader(openFlags);
	IniIncludeLoader::Stream stream = loader.openInclude(fname);
	IniIncludeLoaderFn fn(loader);
	parseIni(stream,ignoreErrors,fn);

}
Exemple #3
0
iniFile *loadHookerIniFile(char *filename){
	strncpy(iniFileName,filename,sizeof(iniFileName));
	ini=parseIni(iniFileName);
	if(ini && ini->debuglevel){
		printf("[ini] monitor=%s\n",*ini->monitor?ini->monitor:"none (DISABLED)");
		printf("[ini] logfile=%s\n",*ini->logfile?ini->logfile:"none (DISABLED)");
		printf("[ini] debuglevel=%d\n",ini->debuglevel);
		printf("[ini] reinject=%d\n",ini->reinject);
	}
	return ini;
}
Exemple #4
0
int main(int argc, char* argv[]) {
	char dllToInject[512],iniFilePath[512];
	char cmd[512];
	DWORD pid=0;
	opt options;
	FILE *in;

	SetDebugPrivileges();
	//printf("%s\n",getfile_fullpath("\\\\.\\pipe\\mojo.6136.4468.15747523823731339023"));
	//return 1;
	char basePath[512];
	_fullpath(basePath, argv[0], sizeof(basePath));
	for(char *p=basePath+strlen(basePath);p>basePath;p--){
		if(*p=='\\') {
			*(p+1)=0;
			break;
		}
	}
	//build ini path
	strcpy(iniFilePath,basePath);
	strcat(iniFilePath,INIFILE);

	options.dumpIAT = FALSE;
	options.loadINI = TRUE;
	options.hook    = TRUE;
	options.unhook  = FALSE;
	options.cmdline = NULL;
	options.waitKeyPress = FALSE;
	options.iniPath = iniFilePath;
	options.suspended=FALSE;

	iniFile *ini=parseIni(iniFilePath);
	options.ini=ini;

	//build dll path
	strcpy(dllToInject,basePath);
	strcat(dllToInject,ini->dll);

	if(argc<2) usage(dllToInject,iniFilePath);

	in=fopen(dllToInject,"r");
	if(in==NULL){
		sprintf(cmd,"Error: DLL to inject NOT FOUND: %s",dllToInject);
		logger(ini,"injector",cmd,strlen(cmd));
		printf("DLL to inject not found... Path:\n");
		printf("%s\n",dllToInject);
		return 0;
	}
	fclose(in);

	if(argc>1 && argv[1][0]=='/'){
		//list processes
		if(argv[1][1]=='?' || argv[1][1]=='h') usage(dllToInject,iniFilePath);
		if(argv[1][1]=='l'){
			listProcesses();
			exit(0);
		}
		//read command line
		if(argv[1][1]=='x' || argv[1][1]=='X'){
			options.cmdline=argv[2];
			options.waitKeyPress=argv[1][1]=='X'?TRUE:FALSE;
		}
		//read the pid
		if(argv[1][1]=='p' || argv[1][1]=='P' || argv[1][1]=='i' || argv[1][1]=='u'){
			pid=atoi(argv[2]);
			if(argv[1][1]=='i') {
				options.dumpIAT=TRUE;
				options.hook=FALSE;
				sprintf(cmd,"Dump IAT requested for Pid %d",pid);
				logger(ini,"injector",cmd,strlen(cmd));
			}
			if(argv[1][1]=='u') {
				options.dumpIAT=FALSE;
				options.hook=FALSE;
				options.loadINI=FALSE;
				options.unhook=TRUE;
				sprintf(cmd,"Unhook requested for PID %d",pid);
				logger(ini,"injector",cmd,strlen(cmd));
			}
			if(argv[1][1]=='P') options.suspended=TRUE;
		}
	}

	printf(TITLE"\n");

	if(pid==0 && options.cmdline==NULL) return 1;

	if(pid!=0){
		HANDLE process = OpenProcess(MAXIMUM_ALLOWED, FALSE, pid);
		if(process == NULL) {
			printf("[Error] the specified process couldn't be found. Code: %d\n",GetLastError());
			sprintf(cmd,"Error: Invalid Pid %d",pid);
			logger(ini,"injector",cmd,strlen(cmd));
			return 1;
		}
	}
	if(ini->debuglevel>3){
		sprintf(cmd,"sinjector.exe called...",pid);
		logger(ini,"injector",cmd,strlen(cmd));
		sprintf(cmd,"Ini: %s",iniFilePath);
		logger(ini,"injector",cmd,strlen(cmd));
		sprintf(cmd,"DLL: %s",dllToInject);
		logger(ini,"injector",cmd,strlen(cmd));
	}

	//dump ini options
	if(ini && ini->debuglevel>0){
		printf("[ini] dll=%s\n",*ini->dll?ini->dll:"Error!!!");
		if(ini->monitor) printf("[ini] monitor=%s\n",*ini->monitor?ini->monitor:"none (DISABLED)");
		if(ini->logfile) printf("[ini] logfile=%s\n",*ini->logfile?ini->logfile:"none (DISABLED)");
		if(ini->iatfile) printf("[ini] iatfile=%s\n",*ini->iatfile?ini->iatfile:"none (DISABLED)");
		if(ini->backup)  printf("[ini] backup=%s\n",*ini->backup?ini->backup:"none (DISABLED)");
		printf("[ini] debuglevel=%d\n",ini->debuglevel);
		printf("[ini] reinject=%d (%s)\n",ini->reinject,ini->reinject?"ENABLED":"DISABLED");
		if(ini->reinject_blacklist) printf("[ini] reinject_blacklist=%s\n",*ini->reinject_blacklist?ini->reinject_blacklist:"none (DISABLED)");
	}else{
		options.loadINI=FALSE;
	}

	if(options.cmdline!=NULL){
		spwanAndHook(dllToInject,&options);
	}else{
		injecta(pid,dllToInject,&options);
	}
	//printf("Press [intro] to exit...\n");
	//getchar();
	return 0;
	/*
	//Classic DLL Injection
	//Get process handle passing in the process ID.
	HANDLE process = OpenProcess(MAXIMUM_ALLOWED, FALSE, pid);
	if(process == NULL) {
		printf("Error: the specified process couldn't be found\n");
		printf("PID: %d Last error: %d\n",pid,GetLastError());
		return FALSE;
	}
	 
	//Get address of the LoadLibrary function.
	LPVOID addrLoadLib = (LPVOID)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
	if(addrLoadLib == NULL) {
	printf("Error: the LoadLibraryA function was not found inside kernel32.dll library\n");
	}
	 
	//Allocate new memory region inside the process's address space.
	LPVOID arg = (LPVOID)VirtualAllocEx(process, NULL, strlen(buffer), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
	if(arg == NULL) {
	printf("Error: the memory could not be allocated inside the chosen process\n");
	}
	 
	//Write the argument to LoadLibraryA to the process's newly allocated memory region.
	int n = WriteProcessMemory(process, arg, buffer, strlen(buffer), NULL);
	if(n == 0) {
	printf("Error: there was no bytes written to the process's address space\n");
	}
	 
	//Inject our DLL into the process's address space.
	printf("Waiting for process (if it's suspended...)\n");   
	WaitForInputIdle(process,INFINITE);

	HANDLE threadID = CreateRemoteThread(process, NULL, 0, (LPTHREAD_START_ROUTINE)addrLoadLib, arg, 0, NULL);
	if(threadID == NULL) {
	printf("Error: the remote thread could not be created\n");
	}
	else {
	printf("Success: the remote thread was successfully created\n");
	}
	 
	//Close the handle to the process, becuase we've already injected the DLL.
	CloseHandle(process);
	*/	 
	return 0;
}
bool CertLauncher::parseIni()
{
    parseIni("BCI2000Certification.ini");
}