Skip to content

Commit 805dcb2

Browse files
committed
Land rapid7#9128, New RC script for dev-related vulns
2 parents ca28abf + eb3f7f9 commit 805dcb2

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

scripts/resource/dev_checks.rc

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<ruby>
2+
3+
#
4+
# This resource script will check for vulnerabilities related to
5+
# programs and services used by developers, including the following:
6+
#
7+
# * NodeJS debug (multi/misc/nodejs_v8_debugger)
8+
# * distcc (unix/misc/distcc_exe)
9+
# * Jenkins (linux/misc/jenkins_java_deserialize)
10+
# * GitHub Enterprise (linux/http/github_enterprise_secret)
11+
#
12+
# It is worth noting that ONLY CHECKS are performed, no active exploiting.
13+
# This makes it safe to run in many environments.
14+
#
15+
# Authors:
16+
# * pbarry-r7
17+
# * dmohanty-r7
18+
#
19+
20+
@job_ids = []
21+
22+
def wait_until_jobs_done
23+
loop do
24+
@job_ids.each do |job_id|
25+
current_job_ids = framework.jobs.keys.map { |e| e.to_i }
26+
sleep 1 if current_job_ids.include?(job_id)
27+
end
28+
29+
return
30+
end
31+
end
32+
33+
def run_scanner(host:, mod_name:)
34+
begin
35+
mod = framework.auxiliary.create(mod_name)
36+
mod.datastore['RHOSTS'] = host.address
37+
print_line("Running the #{mod.name}...")
38+
result = mod.run_simple({'RunAsJob': true, 'LocalOutput': self.output})
39+
rescue ::Exception => e
40+
print_error(e.message)
41+
end
42+
end
43+
44+
def check_exploit(host:, mod_name:, vuln_check_ret_val:)
45+
begin
46+
mod = framework.exploits.create(mod_name)
47+
mod.datastore['RHOST'] = host.address
48+
print_line("Looking for #{mod.name}...")
49+
result = mod.check_simple({'RunAsJob': true, 'LocalOutput': self.output})
50+
@job_ids << mod.job_id if mod.job_id
51+
if vuln_check_ret_val.index(result)
52+
print_line("HOST #{host.address} APPEARS VULNERABLE TO #{mod.name}")
53+
framework.db.report_vuln(
54+
workspace: mod.workspace,
55+
host: mod.rhost,
56+
name: mod.name,
57+
info: "This was flagged as likely vulnerable by the explicit check of #{mod.fullname}.",
58+
refs: mod.references
59+
)
60+
end
61+
rescue ::Exception => e
62+
print_error(e.message)
63+
end
64+
end
65+
66+
def setup
67+
# Test and see if we have a database connected
68+
if not (framework.db and framework.db.active)
69+
print_error("Database connection isn't established")
70+
return false
71+
end
72+
73+
run_single("setg verbose true")
74+
75+
true
76+
end
77+
78+
def main
79+
framework.db.workspace.hosts.each do |host|
80+
print_line("Checking IP: #{host.address}, OS: #{host.os_name}...")
81+
82+
# Modules
83+
{ 'multi/misc/nodejs_v8_debugger': [ Exploit::CheckCode::Appears ],
84+
'unix/misc/distcc_exec': [ Exploit::CheckCode::Vulnerable ],
85+
'unix/misc/qnx_qconn_exec': [ Exploit::CheckCode::Vulnerable ],
86+
'linux/misc/jenkins_java_deserialize': [ Exploit::CheckCode::Vulnerable ],
87+
'linux/http/github_enterprise_secret': [ Exploit::CheckCode::Vulnerable ],
88+
'multi/http/traq_plugin_exec': [ Exploit::CheckCode::Appears ],
89+
'multi/http/builderengine_upload_exec': [ Exploit::CheckCode::Appears ],
90+
'multi/http/mantisbt_php_exec': [ Exploit::CheckCode::Appears ],
91+
'multi/http/vbulletin_unserialize': [ Exploit::CheckCode::Appears ],
92+
'unix/webapp/vbulletin_vote_sqli_exec': [ Exploit::CheckCode::Appears ],
93+
'multi/misc/java_jmx_server': [ Exploit::CheckCode::Appears,
94+
Exploit::CheckCode::Detected ] }.each do |mod,ret_val|
95+
check_exploit(host: host,
96+
mod_name: mod.to_s,
97+
vuln_check_ret_val: ret_val)
98+
end
99+
100+
# Scanners
101+
[ 'scanner/misc/java_rmi_server' ].each do |mod|
102+
run_scanner(host: host, mod_name: mod.to_s)
103+
end
104+
end
105+
106+
wait_until_jobs_done
107+
end
108+
109+
abort("Error during setup, exiting.") unless setup
110+
main
111+
112+
</ruby>

0 commit comments

Comments
 (0)