Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
|
4c63f728aa | ||
|
aac8291219 |
2 changed files with 33 additions and 25 deletions
|
@ -12,6 +12,14 @@ Other than that, I've created this repository to document how patching out verit
|
||||||
|
|
||||||
An explanation of how the script works can be found [here](https://github.com/WessellUrdata/vbmeta-disable-verification/wiki/Explanation:-How-patching-vbmeta-works).
|
An explanation of how the script works can be found [here](https://github.com/WessellUrdata/vbmeta-disable-verification/wiki/Explanation:-How-patching-vbmeta-works).
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Download the script from [Releases](https://github.com/WessellUrdata/vbmeta-disable-verification/releases).
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ python ./bvqc3.py <filename>
|
||||||
|
```
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
Credits to [@libxzr](https://github.com/libxzr) for creating the [original repo](https://github.com/libxzr/vbmeta-disable-verification) and [the blog post about patching vbmeta.img](https://blog.xzr.moe/archives/226/).
|
Credits to [@libxzr](https://github.com/libxzr) for creating the [original repo](https://github.com/libxzr/vbmeta-disable-verification) and [the blog post about patching vbmeta.img](https://blog.xzr.moe/archives/226/).
|
||||||
|
|
|
@ -10,35 +10,35 @@ FLAGS_OFFSET = 123
|
||||||
FLAGS_TO_SET = b'\x03'
|
FLAGS_TO_SET = b'\x03'
|
||||||
|
|
||||||
|
|
||||||
### main program
|
if __name__ == "__main__":
|
||||||
|
|
||||||
# if an argument is not provided
|
# if an argument is not provided
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
sys.exit("Usage: python ./" + os.path.basename(__file__) + " <vbmeta-image>")
|
sys.exit("Usage: python ./" + os.path.basename(__file__) + " <vbmeta-image>")
|
||||||
|
|
||||||
# try reading the file with read/write to make sure it exists
|
# try reading the file with read/write to make sure it exists
|
||||||
FILE = sys.argv[1]
|
FILE = sys.argv[1]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fd = os.open(FILE, os.O_RDWR)
|
fd = os.open(FILE, os.O_RDWR)
|
||||||
except OSError:
|
except OSError:
|
||||||
sys.exit("Error reading file: " + FILE + ". File not modified. Exiting...")
|
sys.exit("Error reading file: " + FILE + ". File not modified. Exiting...")
|
||||||
|
|
||||||
# making sure it's a vbmeta image by reading the magic bytes at the start of the file
|
# making sure it's a vbmeta image by reading the magic bytes at the start of the file
|
||||||
magic = os.read(fd, AVB_MAGIC_LEN)
|
magic = os.read(fd, AVB_MAGIC_LEN)
|
||||||
|
|
||||||
if (magic != AVB_MAGIC):
|
if (magic != AVB_MAGIC):
|
||||||
fd.close()
|
fd.close()
|
||||||
sys.exit("Error: The provided image is not a valid vbmeta image. File not modified. Exiting...")
|
sys.exit("Error: The provided image is not a valid vbmeta image. File not modified. Exiting...")
|
||||||
|
|
||||||
# set the disable-verity and disable-verification flags at offset 123
|
# set the disable-verity and disable-verification flags at offset 123
|
||||||
try:
|
try:
|
||||||
os.lseek(fd, FLAGS_OFFSET, os.SEEK_SET)
|
os.lseek(fd, FLAGS_OFFSET, os.SEEK_SET)
|
||||||
os.write(fd, FLAGS_TO_SET)
|
os.write(fd, FLAGS_TO_SET)
|
||||||
except OSError:
|
except OSError:
|
||||||
fd.close()
|
fd.close()
|
||||||
sys.exit("Error: Failed when patching the vbmeta image. Exiting...")
|
sys.exit("Error: Failed when patching the vbmeta image. Exiting...")
|
||||||
|
|
||||||
# end of program
|
# end of program
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
print("Patching successful.")
|
print("Patching successful.")
|
Loading…
Add table
Reference in a new issue