netboot:~# apt-get install dhcp3-server
netboot:~# mcedit /etc/dhcp3/dhcpd.conf
option domain-name-servers 192.168.1.1;
default-lease-time 86400;
max-lease-time 604800;
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.20 192.168.1.60;
filename "pxelinux.0";
next-server 192.168.1.13;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.1;
}
netboot:~# apt-get install tftpd-hpa
netboot:~# mcedit etc/default/tftpd-hpa
RUN_DAEMON="yes"
OPTIONS="-l -s /opt/vcrypt/boot"
netboot:~# apt-get install syslinux
netboot:~# mkdir -p /opt/vcrypt/boot
netboot:~# cp /usr/lib/syslinux/pxelinux.0 /opt/vcrypt/boot/
netboot:~# mkdir /opt/vcrypt/boot/pxelinux.cfg
netboot:~# touch /opt/vcrypt/boot/pxelinux.cfg/default
netboot:~# mcedit /opt/vcrypt/boot/pxelinux.cfg/default
DEFAULT vcrypt
TIMEOUT 30
PROMPT 1
LABEL vcrypt
KERNEL vmlinuz
APPEND root=/dev/nfs nfsroot=192.168.1.13:/opt/vcrypt/ initrd=initrd.img ip=192.168.1.14::192.168.1.1:255.255.255.0:
netboot:~# apt-get install nfs-kernel-server nfs-common portmap
netboot:~# mcedit /etc/exports
/opt/vcrypt 192.168.1.14(rw,no_root_squash,async,no_subtree_check)
netboot:~# invoke-rc.d nfs-kernel-server reload
netboot:~# apt-get install debootstrap
netboot:~#debootstrap --arch i386 lenny /opt/vcrypt/ http://ftp.us.debian.org/debian
netboot:~# LANG=C chroot /opt/vcrypt/ /bin/bash
netboot:/# nano /etc/default/rcS
TMPTIME=0
SULOGIN=no
DELAYLOGIN=no
UTC=no
VERBOSE=no
FSCKFIX=no
RAMRUN=no
RAMLOCK=no
netboot:/# dpkg-reconfigure tzdata
netboot:/# nano /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.14
netmask 255.255.255.0
gateway 192.168.1.1
netboot:/# nano /etc/resolv.conf
nameserver 192.168.1.1
netboot:/# echo cryptserv > /etc/hostname
netboot:/# apt-get update
netboot:/# apt-get install locales
netboot:/# dpkg-reconfigure locales
netboot:/# touch /etc/kernel-img.conf
netboot:/# nano /etc/kernel-img.conf
do_symlinks = yes
relative_links = yes
do_bootloader = no
do_bootfloppy = no
do_initrd = yes
link_in_boot = no
netboot:/# apt-get install linux-image-2.6.26-2-686
netboot:/boot# nano /etc/initramfs-tools/initramfs.conf
MODULES=netboot
BUSYBOX=y
KEYMAP=n
BOOT=nfs
DEVICE=eth0
NFSROOT=auto
netboot:/# update-initramfs -v -c -k `uname -r` -d
netboot:/# update-initramfs -v -c -k `uname -r`
netboot:/# cd /boot
netboot:/boot# ln -s vmlinuz-2.6.26-2-686 vmlinuz
netboot:/boot# ln -s initrd.img-2.6.26-2-686 initrd.img
netboot:/# apt-get install cryptsetup hashalot
netboot:/# passwd
netboot:/# apt-get install openssh-server
h1g@h1g-laptop:~$ ssh -l root 192.168.1.14
cryptserv:~# dd if=/dev/urandom of=/dev/sda
cryptserv:~# cryptsetup --verbose --verify-passphrase luksFormat /dev/sda
cryptserv:~# cryptsetup luksOpen /dev/sda vcrypt
cryptserv:~# mkfs.ext3 -j -m 1 -O dir_index,filetype,sparse_super /dev/mapper/vcrypt
cryptserv:~# mkdir /home/crypt
cryptserv:~# mount /dev/mapper/vcrypt /home/crypt/
cryptserv:~# echo "deb http://download.virtualbox.org/virtualbox/debian lenny non-free" >> /etc/apt/sources.list
cryptserv:~# wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | apt-key add -
cryptserv:~# apt-get install virtualbox-3.2
cryptserv:~# echo "deb http://download.virtualbox.org/virtualbox/debian lenny non-free" >> /etc/apt/sources.list
cryptserv:~# wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | apt-key add -
cryptserv:~# apt-get install virtualbox-3.2
cryptserv:~# echo "deb http://download.virtualbox.org/virtualbox/debian lenny non-free" >> /etc/apt/sources.list
cryptserv:~# wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | apt-key add -
cryptserv:~# apt-get install virtualbox-3.2
cryptserv:~# echo "deb http://download.virtualbox.org/virtualbox/debian lenny non-free" >> /etc/apt/sources.list
cryptserv:~# wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | apt-key add -
cryptserv:~# apt-get install virtualbox-3.2
cryptserv:~# VBoxManage createvm --name bender1 --ostype Windows2003 —register
cryptserv:~# VBoxManage modifyvm bender1 --memory 1024 --floppy disabled --audio none --nic1 bridged --bridgeadapter1 eth0 --vram 12 --accelerate3d off --boot1 disk --acpi on --cableconnected1 on --usb off --vrdp on --vrdpport 3389 --vtxvpid on
cryptserv:~# VBoxManage storagectl bender1 --name "IDE Controller" --add ide
cryptserv:~# VBoxManage createhd --filename /home/crypt/bender1.vdi --size 20480 --register
cryptserv:~# VBoxManage storageattach bender1 --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium /home/crypt/bender1.vdi
cryptserv:~# VBoxManage storageattach bender1 --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive —medium /home/crypt/some_legal_windows_image.iso
cryptserv:~# VBoxManage modifyvm bender1 --boot1 dvd
cryptserv:~# VBoxManage startvm bender1 --type vrdp
h1g@h1g-laptop:~$ rdesktop -k en-us 192.168.1.14:3389
cryptserv:~# VBoxManage controlvm bender1 acpipowerbutton
cryptserv:~# VBoxManage modifyvm bender1 --boot1 disk
cryptserv:~# cat start_vm.sh
- #! / bin / bash
- / sbin / cryptsetup luksOpen / dev / sda vcrypt && mount / dev / mapper / vcrypt / home / crypt && / usr / bin / VBoxManage startvm bender1 - type vrdp
cryptserv:~# cat shutdown_vm.sh
- #! / bin / bash
- / usr / bin / VBoxManage controlvm bender1 acpipowerbutton
- while [`ps aux | grep " bender1 --startvm " | grep -v grep | wc -l` -ne 0 ]
- do
- echo "VM is poweroff. Wait plz"
- sleep 1
- done
- umount / home / crypt && / sbin / cryptsetup luksClose / dev / mapper / vcrype
Source: https://habr.com/ru/post/88385/