diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2014-09-20 18:10:29 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2014-09-20 22:03:55 +0200 |
commit | 2b74a188332f152e8952725812e086968a41e925 (patch) | |
tree | e895a69b6e04d70bbb98f6b6ad6446837bdc1891 /plugins/ssh.c | |
parent | b9571ec01ff2a23475ca1a8a6b9910f49206b4ff (diff) | |
download | ponymap-2b74a188332f152e8952725812e086968a41e925.tar.gz ponymap-2b74a188332f152e8952725812e086968a41e925.tar.xz ponymap-2b74a188332f152e8952725812e086968a41e925.zip |
Implement more of the services
- SSH: ready for action
- IRC: ready for action
- HTTP: needs some work
Diffstat (limited to 'plugins/ssh.c')
-rw-r--r-- | plugins/ssh.c | 13 |
1 files changed, 9 insertions, 4 deletions
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); } |