Jump to content











Photo
- - - - -

Help with menu.lst


  • Please log in to reply
8 replies to this topic

#1 forsajt

forsajt
  • Members
  • 2 posts
  •  
    Hungary

Posted 12 March 2015 - 02:28 PM

Hi guys. I'm having hard time trying to understand the twisted semantics of grub4dos' menu.lst. Could you please help me a bit?

I have 3 partitions on my HD (I have installed grub4dos as default bootmgr entry on active partition (hd0,0)):

hd0,0 - system reserved, active
hd0,1 - windows
hd0,2 - windows

Now what I'm trying to achieve is:

1. Do not display any menus, instead display blank screen with text "Please enter password: ".

2. Take action as described by following pseudocode:

if(password==123456)
{
    if(not hidden(partition 2)) hide partition 2
    if(hidden(partition 1)) unhide partition 1
    boot partition 1
}
else
{
    if(not hidden(partition 1)) hide partition 1
    if(hidden(partition 2)) unhide partition 2
    boot partition 2
}

3. Optionally:
-Set 10 sec timeout (i.e if no key is pressed, then do the second part).
-If ESC key is pressed, then do the second part.


Is it even possible to configure grub4dos this way? Thanks for your time.


Edited by forsajt, 12 March 2015 - 02:32 PM.


#2 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 12 March 2015 - 04:22 PM

Maybe you want to look at grub4dos batch language? :unsure:

Essentially it is very similar to "common" NT/2K/XP/Later CMD.EXE batch, you could get (or congfigure) one of the grub4dos "silent" mods and have it run the batch.

 

:duff:

Wonko



#3 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 12 March 2015 - 06:35 PM

http://www.rmprepusb...c-grub4dos-menu

http://www.rmprepusb...orials/grub4dos

 

 

This may go some way - note that it assumes that the two Windows installs are separate and do not use the same BCD.

i.e. each Windows partition has \bootmgr and \boot\BCD

 

menu.lst

=======

clear
# set wanted password
set mypwd=123456
set ask=
# ask a question and get an answer into ask variable
set /p:10 ask=Please enter password:
if "%ask%"=="%mypwd%" hide (hd0,1) && unhide (hd0,2) && root (hd0,2) && chainloader (hd0,2) && boot
hide (hd0,2) && unhide (hd0,1) && root (hd0,1) && chainloader (hd0,1) && boot


#4 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 12 March 2015 - 08:15 PM

8 bytes saved ;):

 

if "%ask%"=="%mypwd%" hide (hd0,1) && unhide (hd0,2) && root (hd0,2) && chainloader +1 && boot
hide (hd0,2) && unhide (hd0,1) && root (hd0,1) && chainloader +1 && boot

 

 

Now, more seriously, isn't there a way through one of the "silent" builds and with some of the usual trickery to make use of the password feature of grub4dos? :unsure:

 (not that it is actually "secure", but at least it is not "plain text")

 

 

:duff:

Wonko



#5 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 12 March 2015 - 08:29 PM

There is no timeout on the grub4dos password. :dubbio:

Things can be done with the code sample to improve it - e.g. use a black text on black background, redirect to nul, encrypt the whole menu.lst file, etc. But first lets see if the sample works and works the way the 'customer' wants...



#6 forsajt

forsajt
  • Members
  • 2 posts
  •  
    Hungary

Posted 12 March 2015 - 11:11 PM

Thanks guys, it seems this is just what I wanted. I have a couple of questions though.
 
What is root command? Do I have to use it? Can't I just issue chainloader (hd0,1)/bootmgr instead?

How about muting the debug messages?  :)

Edited by forsajt, 13 March 2015 - 12:11 AM.


#7 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 13 March 2015 - 09:06 AM

root command sets the root partition. It may not be needed but it should not hurt to use it.

If you mean muting the grub4dos startup messages, see the link I gave previously

http://www.rmprepusb...essages-silent-



#8 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 13 March 2015 - 10:21 AM

If you don't want anyone to see what you have typed for the password, use

set mypwd=123456
set ask=
color standard 11
# ask a question and get an answer into ask variable
echo Please enter password :
# set text color to black (same as background colour)
color standard 0
set /p:10 ask=xx > nul
# set text colour to bright cyan = 8 + 3
color standard 11


#9 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 13 March 2015 - 02:36 PM

I was thinking more *along the lines of* :unsure: (set aside temporarily the "silent" version of grub4dos that will be used in the final form) of:
menu.lst:
 
 





timeout 0
default 0

title
echo Imagine this to be just "Enter password:" centered
serial --unit=0 --speed=115200
terminal --silent serial console
password goofy || clear && configfile /normal.lst
echo This is protected
pause

normal.lst:
 



timeout 5
default 0
title Normal
echo This is normal
pause

:duff:
Wonko






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users