Stories
Slash Boxes
Comments

SoylentNews is people

posted by chromas on Monday March 25 2019, @10:24AM   Printer-friendly
from the "'Mawnin'!'-sez-Brer-Rabbit" dept.

Software engineer Chris Wellons writes about tar-pitting nefarious SSH probes. Anyone with a publicly-facing SSH server knows that it is probed from the moment it is turned on. Usually, the overwhelming majority of incoming connection attempts are malevolent in nature. There are several ways to deal with these attempts, one method is to drag out the response for as long as possible.

This program opens a socket and pretends to be an SSH server. However, it actually just ties up SSH clients with false promises indefinitely — or at least until the client eventually gives up. After cloning the repository, here’s how you can try it out for yourself (default port 2222):

[...] Your SSH client will hang there and wait for at least several days before finally giving up. Like a mammoth in the La Brea Tar Pits, it got itself stuck and can’t get itself out. As I write, my Internet-facing SSH tarpit currently has 27 clients trapped in it. A few of these have been connected for weeks. In one particular spike it had 1,378 clients trapped at once, lasting about 20 hours.


Original Submission

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 2) by FatPhil on Monday March 25 2019, @02:33PM (8 children)

    by FatPhil (863) <reversethis-{if.fdsa} {ta} {tnelyos-cp}> on Monday March 25 2019, @02:33PM (#819524) Homepage
    Indeed, he bumps the real sshd to an alternative port, so the tarpit suck connections to the default port.

    My firewall NATs 6 machines, so I just have a bank of ports 222x, one forwarded to sshd on each machine, and so this tarpit on 22 would work for me - it could be forwarded to the unimportant RasPi that doesn't run any other services. However, I use fail2ban on all the machines anyway, so I'm mostly safe from idiotic probes, this is mostly a kind of vaccination to protect others by limitting the number of attacks that can take place on the population as a whole.
    --
    Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves
    Starting Score:    1  point
    Karma-Bonus Modifier   +1  

    Total Score:   2  
  • (Score: 5, Interesting) by canopic jug on Monday March 25 2019, @02:45PM (1 child)

    by canopic jug (3949) Subscriber Badge on Monday March 25 2019, @02:45PM (#819534) Journal

    If you use fail2ban or sshguard, you could maybe use the triggered firewall rule to route the bot to an interal port running the tar pit. Normal connections would pass through to the SSH daemon, as expected, but offending IP addresses would get routed internally to somewhere else.

    --
    Money is not free speech. Elections should not be auctions.
    • (Score: 2) by DannyB on Monday March 25 2019, @03:17PM

      by DannyB (5839) Subscriber Badge on Monday March 25 2019, @03:17PM (#819555) Journal

      I like that approach.

      --
      The lower I set my standards the more accomplishments I have.
  • (Score: 3, Insightful) by DannyB on Monday March 25 2019, @03:17PM (3 children)

    by DannyB (5839) Subscriber Badge on Monday March 25 2019, @03:17PM (#819554) Journal

    Sorry I wrote SSL when I meant SSH.

    For SSH, I have one forwarded to a non standard port in the 3xxx range. I could forward more as you describe.

    I suppose then the standard SSH port could run the tarpit.

    But it would be really cool to be able to mix the tarpit with a real SSH implementation if that were possible to allow a real login to proceed.

    Or another approach: something like fail2ban could redirect certain 'ssh visitors' to the tarpit once it is clear that they are nothing but a brute force attack.

    --
    The lower I set my standards the more accomplishments I have.
    • (Score: 2) by FatPhil on Monday March 25 2019, @03:42PM (2 children)

      by FatPhil (863) <reversethis-{if.fdsa} {ta} {tnelyos-cp}> on Monday March 25 2019, @03:42PM (#819580) Homepage
      The combination of fail2ban banning by tarpitting is indeed an interesting solution.
      I did plan to write a lightweight fail2ban replacement at some point (installed size half a meg? for something that just calls notify/poll and matches a few regexps and optionally calls some scripts, that sounds like bloat to me), I'll remember to consider that kind of option when I do.
      --
      Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves
      • (Score: 2) by canopic jug on Monday March 25 2019, @03:50PM (1 child)

        by canopic jug (3949) Subscriber Badge on Monday March 25 2019, @03:50PM (#819585) Journal

        If your needs are not complex, then the replacement can be quite short. I have one which is less than 10 lines of AWK. Though it depends on probes making specific errors, it seems to get nearly all of them quickly. I should connect it to a tar pit maybe but would want to re-write the tar pit in perl so that I don't have to add python to the mix. It looks simple enough to try.

        --
        Money is not free speech. Elections should not be auctions.
        • (Score: 2) by RS3 on Monday March 25 2019, @06:22PM

          by RS3 (6367) on Monday March 25 2019, @06:22PM (#819668)

          Some years ago I had tried fail2ban and either had trouble getting it to work or just considered it too complicated. Too many years to remember.

          Have any of you tried "pam shield"?

  • (Score: 3, Informative) by NateMich on Monday March 25 2019, @06:00PM (1 child)

    by NateMich (6662) on Monday March 25 2019, @06:00PM (#819653)

    so I just have a bank of ports 222x

    Stop using port numbers with "22" in them. Those are targeting by scans almost as much as the actual ssh port, 22 is. Trust me. Be random.

    • (Score: 3, Informative) by maxwell demon on Monday March 25 2019, @07:37PM

      by maxwell demon (1608) on Monday March 25 2019, @07:37PM (#819705) Journal

      So if you've got a reason to have a real sshd on port 22, it might be a good idea to tarpit all the other ports with "22" in their number?

      --
      The Tao of math: The numbers you can count are not the real numbers.