Merge branch 'vm-stuff'

unstable
Tod Beardsley 2012-01-26 13:04:44 -06:00
commit 5afc164c39
6 changed files with 62 additions and 21 deletions

View File

@ -0,0 +1,9 @@
class AddVirtualHostToHosts < ActiveRecord::Migration
def self.up
add_column :hosts, :virtual_host, :text
end
def self.down
remove_column :hosts, :viritual_host
end
end

View File

@ -262,6 +262,7 @@ class DBManager
# :arch -- one of the ARCH_* constants
# :mac -- the host's MAC address
# :scope -- interface identifier for link-local IPv6
# :virtual_host -- the name of the VM host software, eg "VMWare", "QEMU", "Xen", etc.
#
def report_host(opts)

View File

@ -21,6 +21,10 @@ class Host < ActiveRecord::Base
validates_exclusion_of :address, :in => ['127.0.0.1']
validates_uniqueness_of :address, :scope => :workspace_id
def is_vm?
!!self.virtual_host
end
def attribute_locked?(attr)
n = notes.find_by_ntype("host.updated.#{attr}")
n && n.data[:locked]

View File

@ -30,6 +30,18 @@ module Common
return o
end
def report_vm(vm)
return unless session
return unless vm
vm_normal = vm.to_s.lstrip.strip
return if vm_normal.empty?
vm_data = {
:host => session.target_host,
:virtual_host => vm_normal
}
report_host(vm_data)
end
end
end
end

View File

@ -29,7 +29,7 @@ class Metasploit3 < Msf::Post
'Description' => %q{
This module attempts to determine whether the system is running
inside of a virtual environment and if so, which one. This
module supports detectoin of Hyper-V, VMWare, VirtualBox, Xen,
module supports detection of Hyper-V, VMWare, VirtualBox, Xen,
and QEMU/KVM.},
'License' => MSF_LICENSE,
'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],
@ -164,12 +164,11 @@ class Metasploit3 < Msf::Post
if vm
print_good("This appears to be a #{vm} Virtual Machine")
report_vm(vm)
else
print_status("This appears to be a Physical Machine")
end
end
end

View File

@ -64,8 +64,10 @@ class Metasploit3 < Msf::Post
rescue
end
end
print_status("This is a Hyper-V Virtual Machine") if vm
return vm
if vm
print_status("This is a Hyper-V Virtual Machine")
return "MS Hyper-V"
end
end
# Method for checking if it is a VMware VM
@ -109,9 +111,10 @@ class Metasploit3 < Msf::Post
end
end
end
print_status("This is a VMware Virtual Machine") if vm
return vm
if vm
print_status("This is a VMware Virtual Machine")
return "VMWare"
end
end
# Method for checking if it is a Virtual PC VM
@ -144,8 +147,10 @@ class Metasploit3 < Msf::Post
rescue
end
end
print_status("This is a VirtualPC Virtual Machine") if vm
return vm
if vm
print_status("This is a VirtualPC Virtual Machine")
return "VirtualPC"
end
end
# Method for checking if it is a VirtualBox VM
@ -227,8 +232,10 @@ class Metasploit3 < Msf::Post
rescue
end
end
print_status("This is a Sun VirtualBox Virtual Machine") if vm
return vm
if vm
print_status("This is a Sun VirtualBox Virtual Machine")
return "VirtualBox"
end
end
# Method for checking if it is a Xen VM
@ -293,8 +300,10 @@ class Metasploit3 < Msf::Post
rescue
end
end
print_status("This is a Xen Virtual Machine") if vm
return vm
if vm
print_status("This is a Xen Virtual Machine")
return "Xen"
end
end
def qemuchk(session)
@ -320,18 +329,25 @@ class Metasploit3 < Msf::Post
end
end
return vm
if vm
return "Qemu/KVM"
end
end
# run Method
def run
print_status("Checking if #{sysinfo['Computer']} is a Virtual Machine .....")
found = hypervchk(session)
found = vmwarechk(session) if not found
found = checkvrtlpc(session) if not found
found = vboxchk(session) if not found
found = xenchk(session) if not found
found = qemuchk(session) if not found
print_status("It appears to be a physical host.") if not found
found ||= vmwarechk(session)
found ||= checkvrtlpc(session)
found ||= vboxchk(session)
found ||= xenchk(session)
found ||= qemuchk(session)
if found
report_vm(found)
else
print_status("#{sysinfo['Computer']} appears to be a Physical Machine")
end
end
end