# Place ISO in \_ISO\MAINMENU\MNU or \_ISO\LINUX\MNU (and this .mnu file too)
# http://rmprepusb.blogspot.co.uk/2014/05/add-kali-linux-v107-luks-encrypted.html
# DOES NOT WORK UNDER NORMAL VM!!!
# IMPORTANT: you MUST run WinContig (Ctrl+F2) before booting E2B.

#    For persistence: (File Name=kali32-rw or kali64-rw,  Volume Name=persistence)
# 1. Click 'Create ext2 fs' in RMPrepUSB
# 2. Set the FILENAME to kali32-rw or kali64-rw
# 3. Set the VOLUME LABEL to persistence  <------ VERY IMPORTANT
# 4. Set amount of space you would like allowed to persist

#The persistent 'volume' needs the persistence.conf file in it!
# Boot to kali (do NOT use the Kali Encrypted Persistence menu entry!) and then type following 5 lines to enable persistence - then reboot

#    mkdir /mnt/usb
#    ls /dev/                           (to see which is the USB device - normally sdb)
#    mount /dev/sdb3 /mnt/usb           (will always be sdx3 for 3rd partition)
#    echo "/ union" > /mnt/usb/persistence.conf
#    umount /mnt/usb
#
# Now reboot and use Persistence menu entry

# OR...
# FOR LUKS Encryption use
#    cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb3
#    cryptsetup luksOpen /dev/sdb3 my_usb
#    mkfs.ext3 -L persistence /dev/mapper/my_usb
#    e2label /dev/mapper/my_usb persistence
#    mkdir -p /mnt/my_usb
#    mount /dev/mapper/my_usb /mnt/my_usb
#    echo "/ union" > /mnt/my_usb/persistence.conf
#    umount /dev/mapper/my_usb
#    cryptsetup luksClose /dev/mapper/my_usb

# Now reboot and choose Kali Encrypted Persistence menu entry if LUKS used

iftitle [if exist $HOME$/kali-linux-1.0.7-i386.iso] Kali 1.0.7 x86-32 Persistent\n 32-bit using /kali32-rw persistence file

set ISO=$HOME$/kali-linux-1.0.7-i386.iso
set PERS=/kali32-rw

if "%E2BDEV%"=="" set E2BDEV=hd0 && pause E2BDEV forced to hd0!
if exist CD echo WARNING: Cannot use partnew command! && pause && configfile (bd)/menu.lst
#enable parttype output
partnew (%E2BDEV%,3) 0x0 %ISO%
# make empty table entry in 3rd position in ptn table
debug 1
parttype (%E2BDEV%,2) | set check=
debug off
set check=%check:~-5,4%
if "%check%"=="0x00" partnew (%E2BDEV%,2) 0 0 0
if not "%check%"=="0x00" echo WARNING: PTN TABLE 3 IS ALREADY IN USE! && pause
debug 1
if not exist %PERS% echo WARNING: %PERS% persistence file not found! && pause
errorcheck off
if "%check%"=="0x00" partnew (%E2BDEV%,2) 0x0 %PERS%
errorcheck on
/%grub%/QRUN.g4b %ISO%
boot

iftitle [if exist $HOME$/kali-linux-1.0.7-amd64.iso] Kali 1.0.7 x86-64 Persistent\n Kali 64-bit using /kali64-rw persistence file

set ISO=$HOME$/kali-linux-1.0.7-amd64.iso
set PERS=/kali64-rw

if "%E2BDEV%"=="" set E2BDEV=hd0 && pause E2BDEV forced to hd0!
if exist CD echo WARNING: Cannot use partnew command! && pause && configfile (bd)/menu.lst
#enable parttype output
partnew (%E2BDEV%,3) 0x0 %ISO%
# make empty table entry in 3rd position in ptn table
debug 1
parttype (%E2BDEV%,2) | set check=
debug off
set check=%check:~-5,4%
if "%check%"=="0x00" partnew (%E2BDEV%,2) 0 0 0
if not "%check%"=="0x00" echo WARNING: PTN TABLE 3 IS ALREADY IN USE! && pause
debug 1
if not exist %PERS% echo WARNING: %PERS% persistence file not found! && pause
errorcheck off
if "%check%"=="0x00" partnew (%E2BDEV%,2) 0x0 %PERS%
errorcheck on
/%grub%/QRUN.g4b %ISO%
boot


