From 2c599026430298fa19a54da39541256ee4fb098e Mon Sep 17 00:00:00 2001 From: affggh <879632264@qq.com> Date: Fri, 1 Nov 2024 11:09:06 +0800 Subject: [PATCH] Add vbmeta verity disable page --- web/index.html | 20 ++- web/vbmeta/index.html | 235 ++++++++++++++++++++++++++++ web/vbmeta/vbmeta_disable_verity.js | 41 +++++ 3 files changed, 289 insertions(+), 7 deletions(-) create mode 100644 web/vbmeta/index.html create mode 100644 web/vbmeta/vbmeta_disable_verity.js diff --git a/web/index.html b/web/index.html index b05b70c..843e4c0 100644 --- a/web/index.html +++ b/web/index.html @@ -1,5 +1,6 @@ + @@ -82,8 +83,10 @@ } + - - + + \ No newline at end of file diff --git a/web/vbmeta/index.html b/web/vbmeta/index.html new file mode 100644 index 0000000..8837a20 --- /dev/null +++ b/web/vbmeta/index.html @@ -0,0 +1,235 @@ + + + + + + + 修改VBMETA校验 + + + + + +
+

拖入或选择Vbmeta文件

+ +
+

将文件拖到这里,或点击选择文件

+
+
+
+ +
+

选项

+
+ + +
+
+ + +
+ +
+ + + + + \ No newline at end of file diff --git a/web/vbmeta/vbmeta_disable_verity.js b/web/vbmeta/vbmeta_disable_verity.js new file mode 100644 index 0000000..7842082 --- /dev/null +++ b/web/vbmeta/vbmeta_disable_verity.js @@ -0,0 +1,41 @@ +//@ts-check + +const AVB_MAGIC = "AVB0"; +const AVB_MAGIC_LEN = 4; +const FLAGS_OFFSET = 123; +const FLAG_DISABLE_VERITY = 0x01; +const FLAG_DISABLE_VERIFICATION = 0x02; + +function convertString(array) { + const decoder = new TextDecoder('utf-8'); + return decoder.decode(array); +} + +// arraybuffer disable_verity:bool disable_verification:bool +function ParseVbmetaData(vbmetaData, disable_verity, disable_verification) { + const view = new Uint8Array(vbmetaData); + + const magic = convertString(view.subarray(0, AVB_MAGIC_LEN)); + if (magic != AVB_MAGIC) { + throw new Error("Invalid format, this is not a vbmeta image"); + } + + console.log("Origin flag:", view[FLAGS_OFFSET]); + console.log("DISABLE_VERITY:", Boolean(view[FLAGS_OFFSET] & FLAG_DISABLE_VERITY)); + console.log("DISABLE_VERIFICATION:", Boolean(view[FLAGS_OFFSET] & FLAG_DISABLE_VERIFICATION)); + + let flag = 0; + if (disable_verity) { + flag |= FLAG_DISABLE_VERITY + } + + if (disable_verification) { + flag |= FLAG_DISABLE_VERIFICATION + } + + view[FLAGS_OFFSET] = flag; + + console.log("Edited flag:", view[FLAGS_OFFSET]); + console.log("DISABLE_VERITY:", Boolean(view[FLAGS_OFFSET] & FLAG_DISABLE_VERITY)); + console.log("DISABLE_VERIFICATION:", Boolean(view[FLAGS_OFFSET] & FLAG_DISABLE_VERIFICATION)); +}; \ No newline at end of file