-

 LiveInternet.ru:
: 15.10.2005
: 679
: 2837
: 4929

:


, DDoS...

, 10 2011 . 18:27 +
DDoS. -, nginx, .

, - -, nginx, , . , apache, , . ? , , , ? Click here, motherfucker... => http://ha.ckers.org/slowloris/. , - , IIS. , production- windows - , .

nginx intel Atom , , , , , , cisco asa 5580 + checkpoint firewall + load balancer + IIS. , , :

log_format mainext
'$remote_addr [$http_x_real_ip] - $remote_user($cookie_auth) [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" ua:"$http_user_agent" '
'gz:"$gzip_ratio" ae:"$http_accept_encoding" c:("$http_cookie") rb:("$request_body") ($request_time)';

, , , . - , , , . DDoS . , , - .

, nginx , , , perl , , , , www.you-tube.com POST // Chrome , gzip ($http_accept_encoding), - . , - ip firewall. - iptables.

, iptables, , , , - . iptables - , :)

, perl - , , , , - .

, insight:

my %iplist;

sub blackList {
my $bot = shift;
if (!defined($iplist{$bot})) {
system(iptables -A INPUT -s $bot/32 -j DROP);
$iplist{$bot}++;
}
}

while(my $logLine = ) {
my ($ip) = ($logLine =~ /^(\d+\.\d+\.\d+\.\d+)/);
if (defined($ip)) {
my ($ae) = ($logLine =~ /ae:([^)]+)/);
my ($ua) = ($logLine =~ /ua:([^)]+)/);
if ($ua =~ /chrome|firefox/i && $ae eq -) {
blackList($ip); # chrome/ff without compression
}
}
}

- BerkeleyDB %iplist, . , , , DDoS.

, , twisted python, , . - :

from __future__ import nested_scopes
import twisted.internet.reactor, os, stat, sys

def checkIfBot(logLine):
pass

def file_identity(struct_stat):
return struct_stat[stat.ST_DEV], struct_stat[stat.ST_INO]

def followtail(filename, callback, freq=1, fileobj=None, fstat=None):
if fileobj is None:
fileobj = open(filename)
fileobj.seek(0, 2)
callback(fileobj.read())
if fstat is None: fstat = os.fstat(fileobj.fileno())
try: stat = os.stat(filename)
except: stat = fstat
if file_identity(stat) != file_identity(fstat):
fileobj = open(filename)
fstat = os.fstat(fileobj.fileno())

twisted.internet.reactor.callLater(freq, lambda:
followtail(filename, callback, freq,
fileobj, fstat))

if __name__ == '__main__':
followtail(sys.argv[1], checkIfBot)
twisted.internet.reactor.run()

, . linux, , , , ~7000, . - Cisco , , - shun ip. - iptables, cisco , . quick and dirty solution, DDoS, :

shun.pl:
#!/usr/bin/perl -w
use strict;
use Net::SSH::Perl;

my $ssh = Net::SSH::Perl->new("ciscoHost", debug=>0);
$ssh->login("ciscoUser", "ciscoPassword");
$ssh->shell;

shell, - , . .... , iplist, :

(echo login; echo ciscoUser; echo ciscoPassword; tail -n `iptables-save | wc -l ` iplist | sed 's/^/shun /'; sleep 60) | ./shun.pl
iptables -F

filter , .

, , Cisco - firewall, reduce - , , 20-30%. , : whois ip | grep inetnum, . iptables ipcalc, - :

# whois 31.3.244.146 | grep inetnum
inetnum: 31.3.244.144 - 31.3.244.151

# ipcalc 31.3.244.144 - 31.3.244.151
deaggregate 31.3.244.144 - 31.3.244.151
31.3.244.144/29

, , - , cisco:)

, , , , , DDoS . , , -. - , cookie. nginx :
server {
default_type text/html;
listen yourserver:80;
location = / {
add_header Set-Cookie "thatsfine=yes$remote_addr";
rewrite ^/(.*) http://yourserver/login;
}
location = /login {
if ($cookie_thatsfine != "yes$remote_addr") {
return 503;
}
root /webroot/login;
index login.html;
}
}

login.html , cookie , . , .

, DDoS, , , , icmp udp flood. - , , , udp DNS . , - . Dont forget to disable name resolution in your ssh config:)

- . , , DDoS - . :
- select sum(whatever) from - !
, - , , - ;
mysql , , - , , , SQL, , memcached, mysql;
, - memcached - ;
mysql - , redis, - ;
php, php-fpm + eaccelerator - ;
hiphop php - , php, ;
frameworks php - , ;
, HTML- php, json javascript - ;
- - - , , nginx , , php-fpm.

- ! web, , , - -.

: [1] []
eugene20237   , 10 2011 . 19:26 ()
!
   
eugene20237   , 11 2011 . 21:04 ()
,
   
_   , 11 2011 . 22:39 ()
d0rc, ... ...
   
d0rc   , 12 2011 . 17:54 ()
eugene20237, :) , ddos , ...
   
d0rc   , 12 2011 . 17:54 ()
_, , ....
   
eugene20237   , 12 2011 . 20:38 ()
, , . , , . , 100 , .
P.S.: - .
   
SARGANC   , 30 2011 . 09:44 ()
!
   
eugene20237   , 30 2011 . 15:46 ()
, !!! scifi !
   
_   ! , 30 2011 . 16:28 ()
,
,
,
, , !

, ,

!
75489895_72487462_dr (640x527, 336Kb)
   
Katrina_Op   ! , 31 2011 . 21:14 ()

Photo 023 (240x320, 60Kb)
   
   , 02 2011 . 18:39 ()


, !


- , ? , ! !



!


!

   
   , 25 2012 . 13:40 ()
        |    
: [1] []
 

:
: 

: ( )

:

  URL