Add check method

bug/bundler_fix
jvazquez-r7 2014-06-02 08:14:40 -05:00
parent 31af8ef07b
commit d0241cf4c1
1 changed files with 46 additions and 12 deletions

View File

@ -69,6 +69,50 @@ class Metasploit3 < Msf::Exploit::Local
])
end
def check
unless file_exist?("#{get_env("windir")}\\Microsoft.NET\\Framework\\v4.0.30319\\dfsvc.exe")
return Exploit::CheckCode::Unknown
end
net_version = get_net_version
if net_version.empty?
return Exploit::CheckCode::Unknown
end
unless file_exist?("#{get_env("windir")}\\Microsoft.NET\\Framework\\v4.0.30319\\mscorlib.dll")
return Exploit::CheckCode::Detected
end
mscorlib_version = get_mscorlib_version
unless mscorlib_version < NET_VERSIONS[net_version]["mscorlib"]
return Exploit::CheckCode::Safe
end
Exploit::CheckCode::Vulnerable
end
def get_net_version
net_version = ""
dfsvc_version = file_version("#{get_env("windir")}\\Microsoft.NET\\Framework\\v4.0.30319\\dfsvc.exe")
dfsvc_version = dfsvc_version.join(".")
NET_VERSIONS.each do |k,v|
if v["dfsvc"] == dfsvc_version
net_version = k
end
end
net_version
end
def get_mscorlib_version
mscorlib_version = file_version("#{get_env("windir")}\\Microsoft.NET\\Framework\\v4.0.30319\\mscorlib.dll")
mscorlib_version.join(".")
end
def exploit
print_status("Running module against #{sysinfo['Computer']}") unless sysinfo.nil?
@ -87,16 +131,7 @@ class Metasploit3 < Msf::Exploit::Local
fail_with(Failure::NotVulnerable, ".NET Deployment Service (dfsvc.exe) not found")
end
dfsvc_version = file_version("#{get_env("windir")}\\Microsoft.NET\\Framework\\v4.0.30319\\dfsvc.exe")
dfsvc_version = dfsvc_version.join(".")
net_version = ""
NET_VERSIONS.each do |k,v|
if v["dfsvc"] == dfsvc_version
net_version = k
end
end
net_version = get_net_version
if net_version.empty?
fail_with(Failure::NotVulnerable, "This module only targets .NET Deployment Service from .NET 4.5 and .NET 4.5.1")
@ -110,8 +145,7 @@ class Metasploit3 < Msf::Exploit::Local
fail_with(Failure::NotVulnerable, ".NET Installation can not be verified (mscorlib.dll not found)")
end
mscorlib_version = file_version("#{get_env("windir")}\\Microsoft.NET\\Framework\\v4.0.30319\\mscorlib.dll")
mscorlib_version = mscorlib_version.join(".")
mscorlib_version = get_mscorlib_version
unless mscorlib_version < NET_VERSIONS[net_version]["mscorlib"]
fail_with(Failure::NotVulnerable, ".NET Installation not vulnerable")