Re: SSH bruteforce on its way...

foxxz.net_at_gmail.com
Date: 10/19/05

  • Next message: Christoph Gruber: "Re: Strange attack question - seems udp"
    Date: 19 Oct 2005 20:47:39 -0000
    To: incidents@securityfocus.com
    
    
    ('binary' encoding is not supported, stored as-is) Heres a perl script I made to help solve my problem. I have been seeing these the past 2 years at least. This works on debian sarge (ssh 3.8). Can easily be changed for other ssh versions. Run like this...

    tail -n0 -F /var/log/auth.log |logflow.pl |awk -W interactive '{ print "sshd: "$1 }' >> /etc/hosts.deny 2>&1 &

    and here is the logflow.pl...

    #!/usr/bin/perl

    use Regexp::Common qw /net/;

    # ips that shouldn't be banned
    @safe = ('192.168.51.1','1.2.3.4');

    # number of illegal users received in 1 minute that will trigger a ban
    $thresh = 4;

    while (<STDIN>) {
     if ($_ !~ /Illegal user/) { next; }
     @line = split(' ', $_);
     @hourmin = split(':', @line[2]);
     if ("@line[0] @line[1] @hourmin[0] @hourmin[1] @line[9]" eq $remember && grep(/^@line[9]$/, @bans) eq 0 && @line[9] =~ /^$RE{net}{IPv4}$/) {
      $found++;
      if ($found eq ($thresh - 1)) {
       print "@line[9]\n";
       $| = 1;
       push(@bans, @line[9]);
      }
     } else {
      $found=0;
     }
     $remember = "@line[0] @line[1] @hourmin[0] @hourmin[1] @line[9]";
    }


  • Next message: Christoph Gruber: "Re: Strange attack question - seems udp"

    Relevant Pages

    • Re: Zeichensatzumwandlung innerhalb eines Triggers?
      ... inwieweit ein Trigger dabei helfen ... Stellen das Encoding uminterpretieren kann. ... Du kannst die angehaengte Encoding-Information mit CONVERT() aendern. ... CONVERTtaggt das Ergebnis jedesmal als latin1, aber nur ohne BINARY ...
      (de.comp.datenbanken.mysql)
    • denyhosts.py
      ... Has anyone else set up the python script, ... I installed it last night and it trapped two ips to ... ban. ... I've got enough ip's from Asia on shorewall's ...
      (SSH)
    • banning foreign Internet Providers
      ... In an effort to curtail the current spam attacks I was wondering if I ... could ban all IPs and only allow those in a 200 mile radis. ...
      (alt.os.linux)
    • BAN IP (second try)
      ... Say I want to ban all IPs in the range 123.123 X X from access to some areas ... on my server. ... I don't want to mess up with .htaccess files ...
      (comp.lang.php)