library/src/network/nmapdb/BP-NmapDB.cc
// This function autodetects a result type and prints out the result.
This function autodetects a result type and prints out the result.
This function autodetects a result type and prints out the result .
int BP_NDBVisualizeResults(P_BP_NMAPDB_RESULTS result, size_t displayQuery)
{
	if(!result)
		return ERR_FAILURE;
	if(!result->opaque_data || !result->record_count)
		return ERR_FAILURE;
	size_t i = 0;
	BP_NMAPDB_RUNLIST   *tmp_runlist   = NULL;
	BP_NMAPDB_SCANNERS  *tmp_scanners  = NULL;
	BP_NMAPDB_TARGETS   *tmp_targets   = NULL;
	BP_NMAPDB_HOSTSTATS *tmp_hoststats = NULL;
	BP_NMAPDB_PORTSTATS *tmp_portstats = NULL;
	switch(result->type)
	{
		case BP_NMAPDB_RESULT_RUNLIST:
			printf("\n [+] Runlist NmapDB Information: %u total records", result->record_count);
			tmp_runlist = (P_BP_NMAPDB_RUNLIST) result->opaque_data;
			for(i = 0; i < result->record_count; i++)
				 BP_NDBVisualizeRunlist(&tmp_runlist[i]);
			break;
		case BP_NMAPDB_RESULT_SCANNERS:
			printf("\n [+] Scanners NmapDB Information: %u total records", result->record_count);
			tmp_scanners = (P_BP_NMAPDB_SCANNERS) result->opaque_data;
			for(i = 0; i < result->record_count; i++)
				 BP_NDBVisualizeScanners(&tmp_scanners[i]);
			break;
		case BP_NMAPDB_RESULT_TARGETS:
			printf("\n [+] Targets NmapDB Information: %u total records", result->record_count);
			tmp_scanners = (P_BP_NMAPDB_SCANNERS) result->opaque_data;
			for(i = 0; i < result->record_count; i++)
				 BP_NDBVisualizeTargets(&tmp_targets[i]);
			break;
		case BP_NMAPDB_RESULT_HOSTSTATS:
			printf("\n [+] Host Stats NmapDB Information: %u total records", result->record_count);
			tmp_hoststats = (P_BP_NMAPDB_HOSTSTATS) result->opaque_data;
			for(i = 0; i < result->record_count; i++)
				 BP_NDBVisualizeHostStats(&tmp_hoststats[i]);
			break;
		case BP_NMAPDB_RESULT_PORTSTATS:
			printf("\n [+] Port Stats NmapDB Information: %u total records", result->record_count);
			tmp_portstats = (P_BP_NMAPDB_PORTSTATS) result->opaque_data;
			for(i = 0; i < result->record_count; i++)
				BP_NDBVisualzePortStats(&tmp_portstats[i]);
			break;
		default:
			return ERR_FAILURE;
	}
	return ERR_SUCCESS;
}
int BP_NDBVisualizeResults ( P_BP_NMAPDB_RESULTS result , size_t displayQuery ) { if ( ! result ) return ERR_FAILURE ; if ( ! result -> opaque_data || ! result -> record_count ) return ERR_FAILURE ; size_t i = 0 ; BP_NMAPDB_RUNLIST * tmp_runlist = NULL ; BP_NMAPDB_SCANNERS * tmp_scanners = NULL ; BP_NMAPDB_TARGETS * tmp_targets = NULL ; BP_NMAPDB_HOSTSTATS * tmp_hoststats = NULL ; BP_NMAPDB_PORTSTATS * tmp_portstats = NULL ; switch ( result -> type ) { case BP_NMAPDB_RESULT_RUNLIST : printf ( " \n " , result -> record_count ) ; tmp_runlist = ( P_BP_NMAPDB_RUNLIST ) result -> opaque_data ; for ( i = 0 ; i < result -> record_count ; i ++ ) BP_NDBVisualizeRunlist ( & tmp_runlist [ i ] ) ; break ; case BP_NMAPDB_RESULT_SCANNERS : printf ( " \n " , result -> record_count ) ; tmp_scanners = ( P_BP_NMAPDB_SCANNERS ) result -> opaque_data ; for ( i = 0 ; i < result -> record_count ; i ++ ) BP_NDBVisualizeScanners ( & tmp_scanners [ i ] ) ; break ; case BP_NMAPDB_RESULT_TARGETS : printf ( " \n " , result -> record_count ) ; tmp_scanners = ( P_BP_NMAPDB_SCANNERS ) result -> opaque_data ; for ( i = 0 ; i < result -> record_count ; i ++ ) BP_NDBVisualizeTargets ( & tmp_targets [ i ] ) ; break ; case BP_NMAPDB_RESULT_HOSTSTATS : printf ( " \n " , result -> record_count ) ; tmp_hoststats = ( P_BP_NMAPDB_HOSTSTATS ) result -> opaque_data ; for ( i = 0 ; i < result -> record_count ; i ++ ) BP_NDBVisualizeHostStats ( & tmp_hoststats [ i ] ) ; break ; case BP_NMAPDB_RESULT_PORTSTATS : printf ( " \n " , result -> record_count ) ; tmp_portstats = ( P_BP_NMAPDB_PORTSTATS ) result -> opaque_data ; for ( i = 0 ; i < result -> record_count ; i ++ ) BP_NDBVisualzePortStats ( & tmp_portstats [ i ] ) ; break ; default : return ERR_FAILURE ; } return ERR_SUCCESS ; }
This function autodetects a result type and prints out the result.
This function autodetects a result type and prints out the result .
// make sure we have a result structure // temporary pointers used for indexing through opaque result data // switch to process data types // set opaque data as *structure // display individual data // set opaque data as *structure // display individual data // set opaque data as *structure // display individual data // set opaque data as *structure // display individual data // set opaque data as *structure // display individual data