コード例 #1
0
void CChainWalkContext::Dump()
{
	printf("hash routine: %s\n", m_sHashRoutineName.c_str());
	printf("hash length: %d\n", m_nHashLen);

	for ( uint32_t i = 0; i < m_vCharset.size(); i++ )
	{
		printf( "m_vCharset[%d].m_nPlainCharSetLen: %d\n", i, m_vCharset[i].m_nPlainCharsetLen );

		printf("plain charset: ");
		
		for ( uint32_t j = 0; j < m_vCharset[i].m_nPlainCharsetLen; j++ )
		{
			if (isprint(m_vCharset[i].m_PlainCharset[j]))
				printf("%c", m_vCharset[i].m_PlainCharset[j]);
			else
				printf("?");
		}
		printf("\n");

		for ( int j = 0; j <= m_vCharset[i].m_nPlainLenMax; j++ )
		{
			printf( "m_vCharset[%d].m_nPlainSpaceUpToX[%d]: %"PRIu64"\n"
				, i, j, m_vCharset[i].m_nPlainSpaceUpToX[j] );
		}
		
		printf("plain charset in hex: ");

		for ( uint32_t j = 0; j < m_vCharset[i].m_nPlainCharsetLen; j++ )
			printf("%02x ", m_vCharset[i].m_PlainCharset[j]);
		printf("\n");

		printf("plain length range: %d - %d\n", m_vCharset[i].m_nPlainLenMin, m_vCharset[i].m_nPlainLenMax);
		printf("plain charset name: %s\n", m_vCharset[i].m_sPlainCharsetName.c_str());
		printf("plain subkey space total: %s\n", uint64tostr(m_vCharset[i].m_nPlainSpaceTotal).c_str());
	}
		
	for ( int i = 0; i <= m_nPlainLenMaxTotal; i++ )
	{
		printf( "m_nPlainSpaceUpToX[%d]: %"PRIu64"\n"
			, i, m_nPlainSpaceUpToX[i] );
	}

	//printf("plain charset content: %s\n", m_sPlainCharsetContent.c_str());
	//for (i = 0; i <= m_nPlainLenMax; i++)
	//	printf("plain space up to %d: %s\n", i, uint64tostr(m_nPlainSpaceUpToX[i]).c_str());
	printf("plain space total: %s\n", uint64tostr(m_nPlainSpaceTotal).c_str());

	printf("rainbow table index: %d\n", m_nRainbowTableIndex);
	printf("reduce offset: %s\n", uint64tostr(m_nReduceOffset).c_str());
	printf("\n");
}
コード例 #2
0
ファイル: otp.c プロジェクト: UNIVERSAL-IT-SYSTEMS/otpn900
const gchar*
token_get_counter_as_str ( Token *token )
{
  return uint64tostr ( token->counter );
}
コード例 #3
0
ファイル: rti2rto.cpp プロジェクト: dak180/distrrtgen
int main(int argc, char* argv[])
{
	bool debug = false;
	uint32 dropLastNchains = 0;
	uint32 dropHighSPcount = 0;
	int sptl = 0;

	if (argc < 2)
	{
		usage();
		return 0;
	}
	
	std::vector<std::string> pathNames;

	// Parse command line args
	int i;
	for( i = 1; i < argc; i++ )
	{
		if ( strncmp( argv[i], "-v", 2 ) == 0 )
			debug = true;
		else if ( strncmp( argv[i], "-drop_last_n_chains=", 20 ) == 0 )
		{
			uint32 j;

			for ( j = 20; argv[i][j] >= '0' && argv[i][j] <= '9'; j++ )
			{
				dropLastNchains *= 10;
				dropLastNchains += ((int) argv[i][j] ) - 0x30;
			}

			if ( argv[i][j] != '\0' )
			{
				printf("Error: Invalid drop_last_n_chains number.\n\n");
				usage();
				exit( 1 );
			}
		}
		else if ( strncmp( argv[i], "-drop_high_sp_n_chains=", 23 ) == 0 )
		{
			uint32 j;

			for ( j = 23; argv[i][j] >= '0' && argv[i][j] <= '9'; j++ )
			{
				dropHighSPcount *= 10;
				dropHighSPcount += ((int) argv[i][j] ) - 0x30;
			}

			if ( argv[i][j] != '\0' )
			{
				printf("Error: Invalid drop_high_sp_n_chains number.\n\n");
				usage();
				exit( 1 );
			}
		}
		else if ( strncmp( argv[i], "-sptl=", 6 ) == 0 )
		{
			uint32 j;

			for ( j = 6; argv[i][j] >= '0' && argv[i][j] <= '9'; j++ )
			{
				sptl *= 10;
				sptl += ((int) argv[i][j] ) - 0x30;
			}

			if ( argv[i][j] != '\0' )
			{
				printf("Error: Invalid sptl number.\n\n");
				usage();
				exit( 1 );
			}
		}
		else
			GetTableList( argv[i], pathNames );
	}

	if ( debug )
	{
		for( int i = 0; i < argc; i++ )
			printf("%i: %s\n", i, argv[i]);
	}

	if ( pathNames.size() == 0 )
	{
		printf("no rainbow table found\n");
		return 0;
	}

	std::string resultFile, sType;

	for ( uint32 i = 0; i < pathNames.size(); i++ )
	{
		if( pathNames[i].substr( pathNames[i].length() - 4, pathNames[i].length()) == "rti2")
		{
			resultFile = pathNames[i].substr(0, pathNames[i].length() - 2); // Resulting file is .rt, not .rti2
			sType = "RTI2";
		}
		else if( pathNames[i].substr( pathNames[i].length() - 3, pathNames[i].length()) == "rti")
		{
			resultFile = pathNames[i].substr( 0, pathNames[i].length() - 1 ); // Resulting file is .rt, not .rti
			sType = "RTI";
		}
		else 
		{
			printf("File %s is not a RTI or a RTI2 file", pathNames[i].c_str() );
			continue;
		}
		
		// XXX this assumes someone is converting either just the last file
		// *or* doing a whole set which will read the last file first
		if ( dropLastNchains > 0 && i == 0 )
		{
			std::string::size_type lastX = resultFile.find_last_of('x');

			if ( lastX == std::string::npos )
			{
				std::cout << "Could not parse the filename to drop the last chains"
					<< std::endl;
				exit( -1 );
			}
			
			std::string::size_type firstSplit
				= resultFile.find_first_of('_',lastX);

			#if defined(_WIN32) && !defined(__GNUC__)
				uint64 chains = _atoi64( resultFile.substr( lastX + 1, firstSplit - lastX - 1).c_str() );
			#else
				uint64 chains = atoll( resultFile.substr( lastX + 1, firstSplit - lastX - 1 ).c_str() );
			#endif

			chains -= dropLastNchains;

			resultFile.replace( lastX + 1, firstSplit - lastX - 1, uint64tostr( chains ) );
		}

		ConvertRainbowTable( pathNames[i], resultFile, sType, debug, dropLastNchains, dropHighSPcount, sptl );
		dropLastNchains = 0;
		dropHighSPcount = 0;

		printf("\n");
	}
	return 0;
}
コード例 #4
0
ファイル: rti2rto.cpp プロジェクト: dak180/distrrtgen
void ConvertRainbowTable( std::string pathName, std::string resultFileName, std::string sType, bool debug, uint32 dropLastNchains, uint32 dropHighSPcount, int sptl )
{
#ifdef _WIN32
	std::string::size_type nIndex = pathName.find_last_of('\\');
#else
	std::string::size_type nIndex = pathName.find_last_of('/');
#endif
	std::string fileName;

	if ( nIndex != std::string::npos )
		fileName = pathName.substr( nIndex + 1 );
	else
		fileName = pathName;

	// Info
	printf("%s:\n", fileName.c_str());
	FILE *fResult = fopen(resultFileName.c_str(), "wb");
	if(fResult == NULL)
	{
		printf("Could not open %s for write access", resultFileName.c_str());
		return;
	}
	static CMemoryPool mp;
	uint64 nAllocatedSize;
	BaseRTReader *reader = NULL;
	if(sType == "RTI2")
		reader = new RTI2Reader( pathName );
	else if(sType == "RTI")
		reader = new RTIReader( pathName );
	else 
	{
		printf("Invalid table type '%s'", sType.c_str());
		return ;
	}

	if ( debug )
		reader->Dump();

	uint64 size = reader->getChainsLeft() * sizeof(RainbowChainO);
	uint64 rainbowChainCount = reader->getChainsLeft();
	uint64 chainsLeft;

	rainbowChainCount -= dropLastNchains;
	rainbowChainCount -= dropHighSPcount;

	size -= sizeof(RainbowChainO) * dropLastNchains;

#ifdef _MEMORYDEBUG
	printf("Starting allocation of %i bytes\n", size);
#endif
	RainbowChainO* pChain = (RainbowChainO*)mp.Allocate(size, nAllocatedSize);
#ifdef _MEMORYDEBUG
	printf("Finished. Got %i bytes\n", nAllocatedSize);
#endif
	if (pChain != NULL)
	{
		nAllocatedSize = nAllocatedSize / sizeof(RainbowChainO) * sizeof(RainbowChainO);		// Round to boundary
		unsigned int nChains = nAllocatedSize / sizeof(RainbowChainO);
		while( ( chainsLeft = reader->getChainsLeft() ) > 0 && chainsLeft > dropLastNchains )
		{
#ifdef _MEMORYDEBUG
			printf("Grabbing %i chains from file\n", nChains);
#endif
			reader->readChains(nChains, pChain);
#ifdef _MEMORYDEBUG
			printf("Recieved %i chains from file\n", nChains);
#endif
			for(uint32 i = 0; i < nChains; i++)
			{
				if ( dropHighSPcount > 0 && GetMaxBits(pChain[i].nIndexS) > sptl )
				{
					//dropHighSPcount++;
				}
				else if ( dropLastNchains > 0 && dropLastNchains >= ( chainsLeft - i ) )
				{
				}
				else
					fwrite(&pChain[i], 1, 16, fResult);
			}
		}
	}
	fclose(fResult);

	if(reader != NULL)
		delete reader;

	if ( dropHighSPcount > 0 )
	{
		std::string::size_type lastX = resultFileName.find_last_of('x');

		if ( lastX == std::string::npos )
		{
			std::cout << "Could not parse the filename to drop the high SP chains"
				<< std::endl;
			exit( -1 );
		}
		
		std::string::size_type firstSplit
			= resultFileName.find_first_of('_',lastX);

		if ( firstSplit == std::string::npos )
		{
			std::cout << "Could not parse the filename to drop the high SP chains"
				<< std::endl;
			exit( -1 );
		}

		std::string newResultFileName = resultFileName;

		newResultFileName.replace( lastX + 1, firstSplit - lastX - 1, uint64tostr( rainbowChainCount ) );
		
		if ( rename( resultFileName.c_str(), newResultFileName.c_str() ) != 0 )
		{
			std::cout << "Could not parse the filename to drop the high SP chains"
				<< std::endl;
			exit( -1 );
		}
	}
}