added cipher check
This commit is contained in:
+44
-29
@@ -59,7 +59,7 @@
|
|||||||
that usually is packet 14
|
that usually is packet 14
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SSH_DEBUG 1
|
/* #define SSH_DEBUG 1 */
|
||||||
|
|
||||||
static void ndpi_search_ssh_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
static void ndpi_search_ssh_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ static void ssh_analyze_signature_version(struct ndpi_detection_module_struct *n
|
|||||||
int patch = 0;
|
int patch = 0;
|
||||||
int obsolete_ssh_version = 0;
|
int obsolete_ssh_version = 0;
|
||||||
|
|
||||||
if (sscanf(str_to_check, "SSH-%*f-OpenSSH_%d.%d.%d", &major, &minor, &patch) < 0)
|
if (sscanf(str_to_check, "SSH-%*f-OpenSSH_%d.%d.%d", &major, &minor, &patch) != 3)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((major || minor || patch) == 0) return;
|
if ((major || minor || patch) == 0) return;
|
||||||
@@ -92,7 +92,6 @@ static void ssh_analyze_signature_version(struct ndpi_detection_module_struct *n
|
|||||||
if (patch < PATCH_CUTOFF) obsolete_ssh_version = 1;
|
if (patch < PATCH_CUTOFF) obsolete_ssh_version = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if (obsolete_ssh_version) {
|
if (obsolete_ssh_version) {
|
||||||
#ifdef SSH_DEBUG
|
#ifdef SSH_DEBUG
|
||||||
printf("[SSH] [SSH Version: %d.%d.%d]\n", major, minor, patch);
|
printf("[SSH] [SSH Version: %d.%d.%d]\n", major, minor, patch);
|
||||||
@@ -100,42 +99,58 @@ static void ssh_analyze_signature_version(struct ndpi_detection_module_struct *n
|
|||||||
|
|
||||||
NDPI_SET_BIT(flow->risk, (is_client_signature ? NDPI_SSH_OBSOLETE_CLIENT_VERSION_OR_CIPHER : NDPI_SSH_OBSOLETE_SERVER_VERSION_OR_CIPHER));
|
NDPI_SET_BIT(flow->risk, (is_client_signature ? NDPI_SSH_OBSOLETE_CLIENT_VERSION_OR_CIPHER : NDPI_SSH_OBSOLETE_SERVER_VERSION_OR_CIPHER));
|
||||||
}
|
}
|
||||||
||||||| f83d0b18
|
|
||||||
/*
|
|
||||||
if(obsolete_ssh_version)
|
|
||||||
NDPI_SET_BIT(flow->risk, is_client_signature ? NDPI_SSH_OBSOLETE_CLIENT_SIGNATURE : NDPI_SSH_OBSOLETE_SERVER_SIGNATURE);
|
|
||||||
*/
|
|
||||||
|
|
||||||
=======
|
|
||||||
/*
|
|
||||||
if(obsolete_ssh_version)
|
|
||||||
NDPI_SET_BIT(flow->risk, is_client_signature ? NDPI_SSH_OBSOLETE_CLIENT_SIGNATURE : NDPI_SSH_OBSOLETE_SERVER_SIGNATURE);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************ */
|
/* ************************************************************************ */
|
||||||
|
|
||||||
static void ssh_analyse_cipher(struct ndpi_detection_module_struct *ndpi_struct,
|
static void ssh_analyse_cipher(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
struct ndpi_flow_struct *flow,
|
struct ndpi_flow_struct *flow,
|
||||||
char *cipher, u_int cipher_len,
|
char *ciphers, u_int cipher_len,
|
||||||
u_int8_t is_client_signature) {
|
u_int8_t is_client_signature) {
|
||||||
/*
|
|
||||||
List of obsolete ciphers can be found at
|
|
||||||
https://www.linuxminion.com/deprecated-ssh-cryptographic-settings/
|
|
||||||
*/
|
|
||||||
#ifdef SSH_DEBUG
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
printf("[%s] ", is_client_signature ? "CLIENT" : "SERVER");
|
|
||||||
|
|
||||||
for(i=0; i<cipher_len; i++)
|
char *rem;
|
||||||
printf("%c", cipher[i]);
|
char *cipher;
|
||||||
|
int found_obsolete_cipher = 0;
|
||||||
|
|
||||||
printf("\n");
|
char *obsolete_ciphers[6] = {
|
||||||
#endif
|
"arcfour256",
|
||||||
>>>>>>> ntop_origin/dev
|
"arcfour128",
|
||||||
|
"3des-cbc",
|
||||||
|
"blowfish-cbc",
|
||||||
|
"cast128-cbc",
|
||||||
|
"arcfour",
|
||||||
|
};
|
||||||
|
|
||||||
|
char *copy = (char*)ndpi_calloc(cipher_len, sizeof(char));
|
||||||
|
|
||||||
|
if (strncpy(copy, ciphers, cipher_len) == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
cipher = strtok_r(copy, ",", &rem);
|
||||||
|
|
||||||
|
while (cipher && !found_obsolete_cipher) {
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
if (strcmp(cipher, obsolete_ciphers[i]) == 0) {
|
||||||
|
found_obsolete_cipher = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cipher = strtok_r(NULL, ",", &rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found_obsolete_cipher) {
|
||||||
|
#ifdef SSH_DEBUG
|
||||||
|
printf("[SSH] [SSH obsolete cipher]\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NDPI_SET_BIT(flow->risk, (is_client_signature ? NDPI_SSH_OBSOLETE_CLIENT_VERSION_OR_CIPHER : NDPI_SSH_OBSOLETE_SERVER_VERSION_OR_CIPHER));
|
||||||
|
}
|
||||||
|
|
||||||
|
ndpi_free(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************ */
|
/* ************************************************************************ */
|
||||||
|
|
||||||
static int search_ssh_again(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
static int search_ssh_again(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||||
|
|||||||
Reference in New Issue
Block a user