Thursday, 21 April 2016

E2B v1.80h Beta available

A few changes in 1.80h (g had a bug!):

1. FASTLOAD can now be used with $$$$CONFIG .mnu files (\_ISO\e2b\grub\menu.lst changed).

2. I have added the \_ISO\e2b\grub\checkdate.g4b batch file. It can be used in a MyE2B.cfg batch file as follows:

# set 14 day expiry date from 28th March 2016
call /_ISO/e2b/grub/checkdate.g4b 2016 03 28 14 SILENT
if not "%CHECKDAT%"=="OK" echo E2B EXPIRED! && halt
set CHECKDAT=

If used with a blank \_ISO\e2b\grub\SDATE.txt file (should be approx 1K in size) then you can set a time limit from the day that E2B was first booted as follows by just calling \_ISO\Expire.g4b:



/_ISO/Expire.g4b
=============

!BAT
# /%grub%/SDATE.txt must exist
# If called for first time, set the START DATE
# If called again, compare START DATE with CURRENT DATE

# set the number of days time limit here
set LIMIT=7

if not exist /%grub%/SDATE.txt pause ERROR: /%grub%/SDATE.txt does not exist && goto :EOF

set SDATE=
# get start date
cat /%grub%/SDATE.txt | set SDATE=
if not exist SDATE call :setdate

#echo call /%grub%/checkdate.g4b %SDATE:~0,4% %SDATE:~5,2% %SDATE:~8,2% %LIMIT% SILENT
call /%grub%/checkdate.g4b %SDATE:~0,4% %SDATE:~5,2% %SDATE:~8,2% %LIMIT% SILENT
:: Returns either CHECKDAT=OK  if within expiry date or  CHECKDAT=BAD if the expiry date has been exceeded

##  ACTION IF EXPIRED  ##
if not "%CHECKDAT%"=="OK" echo NUKE ME!
#example line
#if not "%CHECKDAT%"=="OK" partnew (hd0,0) 0 0 0 0 && partnew (hd0,1) 0 0 0 0 &&  halt

# tidy up
set SDATE=
set LIMIT=
set CHECKDAT=
goto :eof

:setdate
echo %@DATE% > /%grub%/SDATE.txt && goto :EOF

By using 
call /_ISO/Expire.g4b
in your MyE2B.cfg file, the user will only be allowed to use E2B for 7 days starting from the time he or she first booted it.

Note: don't forget that \_ISO\e2b\grub\SDATE.txt must be 1K of spaces to start with and must not contain a date!

Instead of just displaying 'NUKE ME!', you can change the line to be slightly more evil - e.g.:

# power off
if not "%CHECKDAT%"=="OK" halt

# reboot
if not "%CHECKDAT%"=="OK" reboot

# sleep for a long time!
if not "%CHECKDAT%"=="OK" call Fn.73 999999

# wipe partition tables (ptn 0 and 1) of USB drive and reboot
if not "%CHECKDAT%"=="OK" partnew (hd0,0) 0 0 0 0 && partnew (hd0,1) 0 0 0 0 && reboot

# wipe first 100K sectors on USB drive and power off
if not "%CHECKDAT%"=="OK" dd if=()/autounattend.xml of=(hd0)0+2000000 > nul && halt


The Expire.g4b and SDATE.txt files can be downloaded from the Other Files folder in the Alternate Downloads Areas.

Tip: for a simple way of clearing the SDATE.txt file before you 'release' your USB stick, you can use this grub4dos command:

if 1==2 echo never > /_ISO/SDATE.txt

It may seem as if this does not do anything, but in fact the redirection symbol > causes grub4dos to first wipe the file contents, but then the 'echo' command never runs because the 1==2 test returns false! In this way the file is filled with 00 bytes.