From patchwork Mon Mar 1 15:24:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joshua Branson X-Patchwork-Id: 27393 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 974C227BC50; Mon, 1 Mar 2021 15:30:35 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 5670C27BC4F for ; Mon, 1 Mar 2021 15:30:34 +0000 (GMT) Received: from localhost ([::1]:44394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGkVF-0000x4-ER for patchwork@mira.cbaines.net; Mon, 01 Mar 2021 10:30:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGkUl-0000K4-5l for guix-patches@gnu.org; Mon, 01 Mar 2021 10:30:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:38889) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lGkUk-00018y-SA for guix-patches@gnu.org; Mon, 01 Mar 2021 10:30:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lGkUk-0004xY-LI for guix-patches@gnu.org; Mon, 01 Mar 2021 10:30:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#46851] [PATCH] services: Add endlessh service. Resent-From: Joshua Branson Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 01 Mar 2021 15:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46851 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 46851@debbugs.gnu.org Cc: Joshua Branson X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.161461255418981 (code B ref -1); Mon, 01 Mar 2021 15:30:02 +0000 Received: (at submit) by debbugs.gnu.org; 1 Mar 2021 15:29:14 +0000 Received: from localhost ([127.0.0.1]:50435 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lGkTr-0004vy-Gw for submit@debbugs.gnu.org; Mon, 01 Mar 2021 10:29:14 -0500 Received: from lists.gnu.org ([209.51.188.17]:39380) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lGkTp-0004vq-GX for submit@debbugs.gnu.org; Mon, 01 Mar 2021 10:29:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGkTp-0006dB-7B for guix-patches@gnu.org; Mon, 01 Mar 2021 10:29:05 -0500 Received: from mx1.dismail.de ([78.46.223.134]:20104) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGkTm-0000Xv-5U for guix-patches@gnu.org; Mon, 01 Mar 2021 10:29:04 -0500 Received: from mx1.dismail.de (localhost [127.0.0.1]) by mx1.dismail.de (OpenSMTPD) with ESMTP id 821b4ca4 for ; Mon, 1 Mar 2021 16:28:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=dismail.de; h=from:to:cc :subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=20190914; bh=znFh+M9PiWAGK2iug+jXy Ot2fg99vU7Qbs899UiSx/I=; b=sgPZCIJLcrmjaSHHeV7sVd34GTlNBcm8ksDSv muQ9cInafcsRD5AofMiyByxhEC8l0UQASSEZFiROfI667nc617jm3flAEqyfsARk bWaQojeX/1yLbZLECm5QqTeXksYrOjuap3pJyyWObsEu5SlDcKBHTPpY9kdB6qlo cW/shPSP294mnZKwxu7KuWB0x5D3Yoet5dY3nWj4rzMK0GhLVHy7nNqLULwF8/Nl Li5lUYBhoIHxJCnS/Wsu0e5mPjN+RIzizp9lMAc295rGLsQTOc/7DnDRxj/HSMrc bD1qAUeDjYxzLfeDJtM+tQcivY94Fe1N9Jv+o17pWXY4MKX5w== Received: from smtp2.dismail.de ( [10.240.26.12]) by mx1.dismail.de (OpenSMTPD) with ESMTP id 7bda1bda for ; Mon, 1 Mar 2021 16:28:57 +0100 (CET) Received: from smtp2.dismail.de (localhost [127.0.0.1]) by smtp2.dismail.de (OpenSMTPD) with ESMTP id f43f82ab for ; Mon, 1 Mar 2021 16:28:57 +0100 (CET) Received: by dismail.de (OpenSMTPD) with ESMTPSA id 6e78767f (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Mon, 1 Mar 2021 16:28:55 +0100 (CET) Date: Mon, 1 Mar 2021 10:24:53 -0500 Message-Id: <20210301152453.14678-1-jbranso@dismail.de> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Received-SPF: pass client-ip=78.46.223.134; envelope-from=jbranso@dismail.de; helo=mx1.dismail.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Joshua Branson X-ACL-Warn: , Joshua Branson via Guix-patches X-Patchwork-Original-From: Joshua Branson via Guix-patches via From: Joshua Branson X-getmail-retrieved-from-mailbox: Patches * gnu/services/ssh.scm: Add endlessh service (): New record type. (%default-endlessh): New variable. (endlessh-shepherd-service, endlessh-service-type): New procedures. doc: doc/guix.texi (Networking Services): New endlessh-service-type section. --- doc/guix.texi | 24 ++++++++++++ gnu/services/ssh.scm | 90 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 113 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 27083f1ae6..bd6dbe5944 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -17081,6 +17081,30 @@ may cause undefined behaviour. @end table @end deftp +@cindex Endlessh +@deffn {Scheme Variable} endlessh-service-type +This is the type for the @uref{https://github.com/skeeto/endlessh, +Endlessh} program that delays ssh clients for days at a time by +@emph{very slowly} sending a random and endless SSH banner. The smart +hacker will put endlessh running on port 22, and let crackers get stuck +in this tarpit. This lets your real ssh server run more securely on a +non-standard port. + +@end deffn + +@deftp {Data Type} endlessh-configuration +Data type representing the configuration for @code{endlessh-service}. +@table @asis +@item @code{package} (default: @var{endlessh}) +@code{endlessh} package to use. + +@item @code{config-file} (default: @var{"%default-endlessh-config-file"}) +The config file that endlessh should use. + +@end table +@end deftp + + @cindex WebSSH @deffn {Scheme Variable} webssh-service-type This is the type for the @uref{https://webssh.huashengdun.org/, WebSSH} diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm index 1891db0487..3f77627ae3 100644 --- a/gnu/services/ssh.scm +++ b/gnu/services/ssh.scm @@ -1,11 +1,12 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès +;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2021 Ludovic Courtès ;;; Copyright © 2016 David Craven ;;; Copyright © 2016 Julien Lepiller ;;; Copyright © 2017 Clément Lassieur ;;; Copyright © 2019 Ricardo Wurmus ;;; Copyright © 2020 pinoaffe ;;; Copyright © 2020 Oleg Pykhalov +;;; Copyright © 2021 Joshua Branson ;;; ;;; This file is part of GNU Guix. ;;; @@ -54,6 +55,11 @@ autossh-configuration? autossh-service-type + endlessh-configuration + endlessh-configuration? + endlessh-service-type + %default-endlessh + webssh-configuration webssh-configuration? webssh-service-type @@ -739,6 +745,88 @@ object." autossh-service-activation))) (default-value (autossh-configuration)))) + +;;; +;;; Endlessh +;;; + +(define-record-type* + endlessh-configuration make-endlessh-configuration + endlessh-configuration? + (package endlessh-configuration-package + (default endlessh)) + (config-file endlessh-configuration-config-file + (default %default-endlessh-config-file))) + +(define %default-endlessh-config-file + (plain-file "endlessh.conf" + "# The port on which to listen for new SSH connections. +Port 22 + +# The endless banner is sent one line at a time. This is the delay +# in milliseconds between individual lines. +Delay 10000 + +# The length of each line is randomized. This controls the maximum +# length of each line. Shorter lines may keep clients on for longer if +# they give up after a certain number of bytes. +MaxLineLength 32 + +# Maximum number of connections to accept at a time. Connections beyond +# this are not immediately rejected, but will wait in the queue. +MaxClients 4096 + +# Set the detail level for the log. +# 0 = Quiet +# 1 = Standard, useful log messages +# 2 = Very noisy debugging information +LogLevel 0 + +# Set the family of the listening socket +# 0 = Use IPv4 Mapped IPv6 (Both v4 and v6, default) +# 4 = Use IPv4 only +# 6 = Use IPv6 only +BindFamily 0")) + +(define endlessh-shepherd-service + (match-lambda + (($ package config-file) + (with-imported-modules (source-module-closure + '((gnu build shepherd) + ;; TODO add optional logging + ;;(gnu system file-systems) + )) + (list (shepherd-service + (documentation "Run the endlessh daemon.") + (provision '(endlessh)) + (requirement '(networking)) + (modules '((gnu build shepherd) + ;; TODO add optional logging + ;;(gnu system file-systems) + )) + (start #~(make-forkexec-constructor/container + (list #$(file-append package "/bin/endlessh") + "-f" #$config-file) + ;; TODO add optional logging + ;; #:mappings (list (file-system-mapping + ;; (source "/dev/log") ;for syslog + ;; (target source))) + )) + (stop #~(make-kill-destructor)))))))) + +(define endlessh-service-type + (service-type + (name 'endlessh) + (description "Endlessh is an SSH tarpit that very slowly sends an endless, +random SSH banner. It keeps SSH clients locked up for hours or even days at a +time. The purpose is to put your real SSH server on another port and then let +the script kiddies get stuck in this tarpit instead of bothering a real +server.") + (extensions + (list (service-extension + shepherd-root-service-type endlessh-shepherd-service))) + (default-value (endlessh-configuration)))) + ;;; ;;; WebSSH