Added the ability to detect when a known protocol is using a non-standard port
Added check to spot executables exchanged via HTTP
This commit is contained in:
+47
-26
@@ -975,26 +975,6 @@ static char* is_unsafe_cipher(ndpi_cipher_weakness c) {
|
||||
|
||||
/* ********************************** */
|
||||
|
||||
char* printUrlRisk(ndpi_url_risk risk) {
|
||||
switch(risk) {
|
||||
case ndpi_url_no_problem:
|
||||
return("");
|
||||
break;
|
||||
case ndpi_url_possible_xss:
|
||||
return(" ** XSS **");
|
||||
break;
|
||||
case ndpi_url_possible_sql_injection:
|
||||
return(" ** SQL Injection **");
|
||||
break;
|
||||
case ndpi_url_possible_rce_injection:
|
||||
return(" ** RCE Injection **");
|
||||
break;
|
||||
}
|
||||
|
||||
return("");
|
||||
}
|
||||
/* ********************************** */
|
||||
|
||||
/**
|
||||
* @brief Print the flow
|
||||
*/
|
||||
@@ -1218,13 +1198,34 @@ static void printFlow(u_int16_t id, struct ndpi_flow_info *flow, u_int16_t threa
|
||||
}
|
||||
}
|
||||
|
||||
if(flow->http.url[0] != '\0')
|
||||
fprintf(out, "[URL: %s%s][StatusCode: %u][ContentType: %s][UserAgent: %s]",
|
||||
flow->http.url,
|
||||
printUrlRisk(ndpi_validate_url(flow->http.url)),
|
||||
flow->http.response_status_code,
|
||||
flow->http.content_type, flow->http.user_agent);
|
||||
if(flow->http.url[0] != '\0') {
|
||||
u_int16_t risk = ndpi_validate_url(flow->http.url);
|
||||
|
||||
if(risk != NDPI_NO_RISK)
|
||||
flow->risk |= risk;
|
||||
|
||||
fprintf(out, "[URL: %s[StatusCode: %u]",
|
||||
flow->http.url, flow->http.response_status_code);
|
||||
|
||||
if(flow->http.content_type[0] != '\0')
|
||||
fprintf(out, "[ContentType: %s]", flow->http.content_type);
|
||||
|
||||
if(flow->http.user_agent[0] != '\0')
|
||||
fprintf(out, "[UserAgent: %s]", flow->http.user_agent);
|
||||
}
|
||||
|
||||
if(flow->risk) {
|
||||
u_int i;
|
||||
|
||||
fprintf(out, "[Risk: ");
|
||||
|
||||
for(i=0; i<NDPI_MAX_RISK; i++)
|
||||
if(NDPI_ISSET_BIT_16(flow->risk, i))
|
||||
fprintf(out, "** %s **", ndpi_risk2str(i));
|
||||
|
||||
fprintf(out, "]");
|
||||
}
|
||||
|
||||
if(flow->ssh_tls.ssl_version != 0) fprintf(out, "[%s]", ndpi_ssl_version2str(flow->ssh_tls.ssl_version, &known_tls));
|
||||
if(flow->ssh_tls.client_requested_server_name[0] != '\0') fprintf(out, "[Client: %s]", flow->ssh_tls.client_requested_server_name);
|
||||
if(flow->ssh_tls.client_hassh[0] != '\0') fprintf(out, "[HASSH-C: %s]", flow->ssh_tls.client_hassh);
|
||||
@@ -3042,6 +3043,25 @@ void test_lib() {
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
static void bitmapUnitTest() {
|
||||
u_int16_t val, i, j;
|
||||
|
||||
for(i=0; i<16; i++) {
|
||||
NDPI_ZERO_16(val);
|
||||
NDPI_SET_BIT_16(val, i);
|
||||
|
||||
assert(NDPI_ISSET_BIT_16(val, i));
|
||||
|
||||
for(j=0; j<16; j++) {
|
||||
if(j != i) {
|
||||
assert(!NDPI_ISSET_BIT_16(val, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
void automataUnitTest() {
|
||||
void *automa = ndpi_init_automa();
|
||||
|
||||
@@ -3258,6 +3278,7 @@ int orginal_main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
/* Internal checks */
|
||||
bitmapUnitTest();
|
||||
automataUnitTest();
|
||||
serializerUnitTest();
|
||||
analyzeUnitTest();
|
||||
|
||||
@@ -993,6 +993,8 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
|
||||
snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s",
|
||||
flow->ndpi_flow->flow_extra_info);
|
||||
|
||||
flow->risk = flow->ndpi_flow->risk;
|
||||
|
||||
if(is_ndpi_proto(flow, NDPI_PROTOCOL_DHCP)) {
|
||||
snprintf(flow->dhcp_fingerprint, sizeof(flow->dhcp_fingerprint), "%s", flow->ndpi_flow->protos.dhcp.fingerprint);
|
||||
} else if(is_ndpi_proto(flow, NDPI_PROTOCOL_BITTORRENT)) {
|
||||
|
||||
@@ -193,7 +193,8 @@ typedef struct ndpi_flow_info {
|
||||
char host_server_name[240];
|
||||
char bittorent_hash[41];
|
||||
char dhcp_fingerprint[48];
|
||||
|
||||
ndpi_risk risk;
|
||||
|
||||
struct {
|
||||
u_int16_t ssl_version;
|
||||
char client_requested_server_name[64], server_info[64],
|
||||
|
||||
Reference in New Issue
Block a user