All of lore.kernel.org
 help / color / mirror / Atom feed
* SSH Brute force attacks
@ 2005-05-06 15:57 Brent Clark
  2005-05-06 16:40 ` Mogens Valentin
                   ` (4 more replies)
  0 siblings, 5 replies; 83+ messages in thread
From: Brent Clark @ 2005-05-06 15:57 UTC (permalink / raw)
  To: iptables

Hi All

One one of my hosted boxes, my logwatch scripts continuously pipe out my 
ssh and auth log of unsuccessful dictionary attacks

I came across this link : http://blog.andrew.net.au/2005/02/17/

And seen that it would help me slow (in hope) that malious person done.

Would anyone care to comment / share tips etc on what I have below

iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --set 
--name SSH
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j SSH_WHITELIST
iptables -A SSH_WHITELIST -s $MYIPADDRESS -m recent --remove --name SSH 
-j ACCEPT
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent 
--update --seconds 60 --hitcount 4 --rttl --name SSH -j LOG --log-prefix 
"SSH BRUTE"
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent 
--update --seconds 60 --hitcount 4 --rttl --name SSH -j DROP

Kind Regards
Brent Clark


^ permalink raw reply	[flat|nested] 83+ messages in thread
* SSH Brute force attacks - Script version 1.0
@ 2005-06-25 18:58 curby .
  2005-06-25 23:54 ` Marius Mertens
  0 siblings, 1 reply; 83+ messages in thread
From: curby . @ 2005-06-25 18:58 UTC (permalink / raw)
  To: netfilter

Pardon my inability to reply to the original post, but I just
subscribed.  Here is the version of the script I am considering, but
have questions about.

iptables -A INPUT -p tcp --dport 22 -s ! $My_Home_Firewall_IP -m state
--state NEW -m recent --name SSH --set --rsource -j SSH_BF
iptables -A SSH_BF -m recent ! --rcheck --seconds 60 --hitcount 3
--name SSH --rsource -j RETURN
iptables -A SSH_BF -j LOG --log-prefix "SSH Brute Force Attempt:  "
iptables -A SSH_BF -p tcp -j TARPIT



(1) First of all, why should there be a -p tcp in the TARPIT line? 
Somewhere in the original thread I think there was mention of nonTCP
packets that would get into the script and that such packets shouldn't
get dropped, but the rule that jumps to our SSH_BF script only matches
TCP packets anyway.  Looks like something's wrong if nonTCP packets
get to the chain at all.



(2) Next, people interested in implementing this sort of protection
might consider changing the duration and number of matches.  For
example, the current 60:3 settings allow a total of 180 attempts in an
hour but only in bursts of three per minute.  We can consider two
classes of people attempting to connect to the server: brute force
attackers and legitimate scripts and human users.  In the former case,
attempts per unit time as time goes to infinity is what they are
concerned about.  In the latter case, access is usually bursty. 
Consider allowing 50 matches every hour, as in

iptables -A SSH_Brute_Force -m recent ! --rcheck --seconds 3600
--hitcount 50 --name SSH --rsource -j RETURN

Now attackers have fewer than a third of the attacks per hour they can
mount on the system, but chatty backup scripts or admins are allowed
the bursty access (like opening 5 shells/scp streams at once) that
they might sometimes need or like to use.  (Whether this legitimate
but potentially disruptive behavior should be allowed is another
thing.)



(3) Also, is this the only position for the negation that makes the
rule work as intended?  It seems to say "Allow/return packets where it
isn't the case that we've seen more than or equal to three connection
attempts in the last 60 seconds."  To me, the following is more
intuitive:

iptables -A SSH_Brute_Force -m recent --rcheck --seconds 60 !
--hitcount 3 --name SSH --rsource -j RETURN

which reads "Allow/return packets from sources that have attempted
connections less than three times in the past 60 seconds."  This is
totally a subjective preference, but in the interest of learning how
the recent match really works and avoiding stupid mistakes, I want to
verify that this revised rule would have the same effect in the
context of this chain.

Thanks!


^ permalink raw reply	[flat|nested] 83+ messages in thread

end of thread, other threads:[~2005-07-26  6:18 UTC | newest]

Thread overview: 83+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-06 15:57 SSH Brute force attacks Brent Clark
2005-05-06 16:40 ` Mogens Valentin
2005-05-06 19:29 ` R. DuFresne
2005-05-07  5:14 ` Taylor, Grant
2005-05-10 14:01   ` Eric Wood
2005-05-11 12:35   ` Brent Clark
2005-05-11 18:21     ` Taylor, Grant
2005-05-11 19:04       ` Pete Toscano
2005-05-11 19:15         ` Taylor, Grant
2005-05-11 19:30           ` Pete Toscano
2005-05-11 20:34             ` Jason Opperisano
2005-05-13 21:31               ` okay, I admit confusion here; R. DuFresne
2005-05-13 21:55                 ` Jason Opperisano
2005-05-16 17:40                   ` R. DuFresne
2005-05-16 20:55                     ` Taylor, Grant
2005-05-16 21:05                 ` Taylor, Grant
2005-05-14  7:02               ` SSH Brute force attacks Georgi Alexandrov
2005-05-14 15:47                 ` Jason Opperisano
2005-05-15 20:12                 ` Patrick Nelson
2005-05-17  0:49                   ` Charlie Brady
2005-05-14  9:08       ` Łukasz Hejnak
2005-05-14 19:08         ` Taylor, Grant
2005-05-16  8:16           ` Łukasz Hejnak
2005-05-17  1:05             ` Charlie Brady
2005-05-17  5:00               ` Łukasz Hejnak
2005-05-17  5:19                 ` Łukasz Hejnak
     [not found]                   ` <42898402.10507@eccotours.dyndns.org>
2005-05-17 12:44                     ` Łukasz Hejnak
2005-05-17 13:20                       ` Brent Clark
2005-05-17 13:36                         ` Sadus .
2005-05-17 16:06                           ` Łukasz Hejnak
2005-05-17 15:21                         ` Taylor, Grant
2005-05-18 12:39                       ` Brent Clark
2005-05-19  4:55                         ` Taylor, Grant
2005-05-19  9:05                           ` Brent Clark
2005-05-19 14:39                             ` Taylor, Grant
2005-05-20 13:01                               ` Brent Clark
2005-05-20 14:53                                 ` Taylor, Grant
2005-05-23 16:31                                   ` Brent Clark
2005-06-02 16:13                                     ` Sadus .
2005-06-02 16:43                                       ` Taylor, Grant
2005-06-02 19:18                                         ` Sadus .
2005-06-13 14:39                                           ` Taylor, Grant
2005-06-13 16:17                                             ` Patrick Nelson
2005-06-13 16:27                                             ` /dev/rob0
2005-06-13 19:00                                             ` R. DuFresne
2005-05-18 16:54                       ` Jim Miller
2005-05-18 17:51                         ` Łukasz Hejnak
2005-05-19  2:09                         ` Taylor, Grant
2005-05-21  8:00                       ` Пётр Волков Александрович
2005-05-21 22:37                         ` Taylor, Grant
2005-05-22  7:11                           ` Пётр Волков Александрович
2005-05-22 10:09                           ` Marius Mertens
2005-05-22 10:57                             ` Łukasz Hejnak
2005-05-23 16:14                               ` Taylor, Grant
2005-05-17  6:55               ` Taylor, Grant
     [not found]                 ` <1116333615.24331.4.camel@debianbox>
2005-05-17 15:25                   ` Taylor, Grant
2005-05-23 16:53               ` Taylor, Grant
2005-05-24 16:19                 ` Marius Mertens
2005-05-25  5:35                 ` Brent Clark
2005-05-25  8:48                   ` Marius Mertens
2005-05-25 18:10                   ` Taylor, Grant
2005-05-26 11:17                     ` Brent Clark
2005-05-31  4:12                       ` Taylor, Grant
2005-05-31 10:06                         ` Brent Clark
2005-05-31 14:17                           ` Taylor, Grant
2005-05-28 23:24                 ` Sebastian Siewior
2005-05-29  1:01                   ` Taylor, Grant
2005-05-07  5:32 ` Taylor, Grant
2005-05-08 15:20   ` Alistair Tonner
2005-05-08 18:51     ` Dwayne Hottinger
2005-05-08 22:57       ` Alexander Samad
2005-05-09  5:41         ` Taylor, Grant
2005-05-09  5:46     ` Taylor, Grant
2005-06-02 18:26 ` SSH Brute force attacks - Script version 1.0 Taylor, Grant
2005-07-25 19:41   ` Steven M Campbell
2005-07-26  6:18     ` Jan Engelhardt
  -- strict thread matches above, loose matches on Subject: below --
2005-06-25 18:58 curby .
2005-06-25 23:54 ` Marius Mertens
2005-06-26 20:46   ` Jan Engelhardt
2005-06-27  8:18     ` Marius Mertens
2005-06-27 15:53       ` curby .
2005-06-27 16:09         ` Stephen Frost
2005-06-27  6:24   ` curby .

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.