So I have been reading the ssh attack thread and finally want to ask about something. I doubt there is a program like this, but I would love to have a program that listens at common ports that I do not use at all...and only allow that program to listen to it, especially the usual ssh port (using a different one for real ssh)... That program would then, upon receiving a 'sniff' or 'user' would then add that ip to the deny hosts lists..for either a long or short time. Using this would seem like a win as you can easily grab someone before they can get somewhere one hopes. Also, by opening up a few other ports that are unusual like 8561....well, if someone sniffs that it could be a 3 day ban or a month... In other words, anyone hitting those ports that are not being used at all except by our sniff protector, would allow instant banning. So...does something like this exist?
On Sat, 20 Jun 2009 20:35:00 -0400 Bob Hoffman wrote:> So...does something like this exist?fail2ban -- MELVILLE THEATRE ~ Melville Sask ~ http://www.melvilletheatre.com
>In other words, anyone hitting those ports that are not being used at all >except by our sniff protector, would allow instant banning. > >So...does something like this exist?I don't know of a program that specifically listens to defined ports and acts on that, but fail2ban would accomplish the end result adequately. jlc
On Sat, Jun 20, 2009 at 8:35 PM, Bob Hoffman<bob at bobhoffman.com> wrote:> So I have been reading the ssh attack thread and finally want to ask about > something. > > I doubt there is a program like this, but I would love to have a program > that listens at common ports that I do not use at all...and only allow that > program to listen to it, especially the usual ssh port (using a different > one for real ssh)... > > That program would then, upon receiving a 'sniff' or 'user' would then add > that ip to the deny hosts lists..for either a long or short time. > > Using this would seem like a win as you can easily grab someone before they > can get somewhere one hopes. > Also, by opening up a few other ports that are unusual like 8561....well, if > someone sniffs that it could be a 3 day ban or a month... > > In other words, anyone hitting those ports that are not being used at all > except by our sniff protector, would allow instant banning. > > So...does something like this exist? > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos >A simple bash script run from a cronjob that looks for entries in /etc/secure for traffic to those ports and then parses out the IP and adds it to your host.deny might work. But if you are looking to set a date/time when it would expire, you could probably achieve this through a comment at the end of the entry containing the expiry date which your bash script would scan with a simple sed command looking for any lines with an expiry date matching the system's current date and removing those lines. fail2ban was also suggested by a few and I believe that was one I played with briefly a few years back and it worked but I wasn't using it in the scenario you describe but rather simply scanning for multiple failed ssh login attempts (not sure if it was looking for failed ssh login attempts, or "Failed" attempts period regardless the port being targeted) that resulted in a host.deny entry. But of course you can potentially lock yourself out (been there, done that) which is a p.i.t.a. You either have to wait until next day at the office to remove your ban, or try and get another IP from your ISP via disconnecting and reconnecting to your ISP. Jacques B.
> > That program would then, upon receiving a 'sniff' or 'user' would then add > that ip to the deny hosts lists..for either a long or short time. > > Using this would seem like a win as you can easily grab someone before they > can get somewhere one hopes. > Also, by opening up a few other ports that are unusual like 8561....well, if > someone sniffs that it could be a 3 day ban or a month... > > In other words, anyone hitting those ports that are not being used at all > except by our sniff protector, would allow instant banning. > > So...does something like this exist?fail2ban... near enough a fit...
> I doubt there is a program like this, but I would love to have a program > that listens at common ports that I do not use at all...and only allow that > program to listen to it, especially the usual ssh port (using a different > one for real ssh)... > > That program would then, upon receiving a 'sniff' or 'user' would then add > that ip to the deny hosts lists..for either a long or short time.Many years ago I used portsentry for this. You can find an article about portsentry at <http://www.securityfocus.com/infocus/1580> Barry
Bob Hoffman <bob at ...> writes:> > So I have been reading the ssh attack thread and finally want to ask about > something. > > I doubt there is a program like this, but I would love to have a program > that listens at common ports that I do not use at all...and only allow that > program to listen to it, especially the usual ssh port (using a different > one for real ssh)... > > That program would then, upon receiving a 'sniff' or 'user' would then add > that ip to the deny hosts lists..for either a long or short time. > > Using this would seem like a win as you can easily grab someone before they > can get somewhere one hopes. > Also, by opening up a few other ports that are unusual like 8561....well, if > someone sniffs that it could be a 3 day ban or a month... > > In other words, anyone hitting those ports that are not being used at all > except by our sniff protector, would allow instant banning. > > So...does something like this exist? >Just in case you want to play around with just the logging port probing information you can add something like the following rule to your firewall: -A RH-Firewall-1-INPUT -p tcp -m tcp -j LOG -A RH-Firewall-1-INPUT -p udp -m udp -j LOG Add the rules at the bottom of /etc/sysconfig/iptables but before your ultimate reject rule. Make sure you have enough room in /var/log for the amount of data you will be collecting. The log entries in /var/log/messages will look like: Jun 16 00:51:01 bend kernel: IN=eth0 OUTMAC=00:0a:5e:1a:ee:4b:00:0a:5e:1a:e9:c8:08:00 SRC=192.168.0.1 DST=192.168.0.2 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=59652 DF PROTO=TCP SPT=59356 DPT=17581 WINDOW=17920 RES=0x00 SYN URGP=0 Cheers, Dave