-Z, --zero [chain [rulenum]]
Zero the packet and byte counters in all chains, or only the given chain, or only the given rule in a chain. It is
legal to specify the -L, --list (list) option as well, to see the counters immediately before they are cleared. (See
above.)
-x, --exact
Expand numbers. Display the exact value of the packet and byte counters, instead of only the rounded number in K's
(multiples of 1000) M's (multiples of 1000K) or G's (multiples of 1000M). This option is only relevant for the -L
command.
1) у меня авторазбиниваются боты, от которых в течение 10 минут ни слуху ни духу — то есть отвалившиеся. куда еще автоматичнее?
2) у меня в момент пика стояло 2 минуты, а не 10, просто сейчас атака затихла, и я снизил до 10, при необходимости легко повышается.
3) универсальным решение всё равно не считается — универсальное решение должно еще уметь фильтровать последовательности, то есть по каждому ip надо вести стейтмашину, а если учесть, что некоторые боты за NATом и начинают переплетаться — то еще сложнее. а так, это не сложнее простой регулярки, которая у меня и есть.
Всё хорошо, только как я понял, это всё решается более простыми способами.
Более того, это решается вообще без софта с помощью консоли.
Я вот вот сейчас под ддос атакой. Так отбиваю:
#!/bin/bash
PATH=/sbin:/usr/sbin:$PATH
date=`date +"%Y%m%d%H%M"`
iptables -t raw -L PREROUTING -vnxZ | perl -ne 'split/ +/;print "$_[8]\n" if $_[1] ne "0";' | xargs -I {} iptables -t raw -D PREROUTING -s {} -j DROP
log_dir=/var/lib/vservers/perfccc/var/www/logs/typofront/
cd ${log_dir}
pid=`cat /var/lib/vservers/perfccc/var/run/nginx.pid`
mv ${log_dir}/typofront.access.log ${log_dir}/typofront.access.${date}.log
/usr/sbin/vkill -s USR1 ${pid}
grep "GET /experts/extrasensy/index.html HTTP" ${log_dir}/typofront.access.${date}.log | cut -d ' ' -f 1 | sort | uniq -dc | sort -nr | perl -ne 'split /\s+/; print "$_[2]\n" if ($_[1]>30);' | xargs -I {} iptables -t raw -I PREROUTING -s {} -j DROP
/bin/gzip ${log_dir}/typofront.access.${date}.log
запускается раз в 10 минут.
И никакого mongodb… и никакого ip_set… и блин, ни чихает ни кашляет. :)
Да, я прогнал в функции поворота, уже заметил, но было только 10 минут утром.
Проблема в том, что в яваскрипте отрицательный модуль — отрицательный :)
Поэтому через плюс считать надо.
Да и от бреков избавился лишних.
Правильное решение:
==========================
var cardinal_directions = ['north','east','south','west','jaw'];
var i, last=1, visible, z, m;
for(i=0; i<4; i++) if (cardinal_directions[i]==last_move) last=i;
visible=[north, east, south, west];
for(m=(last+2)%4,i=0; i<4; i++,m=(m+3)%4) {
if (visible[m]==0) result=m;
}
for(i=0; i<4; i++) if (visible[i]==3) result=i;
console.log(visible, last, result, m, i);
result = cardinal_directions[ result ];
==========================
Ну, не знаю можно ли нарисовать короче, но я решил так:
====================
var cardinal_directions = ['north','east','south','west','jaw'];
var i, last, visible, z, m;
for(i=0; i<4; i++) if (cardinal_directions[i]==last_move) last=i;
visible=[north, east, south, west, east];
coreutils-4.5.10/lib/closeout.c — а сюда не заглядывали? :)
/* Close standard output, exiting with status STATUS on failure.
If a program writes *anything* to stdout, that program should `fflush'
stdout and make sure that it succeeds before exiting. Otherwise,
suppose that you go to the extreme of checking the return status
of every function that does an explicit write to stdout. The last
printf can succeed in writing to the internal stream buffer, and yet
the fclose(stdout) could still fail (due e.g., to a disk full error)
when it tries to write out that buffered data. Thus, you would be
left with an incomplete output file and the offending program would
exit successfully.
FIXME: note the fflush suggested above is implicit in the fclose
we actually do below. Consider doing only the fflush and/or using
setvbuf to inhibit buffering.
Besides, it's wasteful to check the return value from every call
that writes to stdout -- just let the internal stream state record
the failure. That's what the ferror test is checking below.
It's important to detect such failures and exit nonzero because many
tools (most notably `make' and other build-management systems) depend
on being able to detect failure in other tools via their exit status. */
всё-таки, для алгоритмов обработки изображений очень наглядно рисовать «тепловую карту» после предварительной обработки, чтобы визуально было видно о чем идёт речь
От syn флуда не спасае.
-Z, --zero [chain [rulenum]] Zero the packet and byte counters in all chains, or only the given chain, or only the given rule in a chain. It is legal to specify the -L, --list (list) option as well, to see the counters immediately before they are cleared. (See above.) -x, --exact Expand numbers. Display the exact value of the packet and byte counters, instead of only the rounded number in K's (multiples of 1000) M's (multiples of 1000K) or G's (multiples of 1000M). This option is only relevant for the -L command.2) у меня в момент пика стояло 2 минуты, а не 10, просто сейчас атака затихла, и я снизил до 10, при необходимости легко повышается.
3) универсальным решение всё равно не считается — универсальное решение должно еще уметь фильтровать последовательности, то есть по каждому ip надо вести стейтмашину, а если учесть, что некоторые боты за NATом и начинают переплетаться — то еще сложнее. а так, это не сложнее простой регулярки, которая у меня и есть.
# !! Don't forget to add restart of log2ban.py on log rotation !!
#
ECHO_LOG_COMMAND = "tail -f /var/log/nginx/access.log" # shell command
советую просто воспользоваться tail -F
Более того, это решается вообще без софта с помощью консоли.
Я вот вот сейчас под ддос атакой. Так отбиваю:
запускается раз в 10 минут.
И никакого mongodb… и никакого ip_set… и блин, ни чихает ни кашляет. :)
только DROP'ы надо не в "-t filter -A INPUT" пихать а в "-t raw -A PREROUTING"
А главное — какой патент тема так и не раскрыта :) ни там ни тут
Проблема в том, что в яваскрипте отрицательный модуль — отрицательный :)
Поэтому через плюс считать надо.
Да и от бреков избавился лишних.
Правильное решение:
==========================
var cardinal_directions = ['north','east','south','west','jaw'];
var i, last=1, visible, z, m;
for(i=0; i<4; i++) if (cardinal_directions[i]==last_move) last=i;
visible=[north, east, south, west];
for(m=(last+2)%4,i=0; i<4; i++,m=(m+3)%4) {
if (visible[m]==0) result=m;
}
for(i=0; i<4; i++) if (visible[i]==3) result=i;
console.log(visible, last, result, m, i);
result = cardinal_directions[ result ];
==========================
Uncaught exception: TypeError: Second argument to 'instanceof' does not implement [[HasInstance]]
Error thrown at line 142, column 8 in <anonymous function: FiveGUI.GUISlider.prototype.initializePathPoints>() in fivegui.elhsmart.net.ru/js/FiveGUI/src/GUISlider.js:
if(img instanceof Image && img.complete)
called from line 191, column 4 in <anonymous function: FiveGUI.GUISlider.prototype.initialize>(parent) in fivegui.elhsmart.net.ru/js/FiveGUI/src/GUISlider.js:
this.initializePathPoints();
called from line 139, column 8 in <anonymous function: FiveGUI.GUIRegion.prototype.bindSubElements>(defaults) in fivegui.elhsmart.net.ru/js/FiveGUI/src/GUIRegion.js:
this.elements[b].initialize(this);
called from line 356, column 8 in <anonymous function: FiveGUI.GUI.prototype.addElement>(element) in fivegui.elhsmart.net.ru/js/FiveGUI/src/GUI.js:
element.bindSubElements(this.defaults);
called from line 725, column 12 in fivegui.elhsmart.net.ru/skinned-dynamic.html:
G.addElement(Region);
Uncaught exception: TypeError: Cannot convert 'window.jam' to object
Error thrown at line 229, column 15 in <anonymous function: Preload.callback>() in fivegui.elhsmart.net.ru/skinned-dynamic.html:
window.jam.load();
called from line 219, column 20 in <anonymous function: image.onload>() in fivegui.elhsmart.net.ru/skinned-dynamic.html:
window[window.preloaderName].callback();
====================
var cardinal_directions = ['north','east','south','west','jaw'];
var i, last, visible, z, m;
for(i=0; i<4; i++) if (cardinal_directions[i]==last_move) last=i;
visible=[north, east, south, west, east];
z=1; selection: while(z--) {
for(i=0; i<4; i++) if (visible[i]==3) { result=i; way=1; break selection; }
for(m=(last-1)%4,i=0; i<4; i++,m=(m+1)%4) if (visible[m]==0) { result=m; break selection; }
result = Math.round( Math.random() * 5 );
} // selection block
result = cardinal_directions[ result ];
====================