ORDER ORDER — PicoCTF Writeup
好的,我现在需要帮用户总结一篇文章的内容,控制在100字以内。首先,我得仔细阅读文章内容,了解主要情节和关键点。 文章讲的是一个SQL注入漏洞的发现和利用过程。作者测试了一个费用追踪网站,尝试在登录、注册和费用页面寻找漏洞,但没有成功。后来发现生成报告功能存在SQL注入漏洞。通过构造payload,作者最终提取了数据库中的表名和数据,并获得了flag。 接下来,我需要将这些信息浓缩到100字以内。要注意保持主要步骤:测试各页面未果、发现生成报告漏洞、构造payload提取数据、获得flag。 可能会遗漏一些细节,比如具体使用的payload类型或步骤,但必须确保核心流程清晰。同时,语言要简洁明了,避免冗长的描述。 最后,检查字数是否符合要求,并确保内容准确传达了文章的主要内容。 </think> 作者通过测试一个费用追踪网站的登录、注册和费用页面未找到SQL注入漏洞。最终在“生成报告”功能中发现漏洞,并通过构造SQL注入payload提取数据库中的表名和数据,成功获取flag:picoCTF{s3c0nd_0rd3r_1t_1s_4611c226}。 2026-3-29 10:19:21 Author: infosecwriteups.com(查看原文) 阅读量:4 收藏

Press enter or click to view image in full size

Home Page

The website was a normal Expense Tracker website with a Login and Sign-Up page. Based on the given challenge description and name, it was clear that the challenge is mostly related to SQL Injection. So, first I decided to see how the websites work and what are its functionalities.

Press enter or click to view image in full size

Sign Up page

After signing up a dummy account, I was logged in and redirected to the dashboard page. There were 2 more pages as Expenses and Logout

Press enter or click to view image in full size

Home Page after Login

In the expense page, we can add expenses that are to be tracked and even generate a report of it.

Press enter or click to view image in full size

Adding an expense

On clicking on “GENERATE REPORT”, we get a message saying:
Report generation requested successfully! Check your inbox after 10 seconds!!!

Press enter or click to view image in full size

Generate Report

On the Inbox page, we can see that a csv file is ready to be downloaded.

Press enter or click to view image in full size

Inbox Page

Now, I spent a lot of time searching for where the SQLi vulnerability would be present. My first page to test was obviously the Expenses Page. After trying SQLi payloads in all possible parameters (Description, Amount and Date), I came to the conclusion that the Expenses Page is not vulnerable to SQLi.

SQLi can also be found in Login and Sign-Up pages of a website. So, I made more dummy accounts with SQLi payloads in it this time. Still, it didn’t give any hint for SQL Injection Vulnerability.

I had tested majorly all functions except Generate Report and finally decided to give it a go. I assumed that the website would have either used my username or email as identifier to get my expense records from the database.

So, I made a fake account with credentials:
username: dum’
email: [email protected]
Password: Anything

After logging in, I went to the Expenses page and clicked on Generate Report. On checking the inbox, we find that the Report Generation failed.

Press enter or click to view image in full size

SQLi vulnerability found

So, we have finally found the vulnerable endpoint and now we need to just exploit it.

Get Vedant Pillai’s stories in your inbox

Join Medium for free to get updates from this writer.

Remember me for faster sign in

I assumed that the backend SQL Query is somewhat similar to the following query:

SELECT id, amount, categthe no. of columnsory, description, date
FROM expenses
WHERE username = <username>; //SQLi Vulnerable

The challenge most likely wanted us to perform UNION based SQL Injection. Using UNION Based queries, we can get output of multiple tables together. For this, the first step is to get the no. of columns present in the current table.

Payloads:
' ORDER BY 1--
' ORDER BY 2--
' ORDER BY 3--
' ORDER BY 4--
...

//Keep increasing the number until an error occurs
//Eg: If error occurs at "' ORDER BY 4--", then the no. of columns are 3

To execute this, I had to logout and make accounts with username having these payloads.

On using payload ‘ ORDER BY 4 —’, we get an error. This means that the no. of columns are 3 for that table.

Press enter or click to view image in full size

ORDER BY Error

Now, since I had the no. of columns for that table, the next step is to get the name of tables present. In SQLite, the metadata is stored in “sqlite_master”.

' UNION SELECT name,NULL,NULL FROM sqlite_master WHERE type='table'--

On making a new account with this payload in our username, we get a successful generate report response.

Press enter or click to view image in full size

‘ UNION SELECT name,NULL,NULL FROM sqlite_master WHERE type=’table’ —

On downloading the csv file, we see that we have the names of all tables present with us.

sqlite_master tables data

From the list of tables:

aDNyM19uMF9mMTRn:h3r3_n0_f14g (Base64 Encoded String)

This looked suspicious to me, and I decided to dump the data in that table this time.

Payload:
' UNION SELECT *,NULL FROM aDNyM19uMF9mMTRn--

On making another account with the above payload and generating the report again, we get a successful generate report response.

Press enter or click to view image in full size

On downloading the csv file, we finally get the flag.

Flag

Flag: picoCTF{s3c0nd_0rd3r_1t_1s_4611c226}

Let’s Connect:
Linkedin: Vedant Pillai | LinkedIn
Github: Codewith-Vedant (Vedant Pillai)


文章来源: https://infosecwriteups.com/order-order-picoctf-writeup-b7c7de44f296?source=rss----7b722bfd1b8d---4
如有侵权请联系:admin#unsafe.sh