1. Your address, and how you submit a flag
Same as every lab: there is no form and nothing goes to Blackboard.
You submit a flag by redeeming it, and
OK 250 is your receipt. If you still have your key from a
previous lab, use it — the balance carries over.
cd ~/ierg4851/contactless-ctf python3 score/keygen.py
wrote mykey.json address: 3c42822cbbcfb07cac13ad9afa7555cb10fc58f7 verified: address derives from this key registered as u1155203181
Then, for each flag you earn:
python3 score/redeem.py --flag IERG4851_WEB2_LOGIN_933e4aa8 --to 3c42822cbbcfb07cac13ad9afa7555cb10fc58f7
The new flags start with IERG4851_WEB2_. Each belongs to
one account — yours. Redeem it to the address you registered; the ledger
refuses a flag presented from another student's account.
OK 250 your total is now 1500 points (example: 1250 from the earlier labs + this one)
myscore shows your points and rank. The projector page at
http://<lab-machine>:8080/ shows everyone and a tick per
challenge — this week it grows five new columns (user ierg4851,
password given in class).
2. Where the app is, and how you reach it
Everything runs inside the lab machine, like last week. The shop listens on loopback; there is no public URL.
myweb2 first, then
replace 9388 with the port it prints
for you — in every command in this
manual.ssh <your-username>@<lab-machine> myweb2
your shop: http://127.0.0.1:9388/ <-- EXAMPLE ONLY — DO NOT USE 9388, use YOUR port start: curl -i http://127.0.0.1:9388/ your flags: curl -s http://127.0.0.1:9388/my
Use the port myweb2 printed for you in every
command — not 9388. To see the shop in your own browser, forward the
port first (both numbers are your port):
ssh -L 9388:127.0.0.1:9388 <you>@<lab-machine> <-- DO NOT use 9388 — use YOUR port
myweb2 again and check the number./login and look
around — that is a plain customer account. The flag is not on it.cat on the paths the shop's own pages print, as yourself
first, and see the permission denied.3. The five bugs, one per family from the lecture
| # | challenge | family | where it starts |
|---|---|---|---|
| 1 | login | SQL injection | /login |
| 2 | ping | command injection | /tools/ping |
| 3 | preview | SSRF | /settings |
| 4 | download | path traversal | /files/invoice-2001.txt |
| 5 | order | access control | /orders |
Five probes to start with, straight from the lecture: a quote
' in every field, a semicolon ;id after a
parameter, two dots ../ in every path, a URL scheme a
browser will never follow, and an order number nobody showed you. One
of them is your first flag.
4. Hints, in the order of the lecture
1 · login — SQL injection in the sign-in form
The sign-in form builds its SQL by gluing your input into the query
text. The string from the lecture — ' OR 1=1 -- — logs
you in as the admin account, and the flag is on the
admin's page. Start with the user field. Bonus: the
/products page builds its SQL the same way — with a
UNION you can make it show the users table.
2 · ping — command injection in the diagnostic tool
/tools/ping builds a shell command from the host field.
The page shows you the full path of the shop's flag file. First try to
cat that file yourself: permission denied. Now make
the ping tool cat it for you — add a second command after a
semicolon, and the output appears in the page.
3 · preview — the fetcher with the shop's rights
/settings fetches any URL you paste, running as the shop
service account. It accepts file:// URLs, which read files
— with the shop's read permission, not yours. The shop's private files
are in its data directory; the ping page prints that path, and the file
you want has the obvious name.
4 · download — path traversal in the file server
/files/<name> opens the shop's files directory plus
your name. Open the invoice first: its footer names the files directory
you are in and the vault directory that holds the flag. You need to go
from one to the other with ../. Remember to write
/ as %2f, or curl will rewrite your path
before sending it.
5 · order — the API that checks nothing
Your orders are 2001 and 2002. The API
(/api/orders/<number>) serves any
order by number — it never checks whose order it is. That is the bug.
The flag is in the shop owner's order, and the owner's number is not on
any page. But the database knows it: read the orders table through the
/products injection (hint 1's bonus), then call the API
with that number. That is the smart solve — one question to the
database instead of a thousand guesses. You could also try
numbers one by one until the API answers; brute force works too, and
the fact that it works is part of what is wrong with this API.
5. Rules and the explain round
- Attack only the shop assigned to you; everything is local.
- Flags are per student, 250 points each, redeemed once.
myscorefor your standing; the projector board for everyone's ticks.
At the end, three or four of you explain one challenge:
- What did the server trust that it should not have?
- Which interpreter — or which missing check — made it work?
- What would you change, in one line?