Pnet和EVE镜像制作

制作一个新的Linux的qemu镜像

可能需要安装 KVM 镜像管理工具 libguestfs-tools,包含 guestfish 等

将Vulnhub靶场制作成qemu镜像

file Warzone2.ova

Warzone2.ova: POSIX tar archive

文件类型为 : POSIX tar archive

tar -xf Warzone2.ova
ls ./Warzone2

Warzone2.ovf
Warzone2-disk002.vmdk
Warzone2.mf

qemu-img convert -O qcow2 Warzone2-disk002.vmdk virtioa.qcow2
mkdir /opt/unetlab/addons/qemu/Vulnhub-Warzone2

模板文件内容

# Copyright (c) 2016, Andrea Dainese
# Copyright (c) 2018, Alain Degreffe
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of the UNetLab Ltd nor  the name of EVE-NG Ltd nor the
#       names of its contributors may be used to endorse or promote products
#       derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---
type: qemu
description: Vulnhub
name: Vulnhub
cpulimit: 1
icon: Server_WEB.png
cpu: 2
ram: 4096
ethernet: 1
eth_name:
- eth0
eth_format: eth{0}
console: vnc
shutdown: 1
qemu_arch: x86_64
qemu_version: 2.12.0
qemu_nic: virtio-net-pci
qemu_options: -machine type=pc,accel=kvm -vga virtio -usbdevice tablet -boot order=cd
...

qemu设备添加硬盘

在镜像所在目录创建新的硬盘

这样添加的硬盘有个缺点,当保存数据到该硬盘后,需要提交修改才能在其他 Node 中被访问,参考镜像制作过程

-f qcow2 指定创建格式 ,raw 格式的硬盘不支持快照

cd /opt/unetlab/addons/qemu/linux-test/
qemu-img create -f qcow2 virtiob.qcow2 10G

添加任意位置的虚拟磁盘镜像

镜像只需要是qemu支持的格式就行

qemu-img create -f qcow2 /opt/vdisk/data.qcow2 10G

添加多个光驱

先关闭需要添加光驱的节点,编辑 Node 的 QEMU custom options ,添加内容 : -drive file=/opt/vdisk/xxx.iso,index=0,media=cdrom

若镜像目录下已存在 cdrom.iso 那这个 iso 将会自动被挂载到 ide 接口的 2 通道上,其他新建的可使用类推的通道。