From 9719c17d19c97e7a9c86db6dbec4411deb0d17d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 10 Jul 2023 16:13:10 +0800 Subject: [PATCH] LM (Linux): detect sshd version --- src/detection/lm/lm_linux.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/detection/lm/lm_linux.c b/src/detection/lm/lm_linux.c index 0ce9cd8b0..93137bcd6 100644 --- a/src/detection/lm/lm_linux.c +++ b/src/detection/lm/lm_linux.c @@ -24,6 +24,23 @@ static const char* getGdmVersion(FFstrbuf* version) return NULL; } +static const char* getSshdVersion(FFstrbuf* version) +{ + const char* error = ffProcessAppendStdErr(version, (char* const[]) { + "sshd", + "-qv", + NULL + }); + if (error) + return error; + + // unknown option -- v + // OpenSSH_9.0p1, OpenSSL 3.0.9 30 May 2023... + ffStrbufSubstrBeforeFirstC(version, ','); + ffStrbufSubstrAfterFirstC(version, '_'); + return NULL; +} + #ifdef FF_HAVE_ZLIB #include "common/library.h" #include @@ -147,6 +164,8 @@ const char* ffDetectLM(FFLMResult* result) getXfwmVersion(&result->version); else if (ffStrbufStartsWithS(&result->service, "lightdm")) getLightdmVersion(&result->version); + else if (ffStrbufStartsWithS(&result->service, "sshd")) + getSshdVersion(&result->version); // Correct char cases if (ffStrbufIgnCaseEqualS(&result->type, FF_WM_PROTOCOL_WAYLAND))