Added flows risks report
This commit is contained in:
+49
-3
@@ -83,6 +83,7 @@ char *_debug_protocols = NULL;
|
|||||||
u_int8_t human_readeable_string_len = 5;
|
u_int8_t human_readeable_string_len = 5;
|
||||||
u_int8_t max_num_udp_dissected_pkts = 24 /* 8 is enough for most protocols, Signal and SnapchatCall require more */, max_num_tcp_dissected_pkts = 80 /* due to telnet */;
|
u_int8_t max_num_udp_dissected_pkts = 24 /* 8 is enough for most protocols, Signal and SnapchatCall require more */, max_num_tcp_dissected_pkts = 80 /* due to telnet */;
|
||||||
static u_int32_t pcap_analysis_duration = (u_int32_t)-1;
|
static u_int32_t pcap_analysis_duration = (u_int32_t)-1;
|
||||||
|
static u_int32_t risk_stats[NDPI_MAX_RISK] = { 0 }, risks_found = 0;
|
||||||
static u_int16_t decode_tunnels = 0;
|
static u_int16_t decode_tunnels = 0;
|
||||||
static u_int16_t num_loops = 1;
|
static u_int16_t num_loops = 1;
|
||||||
static u_int8_t shutdown_app = 0, quiet_mode = 0;
|
static u_int8_t shutdown_app = 0, quiet_mode = 0;
|
||||||
@@ -2237,6 +2238,53 @@ void printPortStats(struct port_stats *stats) {
|
|||||||
|
|
||||||
/* *********************************************** */
|
/* *********************************************** */
|
||||||
|
|
||||||
|
static void node_flow_risk_walker(const void *node, ndpi_VISIT which, int depth, void *user_data) {
|
||||||
|
struct ndpi_flow_info *f = *(struct ndpi_flow_info**)node;
|
||||||
|
|
||||||
|
if(f->risk) {
|
||||||
|
u_int j;
|
||||||
|
|
||||||
|
for(j = 0; j < NDPI_MAX_RISK; j++) {
|
||||||
|
ndpi_risk_enum r = (ndpi_risk_enum)j;
|
||||||
|
|
||||||
|
if(NDPI_ISSET_BIT(f->risk, r))
|
||||||
|
risks_found++, risk_stats[r]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *********************************************** */
|
||||||
|
|
||||||
|
static void printRiskStats() {
|
||||||
|
if(!quiet_mode) {
|
||||||
|
u_int thread_id, i;
|
||||||
|
|
||||||
|
for(thread_id = 0; thread_id < num_threads; thread_id++) {
|
||||||
|
for(i=0; i<NUM_ROOTS; i++)
|
||||||
|
ndpi_twalk(ndpi_thread_info[thread_id].workflow->ndpi_flows_root[i],
|
||||||
|
node_flow_risk_walker, &thread_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(risks_found) {
|
||||||
|
printf("\nRisk statistics:\n");
|
||||||
|
|
||||||
|
for(i = 0; i < NDPI_MAX_RISK; i++) {
|
||||||
|
ndpi_risk_enum r = (ndpi_risk_enum)i;
|
||||||
|
|
||||||
|
if(risk_stats[r] != 0)
|
||||||
|
printf("\t%-40s %5u [%4.01f %%]\n", ndpi_risk2str(r), risk_stats[r],
|
||||||
|
(float)(risk_stats[r]*100)/(float)risks_found);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n\tNOTE: as one flow can have multiple risks set, the sum of\n"
|
||||||
|
"\t flows with risks can exceed the number of observed flows\n");
|
||||||
|
printf("\n\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *********************************************** */
|
||||||
|
|
||||||
static void printFlowsStats() {
|
static void printFlowsStats() {
|
||||||
int thread_id;
|
int thread_id;
|
||||||
u_int32_t total_flows = 0;
|
u_int32_t total_flows = 0;
|
||||||
@@ -2410,7 +2458,6 @@ static void printFlowsStats() {
|
|||||||
HASH_ADD_INT(hostByJA3Found->ipToDNS_ht, ip, newInnerElement);
|
HASH_ADD_INT(hostByJA3Found->ipToDNS_ht, ip, newInnerElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2763,7 +2810,6 @@ static void printFlowsStats() {
|
|||||||
|
|
||||||
for(i=0; i<num_flows; i++)
|
for(i=0; i<num_flows; i++)
|
||||||
printFlow(i+1, all_flows[i].flow, all_flows[i].thread_id);
|
printFlow(i+1, all_flows[i].flow, all_flows[i].thread_id);
|
||||||
|
|
||||||
} else if(csv_fp != NULL) {
|
} else if(csv_fp != NULL) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -2949,6 +2995,7 @@ static void printResults(u_int64_t processing_time_usec, u_int64_t setup_time_us
|
|||||||
|
|
||||||
// printf("\n\nTotal Flow Traffic: %llu (diff: %llu)\n", total_flow_bytes, cumulative_stats.total_ip_bytes-total_flow_bytes);
|
// printf("\n\nTotal Flow Traffic: %llu (diff: %llu)\n", total_flow_bytes, cumulative_stats.total_ip_bytes-total_flow_bytes);
|
||||||
|
|
||||||
|
printRiskStats();
|
||||||
printFlowsStats();
|
printFlowsStats();
|
||||||
|
|
||||||
if(verbose == 3) {
|
if(verbose == 3) {
|
||||||
@@ -4284,4 +4331,3 @@ int original_main(int argc, char **argv) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user