From 2b74a188332f152e8952725812e086968a41e925 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C5=99emysl=20Janouch?=
Date: Sat, 20 Sep 2014 18:10:29 +0200
Subject: Implement more of the services
- SSH: ready for action
- IRC: ready for action
- HTTP: needs some work
---
plugins/ssh.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
(limited to 'plugins/ssh.c')
diff --git a/plugins/ssh.c b/plugins/ssh.c
index 3a32223..cf18c3c 100644
--- a/plugins/ssh.c
+++ b/plugins/ssh.c
@@ -56,20 +56,25 @@ scan_free (void *handle)
static void
on_data (void *handle, struct unit *u, struct str *data)
{
- // TODO: don't let the input buffer grow too much
+ // See RFC 4253 -- we check for a valid SSH banner
struct scan_data *scan = handle;
- str_append_str (&scan->input, data);
+ if (scan->input.len + data->len > 255)
+ goto end_scan;
+ str_append_str (&scan->input, data);
char *input = scan->input.str;
char *nl = strstr (input, "\r\n");
if (!nl)
return;
- // TODO: parse the reply, make sure that it's actually SSH,
- // don't put just any garbage in the output info
+ if (strncmp (input, "SSH-", 4))
+ goto end_scan;
+
*nl = '\0';
g_data.api->unit_add_info (u, input);
g_data.api->unit_set_success (u, true);
+
+end_scan:
g_data.api->unit_abort (u);
}
--
cgit v1.2.3