每日代码汇第八期:一个简单的php小偷程序。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | <?php //-------------------------配置参数开始------------------------- //目标站网址 $url="http://blog.0907.org"; //当前文件名 $thisname='index.php'; //-------------------------配置参数结束------------------------- header("Content-type: text/html; charset=GBK"); $server_url = preg_replace("/(http|https|ftp|news):\/\//i", "", $url); $server_url = preg_replace("/\/.*/", "", $server_url); $server_url = 'http://'.$server_url; $getid=$_SERVER["REQUEST_URI"]; $scriptname=$_SERVER["SCRIPT_NAME"]; $thisurl="http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; if( preg_match('#(http|https|ftp|news):#iUs',$getid) ){ header("Location:".$scriptname); exit; } if( preg_match('#'.$scriptname.'\/#iUs',$getid) ){ $url=$server_url.'/'.str_ireplace($scriptname."/",'',stristr($getid,$scriptname."/")); } $thismulu=str_ireplace(stristr($_SERVER['PHP_SELF'],$thisname),'',$thisurl); function curl_get($url){ if(function_exists('curl_init') && function_exists('curl_exec')){ $ch = curl_init(); $user_agent = "Mozilla/5.0+(compatible;+Baiduspider/2.0;++http://www.baidu.com/search/spider.html)"; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_REFERER, "http://www.baidu.com/s?wd=%CA%B2%C3%B4"); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); $data = curl_exec($ch); curl_close($ch); }else{ for($i=0;$i<3;$i++){ $data = @file_get_contents($url); if($data) break; } } return $data; } function filter($str){ global $server_url; $str=preg_replace("/<base[^>]+>/si","",$str); $str=preg_replace("/\s+/", " ", $str); $str=preg_replace("/< \!--.*?-->/si","",$str); $str=preg_replace("/< (script.*?)>(.*?)< (\/script.*?)>/si","",$str); $str=preg_replace("/< (\/?script.*?)>/si","",$str); $str=preg_replace("/javascript/si","Javascript",$str); $str=preg_replace("/vbscript/si","Vbscript",$str); $str=preg_replace("/on([a-z]+)\s*=/si","On\\1=",$str); return $str; } function urlchange($str) { global $server_url,$scriptname,$thismulu; $str = preg_replace('/src=(["|\']?)\//', 'src=\\1'.$server_url.'/', $str); $str = preg_replace('/< (link[^>]+)href=(["|\']?)\/?/', '< \\1href=\\2'.$server_url.'/', $str); $str = preg_replace('/<(a[^>]+)href=(["|\']?)\/?/', '< \\1href=\\2'.$scriptname.'/', $str); $str=str_ireplace('/javascript:;','#',$str); $str=str_ireplace('"'.$scriptname.'/"',$scriptname,$str); return $str; } function charset($str){ if(preg_match('#<meta[^>]*charset\s*=\s*utf-8#iUs',$str)){ $str=preg_replace('/charset\s*=\s*utf-8/i','charset=gb2312',$str); $str=iconv("UTF-8", "GB2312//IGNORE", $str); } return $str; } $body=urlchange(filter(charset(curl_get($url)))); //-------------替换开始---------------------- $body=preg_replace('#>精品推荐(.*)<div class="easou_box"><p>" #si',"",$body); //正则替换,这里我就不多说啦,PS:其实我也不大会正则 //PS:可写多个 $body=str_ireplace('action="/v"','action="index.php/v"',$body); //$body=str_ireplace('您要替换的内容','你想替换成的内容',$body); //PS:可写多个 //嘻嘻,欢迎大家去我博客做客 //------------替换结束------------------------ echo $body; ?> </p></div> |
来源:http://www.oschina.net/code/snippet_1243326_23690(oschina.net)
生产:无名游客
主页:http://my.oschina.net/mrl1996
挺喜欢的页面设计的
这个咋用啊
在机器上装个php环境就行!
建议安装wamp,这个比较方便,安装好在wamp目录下启用wampmanager.exe,然后在wamp/www目录下新建个1.php(例子)文件,把以上代码拷进去保存,然后在浏览器运行localhost/1.php 就可以看到效果了!!!
不错啊,
学习了,感谢分享