Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing bios code/flashing the bios

I've spent a lot of time developing an operating system and working on my low level boot loader. But now I want to take some time off my operating system while not leaving the low-level environment and doing something involving security.

So I chose to build my own standard password utility following the pre-boot authentication scheme. Since I want the software to be at least a little portable I want it to use as little external support as is possible. I figured that I'd be best if I somehow managed to 'hook' into the bios somewhere between the self checks and the int 19 bootstrap from within a running real mode OS.

However finding information on how to modify the bios code proved to be impossible. I've found nothing on how to achieve the before mentioned. I have only found pages describing how to flash your bios.

Does anyone know how I can read/write bios code? Or can someone provide links to pages that describe this?

I know that it's not only possible to brick my device but it is also likely, I'm aware of the risk and willing to take it.

like image 549
Rick Avatar asked Aug 19 '11 14:08

Rick


People also ask

Is flashing BIOS the same as updating BIOS?

In order to update the BIOS, the software chip must be completely erased and updated with a flash utility; this is essentially the process known as “flashing the BIOS”. This is referred to as “flashing” because the BIOS code is stored in flash memory.

What does flashing the BIOS mean?

Flashing a BIOS merely means to update it, so you don't want to do this if you already have the most updated version of your BIOS. But how can you tell what you have? You can check the BIOS version you are running in one of the following ways: Click Windows+R to open the run box, type “msinfo32,” and hit Enter.

How do I flash the BIOS that won't boot?

Enter the BIOS screen by pressing the key specified by the manufacturer's instructions for a BIOS update as soon as the computer starts. F1 , F2 , Delete , F8 , Esc , or another key could be used. Start the update process based on your computer's model once you're on the BIOS panel.


3 Answers

Pinczakko's articles on BIOS reverse engineering are a great place to start looking at this. There was also a book published by the same author but it is now out of print.

I'm not sure if this approach is the best approach towards a secure boot, but the articles on this site are very detailed and should point you towards a method for modifying your BIOS firmware.

like image 184
Dion Avatar answered Oct 19 '22 15:10

Dion


I'm not really sure what you are trying to achieve, but:

The BIOS is completely hardware specific - each manufacturer will have their own mechanism for updating / flashing BIOS and so trying to come up with a portable mechanism for updating a BIOS is destined for failure. For example when using Bochs you "update" the BIOS by specifying a different BIOS ROM image.

If you want to modifty / write your own BIOS then its going to be completely specific to that hardware. Your best bet would be to start with something like Bochs as its open source - as you can take a look at the source code for the BIOS (and easily test / debug it) you stand a reasonable chance of understanding the BIOS code and modifying it into something that works, however I suspect this isn't what you are trying to do.

Why not just perform this authentication as your OS boots? If you want to protect the data then you should encrypt it and require that the user supply log in / supply the decryption key on startup.

like image 28
Justin Avatar answered Oct 19 '22 16:10

Justin


If you were thinking of working with "legacy" PC BIOS, I would dissuade you from trying for many of the reasons Justin mentioned: 1) legacy BIOS is PC vendor-specific; 2) it is closed source and proprietary; 3) there are no industry standards defining legacy BIOS interfaces for extending the system as you are trying to do.

On the other hand, if you have access to a UEFI-based BIOS PC, you may be able to write your own PEI/DXE driver(s) to implement such a feature. This will at least point you in the right direction:

http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=Welcome

Intel Press book on the topic: Beyond BIOS

Regarding the practicality of read/writing the BIOS, you'll need to identify the SPI part containg the BIOS and get a ROM burner. The SPI part may or may not be socketed; if it is not socketed, you'll need a soldering iron and be able to create a socket/header for the part. You obviously do not want to embark on this project with your primary computer system. Perhaps you could find an older system or a reference board.

like image 44
William Leara Avatar answered Oct 19 '22 16:10

William Leara