SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
Hachioji.pm #14
 Lightning Talk
    @ytnobody
今回のテーマ
  浮気
浮気?!
そんなふしだらな奴には
 手痛いしっぺ返し!
今日は(サーバ的な意味で)浮気性な
   スクリプトキディたちに
門前払いを食らわせたお話をします。
自分の身は自分で守らないとね!
さくらvpsのnginxに
大量の不審なアクセスログ
アクセス元は
パチモンで名を馳せている
 あの国とかあの国とか
上等だ、アク禁してやる。
use strict;
use warnings;

my $limit = 10;
my $expire = 600;

my $cnt = {};
my $addr;

while ( my $line = <STDIN> ) {
   my @part = split /s/, $line;
   my $stat = $part[8];
   $addr = $part[0];
   next unless $addr =~ /^d+?.d+?.d+?.d+$/;
   next if $addr =~ /^127./;
   next unless $stat =~ /^4/;
   $cnt->{$addr}->{cnt} ||= 0;
   if ( $cnt->{$addr}->{cnt} < $limit ) {
       $cnt->{$addr}->{cnt} ++;
       $cnt->{$addr}->{time} = time();
       if ( $cnt->{$addr}->{cnt} >= $limit ) {
           `iptables -A INPUT -s $addr -j DROP`;
       }
   }
   for $addr ( keys %$cnt ) {
       if ( time - $cnt->{$addr}->{time} >= $expire ) {
           delete $cnt->{$addr};
           `iptables -D INPUT -s $addr -j DROP`;
       }
   };
}
アクセスログを解析
404を頻発させているIPアドレスを抽出
そうやって絞り出したIPを
iptables で DROP DROP DROP!
今ではアクセスログが
 たまりすぎることなく
平和に過ごしております
ご静聴
ありがとうございました

Contenu connexe

En vedette

Lectionline xv domenica del t o anno a_13 luglio
Lectionline xv domenica del t o  anno a_13 luglioLectionline xv domenica del t o  anno a_13 luglio
Lectionline xv domenica del t o anno a_13 luglio
Maike Loes
 
Giornata migranti rifugiati 2014
Giornata migranti rifugiati   2014Giornata migranti rifugiati   2014
Giornata migranti rifugiati 2014
Maike Loes
 
Pressbook fish tank
Pressbook fish tank Pressbook fish tank
Pressbook fish tank
stoliros
 
Kerajaan orang khmer
Kerajaan orang khmerKerajaan orang khmer
Kerajaan orang khmer
Opie Mohamad
 
Triduo Sr. Angela Vallese_3 giorno ita
Triduo Sr. Angela Vallese_3 giorno itaTriduo Sr. Angela Vallese_3 giorno ita
Triduo Sr. Angela Vallese_3 giorno ita
Maike Loes
 
Triduo Sr Angela Vallese_3 giorno eng
Triduo Sr Angela Vallese_3 giorno engTriduo Sr Angela Vallese_3 giorno eng
Triduo Sr Angela Vallese_3 giorno eng
Maike Loes
 
Family tree
Family tree Family tree
Family tree
35150
 

En vedette (20)

Lectionline xv domenica del t o anno a_13 luglio
Lectionline xv domenica del t o  anno a_13 luglioLectionline xv domenica del t o  anno a_13 luglio
Lectionline xv domenica del t o anno a_13 luglio
 
Barómetro sobre CONFIANZA de Edelman 2016
Barómetro sobre CONFIANZA de Edelman 2016Barómetro sobre CONFIANZA de Edelman 2016
Barómetro sobre CONFIANZA de Edelman 2016
 
Giornata migranti rifugiati 2014
Giornata migranti rifugiati   2014Giornata migranti rifugiati   2014
Giornata migranti rifugiati 2014
 
Pressbook fish tank
Pressbook fish tank Pressbook fish tank
Pressbook fish tank
 
Kerajaan orang khmer
Kerajaan orang khmerKerajaan orang khmer
Kerajaan orang khmer
 
In Defence of Sri Rama
In Defence of Sri RamaIn Defence of Sri Rama
In Defence of Sri Rama
 
大ざっぱにオブジェクト指向
大ざっぱにオブジェクト指向大ざっぱにオブジェクト指向
大ざっぱにオブジェクト指向
 
Portfolio katrulina a price
Portfolio katrulina a pricePortfolio katrulina a price
Portfolio katrulina a price
 
Unpaid Internships in the Creative Industries
Unpaid Internships in the Creative IndustriesUnpaid Internships in the Creative Industries
Unpaid Internships in the Creative Industries
 
geriatric-myth and facts India
geriatric-myth and facts Indiageriatric-myth and facts India
geriatric-myth and facts India
 
Triduo Sr. Angela Vallese_3 giorno ita
Triduo Sr. Angela Vallese_3 giorno itaTriduo Sr. Angela Vallese_3 giorno ita
Triduo Sr. Angela Vallese_3 giorno ita
 
Triduo Sr Angela Vallese_3 giorno eng
Triduo Sr Angela Vallese_3 giorno engTriduo Sr Angela Vallese_3 giorno eng
Triduo Sr Angela Vallese_3 giorno eng
 
Novembre 2011
Novembre 2011Novembre 2011
Novembre 2011
 
TRABAJO FINAL
TRABAJO FINALTRABAJO FINAL
TRABAJO FINAL
 
Lec1 understanding unix
Lec1 understanding unixLec1 understanding unix
Lec1 understanding unix
 
Imagen1
Imagen1Imagen1
Imagen1
 
Singapore Power x Singapore Poly
Singapore Power x Singapore PolySingapore Power x Singapore Poly
Singapore Power x Singapore Poly
 
Mission 11 mars 2016
Mission 11 mars 2016Mission 11 mars 2016
Mission 11 mars 2016
 
Poster Challenge
Poster Challenge Poster Challenge
Poster Challenge
 
Family tree
Family tree Family tree
Family tree
 

Plus de azuma satoshi

Perlbeginnes 9 lt_ytnobody
Perlbeginnes 9 lt_ytnobodyPerlbeginnes 9 lt_ytnobody
Perlbeginnes 9 lt_ytnobody
azuma satoshi
 
Perlbeginnes 9 opening
Perlbeginnes 9 openingPerlbeginnes 9 opening
Perlbeginnes 9 opening
azuma satoshi
 
Perlbeginners proposal
Perlbeginners proposalPerlbeginners proposal
Perlbeginners proposal
azuma satoshi
 
ライブコーディング(?)で学ぶPerlオブジェクト指向
ライブコーディング(?)で学ぶPerlオブジェクト指向ライブコーディング(?)で学ぶPerlオブジェクト指向
ライブコーディング(?)で学ぶPerlオブジェクト指向
azuma satoshi
 
Perlbeginnes 4 keynote
Perlbeginnes 4 keynotePerlbeginnes 4 keynote
Perlbeginnes 4 keynote
azuma satoshi
 
Perl暦およそ10年(?)の僕がデータベースを使えるようになるまでの昔話
Perl暦およそ10年(?)の僕がデータベースを使えるようになるまでの昔話Perl暦およそ10年(?)の僕がデータベースを使えるようになるまでの昔話
Perl暦およそ10年(?)の僕がデータベースを使えるようになるまでの昔話
azuma satoshi
 
Perlbeginners 3 opening talk
Perlbeginners 3 opening talkPerlbeginners 3 opening talk
Perlbeginners 3 opening talk
azuma satoshi
 
Perlbeginnes 2 keynote
Perlbeginnes 2 keynotePerlbeginnes 2 keynote
Perlbeginnes 2 keynote
azuma satoshi
 
Perl Beginners #1 keynote
Perl Beginners #1 keynotePerl Beginners #1 keynote
Perl Beginners #1 keynote
azuma satoshi
 
Alluren of prototype-based OOP
Alluren of prototype-based OOPAlluren of prototype-based OOP
Alluren of prototype-based OOP
azuma satoshi
 

Plus de azuma satoshi (19)

finally (not finally)
finally (not finally)finally (not finally)
finally (not finally)
 
時を駆けるINSERT.pptx
時を駆けるINSERT.pptx時を駆けるINSERT.pptx
時を駆けるINSERT.pptx
 
できる!サーバレスアーキテクチャ
できる!サーバレスアーキテクチャできる!サーバレスアーキテクチャ
できる!サーバレスアーキテクチャ
 
L tthon
L tthonL tthon
L tthon
 
Perlbeginnes 9 lt_ytnobody
Perlbeginnes 9 lt_ytnobodyPerlbeginnes 9 lt_ytnobody
Perlbeginnes 9 lt_ytnobody
 
Perlbeginnes 9 opening
Perlbeginnes 9 openingPerlbeginnes 9 opening
Perlbeginnes 9 opening
 
Perlbeginners proposal
Perlbeginners proposalPerlbeginners proposal
Perlbeginners proposal
 
Chibapm01 lt
Chibapm01 ltChibapm01 lt
Chibapm01 lt
 
入れ子構造を分解する
入れ子構造を分解する入れ子構造を分解する
入れ子構造を分解する
 
YAPC::Asia 2012 CPANに恩返ししよう
YAPC::Asia 2012 CPANに恩返ししようYAPC::Asia 2012 CPANに恩返ししよう
YAPC::Asia 2012 CPANに恩返ししよう
 
ライブコーディング(?)で学ぶPerlオブジェクト指向
ライブコーディング(?)で学ぶPerlオブジェクト指向ライブコーディング(?)で学ぶPerlオブジェクト指向
ライブコーディング(?)で学ぶPerlオブジェクト指向
 
Perlbeginnes 4 keynote
Perlbeginnes 4 keynotePerlbeginnes 4 keynote
Perlbeginnes 4 keynote
 
Perl暦およそ10年(?)の僕がデータベースを使えるようになるまでの昔話
Perl暦およそ10年(?)の僕がデータベースを使えるようになるまでの昔話Perl暦およそ10年(?)の僕がデータベースを使えるようになるまでの昔話
Perl暦およそ10年(?)の僕がデータベースを使えるようになるまでの昔話
 
Perlbeginners 3 opening talk
Perlbeginners 3 opening talkPerlbeginners 3 opening talk
Perlbeginners 3 opening talk
 
PSGIへの誘い
PSGIへの誘いPSGIへの誘い
PSGIへの誘い
 
Perlbeginnes 2 keynote
Perlbeginnes 2 keynotePerlbeginnes 2 keynote
Perlbeginnes 2 keynote
 
Perl Beginners #1 keynote
Perl Beginners #1 keynotePerl Beginners #1 keynote
Perl Beginners #1 keynote
 
Hachioji.pm #13 LT
Hachioji.pm #13 LTHachioji.pm #13 LT
Hachioji.pm #13 LT
 
Alluren of prototype-based OOP
Alluren of prototype-based OOPAlluren of prototype-based OOP
Alluren of prototype-based OOP
 

Hachiojipm 14 LT