破解Xen虚拟机密码

简介:

查看Xen镜像文件的位置:

more /etc/xen/selboo

virsh edit IM-243.35


找到类似以下一句话:
disk = ['file:/opt/disk/selboo.img,sda1,w']
说明 镜像文件的位置在 /opt/disk/selboo.img

<source file='/xen/hardDisk/IM-243.35.img'/>


关闭虚拟机:
xm  shutdown selboo

2.进行挂载镜像文件:
首先查看文件基本信息:
fdisk /xen/hardDisk/IM-243.35.img -l  #得知此镜像的簇大小为512
sfdisk -d /xen/hardDisk/IM-243.35.img

/opt/disk/selboo.img1 : start=       63, size=   208782, Id=83, bootable
/opt/disk/selboo.img2 : start=   208845, size= 16563015, Id=8e
/opt/disk/selboo.img3 : start=        0, size=        0, Id= 0
/opt/disk/selboo.img4 : start=        0, size=        0, Id= 0 
上述结果可以得知,簇的起始位置在63!

mount -o loop,offset=$((63*512)) /xen/hardDisk/IM-243.30.img /mnt

3.修改镜像文件的grub 修改为直接启动sh
     kernel /vmlinuz-2.6.18-92.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet  single  #单用户模式进入

        initrd /initrd-2.6.18-92.el5.img

取消挂载,umount /mnt

4.重新启动虚拟机:
       xm create selboo
5.修改密码:
passwd root
修改密码后,关闭虚拟机。
6.再次挂载镜像后,去除grub中  single 这句话。
7.重新启动虚拟机!OK

也可以直接挂在 跟 "/" 修改 /etc/shadow 即可



具体执行 virsh edit 虚拟机名 找到 虚拟机的镜像文件位置 ,即 img的位置



<domain type='xen' id='1'>

  <name>IM-TJ01-175.207</name>

  <uuid>b39f7d38-cb87-ac63-728e-56d1eb90a763</uuid>

  <memory>4096000</memory>

  <currentMemory>4096000</currentMemory>

  <vcpu>4</vcpu>

  <bootloader>/usr/bin/pygrub</bootloader>

  <bootloader_args>-q</bootloader_args>

  <os>

    <type>linux</type>

  </os>

  <clock offset='utc'/>

  <on_poweroff>destroy</on_poweroff>

  <on_reboot>restart</on_reboot>

  <on_crash>restart</on_crash>

  <devices>

    <disk type='file' device='disk'>

      <driver name='file'/>

      <source file=''/>

      <target dev='xvda' bus='xen'/>

    </disk>

    <interface type='bridge'>

      <mac address='00:16:3e:06:7a:d9'/>

      <source bridge='xenbr0'/>

      <script path='/etc/xen/scripts/vif-bridge'/>

      <target dev='vif1.0'/>

    </interface>

    <interface type='bridge'>

      <mac address='00:16:3e:63:a7:97'/>

      <source bridge='xenbr1'/>

      <script path='/etc/xen/scripts/vif-bridge'/>

      <target dev='vif1.1'/>

    </interface>

    <console type='pty'>

      <target port='0'/>

    </console>

 </devices>

</domain>  


1  首先关闭虚拟机  

 xm shutdown 虚拟机名字

2  挂载 

mount -o loop,offset=$((63*512)) /xen/hardDisk/IM-243.35.img /mnt


3  编辑启动文件 

   vim /mnt/grub/menu.lst

 

# grub.conf generated by anaconda

#

# Note that you do not have to rerun grub after making changes to this file

# NOTICE:  You have a /boot partition.  This means that

#          all kernel and initrd paths are relative to /boot/, eg.

#          root (hd0,0)

#          kernel /vmlinuz-version ro root=/dev/xvda3

#          initrd /initrd-version.img

#boot=/dev/xvda

default=0

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title Red Hat Enterprise Linux AS (2.6.9-78.ELxenU)

        root (hd0,0)

        kernel /vmlinuz-2.6.9-78.ELxenU ro root=LABEL=/  console=xvc0这里改为quiet single

        initrd /initrd-2.6.9-78.ELxenU.img


将 

 ,保存退出 

   卸载                      umount /mnt


4    进入到单用户模式            xm start 虚拟机 -c


5  修改root密码 passwd root 


6  exit ,再关闭虚拟机 ---》挂载 ------》编辑启动文件  把 quiet single 改为 console=xvc0 保存退出------》卸载-------》再执行  xm start 虚拟机名称 -c










本文转自 chengxuyonghu 51CTO博客,原文链接:http://blog.51cto.com/6226001001/1545403,如需转载请自行联系原作者
目录
相关文章
|
6月前
|
Linux Shell 数据安全/隐私保护
超简单五步实现Linux虚拟机CentOS 7系统Root密码忘记重置
超简单五步实现Linux虚拟机CentOS 7系统Root密码忘记重置
814 0
|
11月前
|
Ubuntu Linux 网络安全
使用Kali Linux虚拟机破解WiFi密码的一波三折及详细操作步骤
使用Kali Linux虚拟机破解WiFi密码的一波三折及详细操作步骤
1961 0
使用Kali Linux虚拟机破解WiFi密码的一波三折及详细操作步骤
|
11月前
|
关系型数据库 MySQL 数据安全/隐私保护
虚拟机安装MYSQL后不知道密码打开 ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘
虚拟机安装MYSQL后不知道密码打开 ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘
150 0
|
11月前
|
运维 数据安全/隐私保护 虚拟化
运维小笔记:Windows-VMWare 虚拟机密码移除
本文介绍一种使用大白菜 PE 系统内置的密码移除工具,通过加载到 VMWare 虚拟机上,移除虚拟机密码的方法
408 0
|
数据安全/隐私保护 Windows
Paralles Desktop 修改虚拟机用户密码
使用其提供的命令工具修改用户密码
260 0
|
XML 安全 Linux
kvm虚拟机管理之一(磁盘压缩,用户密码重设,快照建立)
kvm虚拟机管理之一(磁盘压缩,用户密码重设,快照建立)
444 0
|
Linux 数据安全/隐私保护
五分钟学会虚拟机centos 7忘记root密码如何解决(你想要什么,不要等人送)
五分钟学会虚拟机centos 7忘记root密码如何解决(你想要什么,不要等人送)
419 0
五分钟学会虚拟机centos 7忘记root密码如何解决(你想要什么,不要等人送)
|
数据安全/隐私保护
两分钟学会虚拟机centos6忘记root密码如何解决(你得离开,我才能自由)
两分钟学会虚拟机centos6忘记root密码如何解决(你得离开,我才能自由)
405 0
两分钟学会虚拟机centos6忘记root密码如何解决(你得离开,我才能自由)

热门文章

最新文章