Jump to content


Byte Flipping?

  • Please log in to reply
1 reply to this topic

#1 DapperDeer



  • Members
  • 28 posts
    United States

Posted 15 September 2020 - 05:47 PM



I have a boot chain that I've asked about previously in this forum which you can read about here if you'd like.

The basic gist is that I was tasked with creating a secure boot chain for my work, the general flow of which happens as such:


Power on -> GRUB2 checks grubenv variable. If the variable is true, display Windows boot option. If false, display Linux boot option. -> (Variable = False): Linux performs integrity checks on the filesystem and sets the grubenv variable to true, then reboots -> GRUB2 checks grubenv variable (which is now True), displays Windows boot option -> boot to Windows.


However, the grubenv variable is a plaintext file. I'd like to change from this plaintext file to a byte located somewhere in the blank space of the drive. I am able to have Linux read/write this byte and in the thread linked, Wimb and Wonko the Sane were able to get Grub4Dos to perform this byte flipping, but I am having trouble getting GRUB2 to perform this same functionality.


GRUB2 CLI has the commands

read_byte and write_byte

which I believe are exactly what I need. However, the commands require an address of some sort. Via a HexEditor, I have the decimal and hexadecimal offsets of where the byte to flip is, but neither offset works as the address.


It should be noted that neither of the commands are listed in the GRUB2 manual and other than finding the source code for the commands, I've not found anything useful regarding either of them by simple Google searches.


Any help is greatly appreciated,



EDIT/PS: I was very conflicted on making a new thread vs. continuing my old one, but I figured since I am NOT using Grub4Dos in any capacity, it would be better served to make a new thread in this new subforum.

Edited by DapperDeer, 15 September 2020 - 05:48 PM.

#2 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 17 September 2020 - 08:52 AM

GRUB2 is a mess.


I wouldn't be surprised if those commands are there but are not enabled, but in this case I believe they are ONLY related to memory (not disk).


See also here:



The a1ve's verion has a dd that you can use, as I already told you (but maybe it is not suitable for your "secure boot" needs :unsure:):





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users