Examples/TLSFingerprinting/main.cpp
/**
 * Print cipher-suite map in a table sorted by number of occurrences (most common cipher-suite will be first)
 */
Print cipher-suite map in a table sorted by number of occurrences (most common cipher-suite will be first)
Print cipher - suite map in a table sorted by number of occurrences ( most common cipher - suite will be first )
void printCommonTLSFingerprints(const std::map<std::string, uint64_t>& tlsFingerprintMap, int printCountItems)
{
	std::vector<std::string> columnNames;
	columnNames.push_back("TLS Fingerprint");
	columnNames.push_back("Count");
	std::vector<int> columnsWidths;
	columnsWidths.push_back(32);
	columnsWidths.push_back(7);
	pcpp::TablePrinter printer(columnNames, columnsWidths);
	std::vector<std::pair<std::string, int> > map2vec(tlsFingerprintMap.begin(), tlsFingerprintMap.end());
	std::sort(map2vec.begin(),map2vec.end(), &stringCountComparer);
	for(std::vector<std::pair<std::string, int> >::iterator iter = map2vec.begin();
			iter != map2vec.end();
			iter++)
	{
		if (iter - map2vec.begin() >= printCountItems)
			break;
		std::stringstream values;
		values << iter->first << "|" << iter->second;
		printer.printRow(values.str(), '|');
	}
}
void printCommonTLSFingerprints ( const std :: map < std :: string , uint64_t > & tlsFingerprintMap , int printCountItems ) { std :: vector < std :: string > columnNames ; columnNames . push_back ( " " ) ; columnNames . push_back ( " " ) ; std :: vector < int > columnsWidths ; columnsWidths . push_back ( 32 ) ; columnsWidths . push_back ( 7 ) ; pcpp :: TablePrinter printer ( columnNames , columnsWidths ) ; std :: vector < std :: pair < std :: string , int > > map2vec ( tlsFingerprintMap . begin ( ) , tlsFingerprintMap . end ( ) ) ; std :: sort ( map2vec . begin ( ) , map2vec . end ( ) , & stringCountComparer ) ; for ( std :: vector < std :: pair < std :: string , int > > :: iterator iter = map2vec . begin ( ) ; iter != map2vec . end ( ) ; iter ++ ) { if ( iter - map2vec . begin ( ) >= printCountItems ) break ; std :: stringstream values ; values << iter -> first << " " << iter -> second ; printer . printRow ( values . str ( ) , ' ' ) ; } }
Print cipher-suite map in a table sorted by number of occurrences (most common cipher-suite will be first)
Print cipher - suite map in a table sorted by number of occurrences ( most common cipher - suite will be first )
// create the table // sort the TLS fingerprint map so the most popular will be first // since it's not possible to sort a std::map you must copy it to a std::vector and sort it then // go over all items (fingerprints + count) in the sorted vector and print them