{"id":308,"date":"2022-01-15T12:37:34","date_gmt":"2022-01-15T10:37:34","guid":{"rendered":"https:\/\/greenhouse.cv.ua\/?p=308"},"modified":"2022-01-15T12:37:34","modified_gmt":"2022-01-15T10:37:34","slug":"ssh-honeypot","status":"publish","type":"post","link":"https:\/\/greenhouse.cv.ua\/?p=308","title":{"rendered":"SSH Honeypot"},"content":{"rendered":"\n<p>Endlessh is an SSH tarpit&nbsp;<a href=\"https:\/\/nullprogram.com\/blog\/2019\/03\/22\/\">that&nbsp;<em>very<\/em>&nbsp;slowly sends an endless, random SSH banner<\/a>. 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.<\/p>\n\n\n\n<p>Since the tarpit is in the banner before any cryptographic exchange occurs, this program doesn&#8217;t depend on any cryptographic libraries. It&#8217;s a simple, single-threaded, standalone C program. It uses&nbsp;<code>poll()<\/code>&nbsp;to trap multiple clients at a time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/skeeto\/endlessh#usage\"><\/a>Usage<\/h2>\n\n\n\n<p>Usage information is printed with&nbsp;<code>-h<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Usage: endlessh &#91;-vhs] &#91;-d MS] &#91;-f CONFIG] &#91;-l LEN] &#91;-m LIMIT] &#91;-p PORT]\n  -4        Bind to IPv4 only\n  -6        Bind to IPv6 only\n  -d INT    Message millisecond delay &#91;10000]\n  -f        Set and load config file &#91;\/etc\/endlessh\/config]\n  -h        Print this help message and exit\n  -l INT    Maximum banner line length (3-255) &#91;32]\n  -m INT    Maximum number of clients &#91;4096]\n  -p INT    Listening port &#91;2222]\n  -s        Print diagnostics to syslog instead of standard output\n  -v        Print diagnostics (repeatable)\n<\/code><\/pre>\n\n\n\n<p>Argument order matters. The configuration file is loaded when the&nbsp;<code>-f<\/code>&nbsp;argument is processed, so only the options that follow will override the configuration file.<\/p>\n\n\n\n<p>By default no log messages are produced. The first&nbsp;<code>-v<\/code>&nbsp;enables basic logging and a second&nbsp;<code>-v<\/code>&nbsp;enables debugging logging (noisy). All log messages are sent to standard output by default.&nbsp;<code>-s<\/code>&nbsp;causes them to be sent to syslog.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>endlessh -v &gt;endlessh.log 2&gt;endlessh.err\n<\/code><\/pre>\n\n\n\n<p>A SIGTERM signal will gracefully shut down the daemon, allowing it to write a complete, consistent log.<\/p>\n\n\n\n<p>A SIGHUP signal requests a reload of the configuration file (<code>-f<\/code>).<\/p>\n\n\n\n<p>A SIGUSR1 signal will print connections stats to the log.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/skeeto\/endlessh#sample-configuration-file\"><\/a>Sample Configuration File<\/h2>\n\n\n\n<p>The configuration file has similar syntax to OpenSSH.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># The port on which to listen for new SSH connections.\nPort 2222\n\n# The endless banner is sent one line at a time. This is the delay\n# in milliseconds between individual lines.\nDelay 10000\n\n# The length of each line is randomized. This controls the maximum\n# length of each line. Shorter lines may keep clients on for longer if\n# they give up after a certain number of bytes.\nMaxLineLength 32\n\n# Maximum number of connections to accept at a time. Connections beyond\n# this are not immediately rejected, but will wait in the queue.\nMaxClients 4096\n\n# Set the detail level for the log.\n#   0 = Quiet\n#   1 = Standard, useful log messages\n#   2 = Very noisy debugging information\nLogLevel 0\n\n# Set the family of the listening socket\n#   0 = Use IPv4 Mapped IPv6 (Both v4 and v6, default)\n#   4 = Use IPv4 only\n#   6 = Use IPv6 only\nBindFamily 0\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/skeeto\/endlessh#build-issues\"><\/a>Build issues<\/h2>\n\n\n\n<p>Some more esoteric systems require extra configuration when building.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/skeeto\/endlessh#rhel-6--centos-6\"><\/a>RHEL 6 \/ CentOS 6<\/h3>\n\n\n\n<p>This system uses a version of glibc older than 2.17 (December 2012), and&nbsp;<code>clock_gettime(2)<\/code>&nbsp;is still in librt. For these systems you will need to link against librt:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>make LDLIBS=-lrt\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/skeeto\/endlessh#solaris--illumos\"><\/a>Solaris \/ illumos<\/h3>\n\n\n\n<p>These systems don&#8217;t include all the necessary functionality in libc and the linker requires some extra libraries:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>make CC=gcc LDLIBS='-lnsl -lrt -lsocket'\n<\/code><\/pre>\n\n\n\n<p>If you&#8217;re not using GCC or Clang, also override&nbsp;<code>CFLAGS<\/code>&nbsp;and&nbsp;<code>LDFLAGS<\/code>&nbsp;to remove GCC-specific options. For example, on Solaris:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>make CFLAGS=-fast LDFLAGS= LDLIBS='-lnsl -lrt -lsocket'\n<\/code><\/pre>\n\n\n\n<p>The feature test macros on these systems isn&#8217;t reliable, so you may also need to use&nbsp;<code>-D__EXTENSIONS__<\/code>&nbsp;in&nbsp;<code>CFLAGS<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/skeeto\/endlessh#openbsd\"><\/a>OpenBSD<\/h3>\n\n\n\n<p>The man page needs to go into a different path for OpenBSD&#8217;s&nbsp;<code>man<\/code>&nbsp;command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>diff --git a\/Makefile b\/Makefile\nindex 119347a..dedf69d 100644\n--- a\/Makefile\n+++ b\/Makefile\n@@ -14,8 +14,8 @@ endlessh: endlessh.c\n install: endlessh\n        install -d $(DESTDIR)$(PREFIX)\/bin\n        install -m 755 endlessh $(DESTDIR)$(PREFIX)\/bin\/\n-       install -d $(DESTDIR)$(PREFIX)\/share\/man\/man1\n-       install -m 644 endlessh.1 $(DESTDIR)$(PREFIX)\/share\/man\/man1\/\n+       install -d $(DESTDIR)$(PREFIX)\/man\/man1\n+       install -m 644 endlessh.1 $(DESTDIR)$(PREFIX)\/man\/man1\/\n\n clean:\n        rm -rf endlessh\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"SSH Honeypot in 4 Minutes - Trap Hackers in Your Server\" width=\"750\" height=\"422\" src=\"https:\/\/www.youtube.com\/embed\/SKhKNUo6rJU?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Links:<br><a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/skeeto\/endlessh.git\" target=\"_blank\">GitHub<\/a>;<\/p>\n\n\n\n<div class=\"wp-block-file\"><a href=\"https:\/\/greenhouse.cv.ua\/wp-content\/uploads\/2022\/01\/endlessh-1.0.zip\">endlessh-1.0<\/a><a href=\"https:\/\/greenhouse.cv.ua\/wp-content\/uploads\/2022\/01\/endlessh-1.0.zip\" class=\"wp-block-file__button\" download>\u0417\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0438\u0442\u0438<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Endlessh is an SSH tarpit&nbsp;that&nbsp;very&nbsp;slowly sends an endless, random SSH banner. It keeps SSH clients locked up for hours or even days at a time. . . .<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[7],"tags":[],"class_list":["post-308","post","type-post","status-publish","format-standard","hentry","category-linux"],"aioseo_notices":[],"featured_image_src":null,"author_info":{"display_name":"Bernyk Dmytro","author_link":"https:\/\/greenhouse.cv.ua\/?author=2"},"_links":{"self":[{"href":"https:\/\/greenhouse.cv.ua\/index.php?rest_route=\/wp\/v2\/posts\/308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/greenhouse.cv.ua\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/greenhouse.cv.ua\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/greenhouse.cv.ua\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/greenhouse.cv.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=308"}],"version-history":[{"count":3,"href":"https:\/\/greenhouse.cv.ua\/index.php?rest_route=\/wp\/v2\/posts\/308\/revisions"}],"predecessor-version":[{"id":312,"href":"https:\/\/greenhouse.cv.ua\/index.php?rest_route=\/wp\/v2\/posts\/308\/revisions\/312"}],"wp:attachment":[{"href":"https:\/\/greenhouse.cv.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/greenhouse.cv.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/greenhouse.cv.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}