Welcome 微信登录

首页 / 操作系统 / Linux / 几个检查当前运行的Linux是在VM还是在实体机中的方法

当一个高配置的主机虚拟成N个不同的VM主机分给不同的用户使用的时候,需要防范利用VM的漏洞逃逸到宿主机或者取得了其他VM的信息,这是云安全遇到的一个不小的难题。要想逃逸,首先要检测当前操作系统是否为VM,下面提供几个Linux下的检查方法:第一,首推facter virtual ,权限为普通用户,约定,普通用户命令提示符用$表示,root用户命令提示符用#表示,第一组为实体机的返回,第二组为虚拟机的返回:$facter virtualphysical$facter virtual
vmware第二,cat /proc/scsi/scsi,需要分析Vendor中的内容:$cat /proc/scsi/scsi
Attached devices:
Host: scsi6 Channel: 03 Id: 00 Lun: 00
  Vendor: HP     Model: P410           Rev: 5.14
  Type: RAID                           ANSI  SCSI revision: 05
Host: scsi6 Channel: 00 Id: 00 Lun: 00
  Vendor: HP     Model: LOGICAL VOLUME Rev: 5.14
  Type: Direct-Access   $cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
  Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
  Type: CD-ROM                         ANSI  SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: VMware Model: Virtual disk   Rev: 1.0
  Type: Direct-Access  由于我当前使用的测试环境为vmware,下面以它为例第三,lspci | grep -i vmware:$ lspci | grep -i vmware实体机上无返回结果$ lspci | grep -i vmware
00:07.7 System peripheral: VMware Virtual Machine Communication Interface (rev 10)
00:0f.0 VGA compatible controller: VMware SVGA II Adapter
00:11.0 PCI bridge: VMware PCI bridge (rev 02)
00:15.0 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.1 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.2 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.3 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.4 PCI bridge: VMware PCI Express Root Port (rev 01)第四,grep -i vmware /proc/scsi/scsi /proc/ide/*/model$grep -i vmware /proc/scsi/scsi /proc/ide/*/model
grep: /proc/ide/*/model: No such file or directory
$ grep -i vmware /proc/scsi/scsi /proc/ide/*/model
/proc/scsi/scsi:  Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
/proc/scsi/scsi:  Vendor: VMware Model: Virtual disk   Rev: 1.0第五,需要root权限,dmidecode | grep -i vmware#dmidecode | grep -i vmware实体机无返回# dmidecode | grep -i vmware        Manufacturer: VMware, Inc.
        Product Name: VMware Virtual Platform
        Serial Number: VMware-56 4d 29 65 6c ac 42 33-33 7f 89 2c d0 36 a3 25
        Description: VMware SVGA II推荐阅读:openfilter Linux 安装VMtools http://www.linuxidc.com/Linux/2012-11/73821.htm在Windows 7下安装VMware Workstation 9.0虚拟机 见 http://www.linuxidc.com/Linux/2012-11/74704.htmVMware Workstation 9.0正式版下载(附注册机+序列号激活码):http://www.linuxidc.com/Linux/2012-11/73743.htmUbuntu 12.04 Unity桌面环境VNC配置手记三个快速便捷的Linux命令行小贴士相关资讯      虚拟机  Linux VM 
  • 虚拟机已死,容器才是未来?  (05月06日)
  • 虚拟机Linux共享主机Windows文件夹  (09/12/2014 21:27:46)
  • Linux实用技巧:使用快照制作虚拟  (07/20/2014 11:02:22)
  • 微软发布2016年4月Windows 10开发  (04月22日)
  • 在Ubuntu上创建和管理Redhat虚拟机  (08/05/2014 14:47:21)
  • OpenShift Origin 虚拟机部署指南  (08/30/2013 21:21:16)
本文评论 查看全部评论 (0)
表情: 姓名: 字数