check vm main module

This commit is contained in:
Alessandro ZANNI 2016-10-23 16:02:20 +02:00
parent 8947850c31
commit 972274345d
1 changed files with 16 additions and 8 deletions

View File

@ -6,7 +6,7 @@ from modules.lib.windows.powershell_upload import execute_powershell_script
__class_name__="CheckVM" __class_name__="CheckVM"
ROOT=os.path.abspath(os.path.join(os.path.dirname(__file__),"..")) ROOT=os.path.abspath(os.path.join(os.path.dirname(__file__),".."))
@config(compat="windows", category="gather") @config(compat=['linux', 'windows'], category="gather")
class CheckVM(PupyModule): class CheckVM(PupyModule):
""" check if running on Virtual Machine """ """ check if running on Virtual Machine """
@ -14,10 +14,18 @@ class CheckVM(PupyModule):
self.arg_parser = PupyArgumentParser(prog="CheckVM", description=self.__doc__) self.arg_parser = PupyArgumentParser(prog="CheckVM", description=self.__doc__)
def run(self, args): def run(self, args):
content = open(os.path.join(ROOT, "external", "Nishang", "Check-VM.ps1"), 'r').read() if self.client.is_windows():
function = 'Check-VM' content = open(os.path.join(ROOT, "external", "Nishang", "Check-VM.ps1"), 'r').read()
output = execute_powershell_script(self, content, function) function = 'Check-VM'
if output.strip(): output = execute_powershell_script(self, content, function)
self.success("%s" % output) if output.strip():
else: self.success("%s" % output)
self.success("No virtual machine detected") else:
self.success("No virtual machine detected")
elif self.client.is_linux():
self.client.load_package("checkvm")
vm = self.client.conn.modules["checkvm"].checkvm()
if vm:
self.success('This appears to be a %s virtual machine' % vm)
else:
self.success('This does not appear to be a virtual machine')