示例#1
0
void DarunGrim::RunIDAToCreateDGF(const char *ida_filename, unsigned long StartAddress, unsigned long EndAddress)
{
	char *idc_filename = WriteToTemporaryFile(RUN_DARUNGRIM_PLUGIN_STR,
		EscapedLogFilename ? EscapedLogFilename : "",
		EscapedOutputFilename ? EscapedOutputFilename : "",
		StartAddress,
		EndAddress);

	if (idc_filename)
	{
		//Run IDA
		Logger.Log(10, "Analyzing [%s]( %s )\n", ida_filename, idc_filename);
		if (IDALogFilename[0])
		{
			Logger.Log(10, "Executing \"%s\" -A -L\"%s\" -S\"%s\" \"%s\"", IDAPath, IDALogFilename, idc_filename, ida_filename);
			Execute(TRUE, "\"%s\" -A -L\"%s\" -S\"%s\" \"%s\"", IDAPath, IDALogFilename, idc_filename, ida_filename);
		}
		else
		{
			Logger.Log(10, "Executing \"%s\" -A -S\"%s\" \"%s\"", IDAPath, idc_filename, ida_filename);
			Execute(TRUE, "\"%s\" -A -S\"%s\" \"%s\"", IDAPath, idc_filename, ida_filename);
		}
		free(idc_filename);
	}
}
示例#2
0
	bool Init( void ) {
		if ( handle ) {
			return true;
		}
		handle = new MMDB_s{};
		int status = -1;

		char fs_gameString[MAX_CVAR_VALUE_STRING];
		trap->Cvar_VariableStringBuffer( "fs_game", fs_gameString, sizeof(fs_gameString) );
		const char *sPath = va( "%s/GeoLite2-Country.mmdb", fs_gameString );

		trap->Print( "Loading %s\n", sPath );
		fileHandle_t f = NULL_FILE;
		unsigned int len = trap->FS_Open( sPath, &f, FS_READ );

		// no file
		if ( !f ) {
			return false;
		}

		// empty file
		if ( !len || len == -1 ) {
			trap->FS_Close( f );
			return false;
		}

		// alloc memory for buffer
		char *buf = (char *)malloc( len + 1 );
		if ( !buf ) {
			return false;
		}

		trap->FS_Read( buf, len, f );
		trap->FS_Close( f );
		buf[len] = '\0';

		// pass it off to the json reader
		char *tmpFilePath = nullptr;
		trap->Print( "writing to temporary file\n" );
		if ( WriteToTemporaryFile( buf, len, &tmpFilePath ) ) {
			trap->Print( "loading from temporary file %s\n", tmpFilePath );
			if ( (status = MMDB_open( tmpFilePath, MMDB_MODE_MMAP, handle ) ) != MMDB_SUCCESS ) {
				trap->Print( "Error occured while initialising MaxMind GeoIP: \"%s\"\n", MMDB_strerror( status ) );
				delete handle;
				handle = nullptr;
				return false;
			}
		}

		free( buf );

		return true;
	}
示例#3
0
void DarunGrim::ConnectToDarunGrim(const char *ida_filename)
{
	char *idc_filename = WriteToTemporaryFile(CONNECT_TO_DARUNGRIM_STR, EscapedLogFilename ? EscapedLogFilename : "");

	if (idc_filename)
	{
		//Run IDA
		Logger.Log(10, "Analyzing [%s]( %s )\n", ida_filename, idc_filename);
		Logger.Log(10, "\"%s\" -S\"%s\" \"%s\"", IDAPath, EscapedLogFilename, idc_filename, ida_filename);

		if (IDALogFilename[0])
		{
			Execute(TRUE, "\"%s\" -L\"%s\" -S\"%s\" \"%s\"", IDAPath, IDALogFilename, idc_filename, ida_filename);
		}
		else
		{
			Execute(TRUE, "\"%s\" -S\"%s\" \"%s\"", IDAPath, idc_filename, ida_filename);
		}
		free(idc_filename);
	}
}
示例#4
0
	bool Init( void ) {
		if ( handle ) {
			return true;
		}
		handle = new MMDB_s{};
		int status = -1;

		const char *sPath = "GeoLite2-Country.mmdb";
		trap->Print( "Loading %s\n", sPath );
		fileHandle_t f = NULL_FILE;
		unsigned int len = trap->FS_Open( sPath, &f, FS_READ );

		// no file
		if ( !f ) {
			return false;
		}

		// empty file
		if ( !len || len == -1 ) {
			trap->FS_Close( f );
			return false;
		}

		// alloc memory for buffer
		char *buf = (char *)malloc( len + 1 );
		if ( !buf ) {
			return false;
		}

		trap->FS_Read( buf, len, f );
		trap->FS_Close( f );
		buf[len] = '\0';

		const char *extension = nullptr;
		for ( const char *p = sPath + strlen(sPath); p != sPath; p-- ) {
			if ( *p == '.' ) {
				extension = p;
				break;
			}
		}
		char *tmpFilePath = nullptr;
		if ( WriteToTemporaryFile( buf, len, &tmpFilePath, extension ) ) {
			trap->Print( "Failed to create temporary file\n" );
			free( buf );
			return false;
		}

		trap->Print( "loading from temporary file %s\n", tmpFilePath );
		status = MMDB_open( tmpFilePath, MMDB_MODE_MMAP, handle );
		if ( status != MMDB_SUCCESS ) {
			trap->Print( "Error occured while initialising MaxMind GeoIP: \"%s\"\n", MMDB_strerror( status ) );
			delete handle;
			handle = nullptr;

			free( tmpFilePath );
			free( buf );
			return false;
		}

		free( tmpFilePath );
		free( buf );
		return true;
	}