Skip to content

Commit bd3dc8a

Browse files
committed
Use fail_with rather than fail
1 parent 015b96a commit bd3dc8a

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

modules/exploits/multi/http/cve_2014_9390.rb

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def initialize(info = {})
6767
{
6868
'PayloadType' => 'cmd cmd_bash',
6969
'RequiredCmd' => 'generic bash-tcp perl bash'
70-
},
70+
}
7171
}
7272
}
7373
],
@@ -103,7 +103,7 @@ def setup
103103
mercurial: { files: {}, trigger: nil }
104104
}
105105
if git_uri.blank? && mercurial_uri.blank?
106-
fail ArgumentError, 'Must specify at least one non-blank GIT_URI or MERCURIAL_URI'
106+
fail_with(Exploit::Failure::BadConfig, 'Must specify at least one non-blank GIT_URI or MERCURIAL_URI')
107107
end
108108
setup_git unless git_uri.blank?
109109
setup_mercurial unless mercurial_uri.blank?
@@ -113,9 +113,13 @@ def setup
113113

114114
def setup_git
115115
# URI must start with a /
116-
fail ArgumentError, 'GIT_URI must start with a /' unless git_uri =~ /^\//
116+
unless git_uri =~ /^\//
117+
fail_with(Exploit::Failure::BadConfig, 'GIT_URI must start with a /')
118+
end
117119
# sanity check the malicious hook:
118-
fail ArgumentError, 'GIT_HOOK must not be blank' if datastore['GIT_HOOK'].blank?
120+
if datastore['GIT_HOOK'].blank?
121+
fail_with(Exploit::Failure::BadConfig, 'GIT_HOOK must not be blank')
122+
end
119123

120124
# This builds a fake git repository using the knowledge from:
121125
# http://schacon.github.io/gitbook/7_how_git_stores_objects.html
@@ -191,9 +195,13 @@ def setup_git
191195

192196
def setup_mercurial
193197
# URI must start with a /
194-
fail ArgumentError, 'MERCURIAL_URI must start with a /' unless mercurial_uri =~ /^\//
195-
# sanity check the malicious hook:
196-
fail ArgumentError, 'MERCURIAL_HOOK must not be blank' if datastore['MERCURIAL_HOOK'].blank?
198+
unless mercurial_uri =~ /^\//
199+
fail_with(Exploit::Failure::BadConfig, 'MERCURIAL_URI must start with a /')
200+
end
201+
# sanity check the malicious hook
202+
if datastore['MERCURIAL_HOOK'].blank?
203+
fail_with(Exploit::Failure::BadConfig, 'MERCURIAL_HOOK must not be blank')
204+
end
197205
# we fake the Mercurial HTTP protocol such that we are compliant as possible but
198206
# also as simple as possible so that we don't have to support all of the protocol
199207
# complexities. Taken from:

0 commit comments

Comments
 (0)