Thread: BuYS - Protecting the Grub
-
05-22-2011, 03:50 AM #11Network Security Administrator
- Join Date
- Apr 2011
- Location
- /india/ap/hyd
- Posts
- 98
- Thanks
- 1
- Thanked 84 Times in 37 Posts
Nope. The grub.cfg is not ment to edited. Because, grub.cfg is overwritten if you update, or you add/remove a kernel, or if you run update-grub. To over come the issue, you could use, custom file /etc/grub.d/40_custom in which you can place entries.For Grub2 we have to make changes in the grub.cfg file (wherever it is located), I think.
And, there are multiple files for configuration, like /etc/grub.d and /etc/default/grub(which is main file).
-
The Following User Says Thank You to Hackuin For This Useful Post:
abhaythehero (05-22-2011)
-
05-22-2011, 07:46 AM #12Network Security Administrator
- Join Date
- Apr 2011
- Location
- /india/ap/hyd
- Posts
- 98
- Thanks
- 1
- Thanked 84 Times in 37 Posts
@fb1:
Actually, booting to root shell/Recovery boot is actually, booting to a single-user mode/recovery mode, or maintenance mode(AIX). This is actually done by passing argument(single) to the kernel at boot time. This non specific of distribution. Its all about boot-loader (in our case GRUB).
As the saying goes, Boot time is a period of special vulnerability.
Lets see what happen when a system boot from Linux perspective ( People who know may ignore this post ).
When a computer is switched onn, the first thing happens is, it executes boot code that is stored in ROM. This berry boot code actually looks how to load and start the almighty KERNEL. Then, KERNEL probes the system's hardware and loads the first process that is init. However, filesystems are checked and mounted and also, services are started usually by the shell scripts processed by init so do they called as init scripts.
Solely boot loader is responsible for loading KERNEL, GRUB Legacy reads it configuration from /boot/grub/menu.lst or /boot/grub/grub.conf depends on distro in use, like, fedora uses, grub.conf where as Ubuntu/SUSE/Solaris uses menu.lst. The thing is both the files are similar only with slight difference.
Actually at boot time, KERNEL OPTIONS are very critical, like init=/bin/bash [Similar to single user mode, it just starts bash shell.
For example:
In RedHat or fedora, at Grub menu type letter "a", you will switch to grub append mode.
just append word "single" at the end.Code:grub append> ro root=/dev/abc/xyz efg quiet
You will get a root shell.Code:grub append> ro root=/dev/abc/xyz efg quiet single
On Solaris, at boot PROM just type, "boot -s" makes you boot at single-user mode.
On HP-UX, at prompt, type "boot pri isl" then, "hpux -iS /stand/vmunix" makes you boot at single-user mode.
On AIX, Just select maintenance mode from the boot menu, which makes you at root shell.
One thing must be noted is, it isn't persistent, I mean, when you edit/append something at boot time, they are non persistent, you must manually change kernel arguments in configuration file, like in grub.conf or menu.lst
@abhaythehero:
If you have multiple Operating systems, you must append the word "lock" on each entry after you have md5crypted.
On GRUB 2, The procedure is similar, just press "e" at grub menu and locate to "linux /boot/viml..... remove "quiet"/"splash" or replace it with "single"
~Hackuin
-
The Following 2 Users Say Thank You to Hackuin For This Useful Post:
abhaythehero (05-22-2011), Anant Shrivastava (06-01-2011)
-
05-22-2011, 10:21 AM #13Super Commando Dhruv


- Join Date
- Sep 2010
- Location
- Lucknow/Pune,India
- Posts
- 470
- Blog Entries
- 2
- Thanks
- 170
- Thanked 144 Times in 83 Posts
In the world of 0s and 1s, are you a zero or The One !
-
05-22-2011, 10:32 AM #14Super Commando Dhruv


- Join Date
- Sep 2010
- Location
- Lucknow/Pune,India
- Posts
- 470
- Blog Entries
- 2
- Thanks
- 170
- Thanked 144 Times in 83 Posts
@Hackuin Ohh .. I was wrong for grub.cfg. Thanks for correction

Yes, we have to change the /etc/grub.d/40_custom file ( in case of Debian derivatives like Ubuntu and Backtrack 5)
shamelessly copying from ubuntu forums :
sudo gedit /etc/grub.d/40_custom
and add the lines:
set superusers="user1"
# password_pbkdf2 user1 grub.pbkdf2.sha512.10000.biglongstring
password user1 unencryptedpasswordhere
where "user1" will be the user with permission to access the Grub2 command-line (or menu editing functions) and unencryptedpasswordhere will be the password required to access the Grub2 command-line. (The commented line is if a pbkdf2 encrypted password will be used).
Then, as usual:
sudo update-grubLast edited by abhaythehero; 05-22-2011 at 10:41 AM.
In the world of 0s and 1s, are you a zero or The One !
-
06-01-2011, 05:22 PM #15Security Researcher

- Join Date
- May 2011
- Location
- Pune, Maharashtra, India
- Posts
- 229
- Blog Entries
- 1
- Thanks
- 76
- Thanked 93 Times in 52 Posts
specifically for grub 1
you can try method listed here (the difference is even if you are using single user mode debian still asks for root password)
http://blog.anantshri.info/how-to-ch...ord-in-debian/
this i posted way back around 2007....
Also grub 2 is a lot more tricky affair. @Hackuin Thanks for provided correct details......
-
The Following User Says Thank You to Anant Shrivastava For This Useful Post:
abhaythehero (06-02-2011)



LinkBack URL
About LinkBacks



Reply With Quote
was it? I wasn't aware of it.

Poizon Web Exploiter 2.0
Yesterday, 10:34 PM in Tools & Scripts