Awesome
Awesome

Reputation: 47

run script before boot options apears

Do any of you guys know if it's possible to run a script before i get the option to enter bios and before OS boots? Example: i want to secure my pc with a script that requires me to press certain keys before the screen where i have the boot options apears (because passwords can be cracked, even bios, i don't trust them)

ps: i have been looking into this problem for a couple of hours and i couldn't find anything :(. i just need to know what language to use and where to insert the script.

thanks in advance!

Upvotes: 1

Views: 1452

Answers (1)

Piotr Król
Piotr Król

Reputation: 3450

It is possible and not so hard when system use UEFI BIOS, which is true for almost all modern systems.

Below solution is not exactly what you want but it is closest to what you can get.

What have to be done:

  1. Write UEFI application in C that will wait until correct key combination pressed. If incorrect combination pressed then reboot or wait for another try.
  2. Affect boot order using bcfg UEFI Shell command. You should use bcfg to put your application on top of boot order, so while device is booting first entry would be your application and not OS. How to use bcfg you can read here, page 83

Couple notes:

  • Biggest problem with this approach is that someone can enter BIOS setup and change order so application will not be executed, but this can be solved with securing setup menu with password.
  • UEFI application have to be stored somewhere. It depends on storage medium, but application should be on UEFI readable partition, if someone will disconnect storage, then boot option will be skipped and protection will not work.
  • Most UEFI BIOS vendors disable bcfg command since it can be dangerous, but this can be worked around by booting UEFI Shell from USB stick, if you have that option.
  • Adding and removing devices in system affect boot order. You should test and see how adding various devices affect boot order in your system. Some additional configuration maybe needed in BIOS setup menu to make sure no new device will be probed before your application.

I wrote blog post about UEFI application development in emulated environment, which you should consider instead of experimenting on real hardware.

Upvotes: 1

Related Questions