Jelajahi Sumber

读取crypto加密软件

Fury 2 tahun lalu
induk
melakukan
da6c8d8601
3 mengubah file dengan 78 tambahan dan 11647 penghapusan
  1. 1 11640
      package-lock.json
  2. 77 7
      src/pages/user_center/firmware/index.vue
  3. TEMPAT SAMPAH
      static/verify.bin

File diff ditekan karena terlalu besar
+ 1 - 11640
package-lock.json


+ 77 - 7
src/pages/user_center/firmware/index.vue

@@ -11,6 +11,8 @@
 import {getDeviceBySn} from "../../../requests/game";
 import game_store from "@/store/game";
 
+import CryptoJS from 'crypto-js'
+
 var $this;
 var FileSystemManager = wx.getFileSystemManager();
 export default {
@@ -22,6 +24,8 @@ export default {
       updateImageSavePath: "",
       software_version: "",
       model: "",
+      //解密行数下标
+      dec_index: 0
     }
   },
   methods: {
@@ -264,32 +268,68 @@ export default {
      * 读取更新文件
      */
     readUpdateFile() {
+      $this.readBinfile()
       FileSystemManager.readFile({
         filePath: $this.updateImageSavePath,
         success(res) {
           $this.AddContent("读取文件成功")
           let buffer_len = new Uint8Array(res.data).length
-          let $file_dec_index = 0;
+          // 读取信息
           for (let i = 0; i < buffer_len; i += 16) {
             let buffer = new Uint8Array(res.data, i, 16);
-            console.log(buffer)
             if (i == 0) {
               //读取第一行信息 并返回 文件解密下标
-              $file_dec_index = $this.getUpdateHeader0(buffer)
+              $this.dec_index = $this.getUpdateHeader0(buffer)
+              $this.AddContent(`解密指定行:${$this.dec_index}`)
+              console.log(`解密指定行:${$this.dec_index}`)
             }
-            if (i == 1*16) {
+            if (i == 1 * 16) {
               for (let j = 0; j < buffer.length; j++) {
                 $this.software_version += String.fromCharCode(buffer[j])
               }
               $this.AddContent(`软件版本:${$this.software_version}`)
+              console.log(`软件版本:${$this.software_version}`)
             }
-            if (i == 2*16) {
+            if (i == 2 * 16) {
               for (let j = 0; j < buffer.length; j++) {
                 $this.model += String.fromCharCode(buffer[j])
               }
-              $this.AddContent(`软件版本:${$this.model}`)
+              $this.model = $this.model.trim()
+              console.log(`模型:${$this.model}`)
+              $this.AddContent(`模型:${$this.model}`)
             }
-            if(i==5*16){
+            if (i == $this.dec_index * 16) {
+              // 解密
+              let aes_pr_key = [
+                0x31,
+                0x88,
+                0x73,
+                0xc6,
+                0x8c,
+                0x73,
+                0x91,
+                0x36,
+                0x89,
+                0xa8,
+                0xc1,
+                0x91,
+                0x32,
+                0x88,
+                0x92,
+                0x36,
+              ];
+              let aes_iv = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
+              buffer = buffer.toString().replaceAll(',','')
+              aes_pr_key = aes_pr_key.toString().replaceAll(',','')
+              aes_iv = aes_iv.toString().replaceAll(',','')
+              console.log("buffer:"+buffer)
+              console.log("aes_pr_key:"+aes_pr_key)
+              console.log("aes_iv:"+aes_iv)
+              let decrypt = CryptoJS.AES.decrypt(buffer, aes_pr_key, {
+                iv: aes_iv,
+                padding: CryptoJS.pad.NoPadding
+              })
+              console.log("decrypt_str:" + decrypt)
               break;
             }
           }
@@ -342,6 +382,36 @@ export default {
       let file_total_size = payload_len + parseInt(update_offset, 16)
       $this.AddContent(`文件总长度:${file_total_size}`)
       return update_offset;
+    },
+    readBinfile() {
+      wx.downloadFile({
+        url: 'https://vs.shuimuai.com/ble/verify.bin', //仅为示例,并非真实的资源
+        success(res) {
+          // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
+          if (res.statusCode === 200) {
+            //将临时文件保存到用户文件路径下
+            FileSystemManager.saveFile({
+              tempFilePath: res.tempFilePath,
+              filePath: `${wx.env.USER_DATA_PATH}/verify.bin`,
+              success(res) {
+                FileSystemManager.readFile({
+                  encoding: "hex",
+                  filePath: res.savedFilePath,
+                  success(res) {
+                    console.log(res)
+                  },
+                  fail(err) {
+                    console.log(err)
+                  }
+                });
+              }, fail(err) {
+                console.log(err)
+              }
+            })
+          }
+        }
+      })
+
     }
   },
   created() {

TEMPAT SAMPAH
static/verify.bin


Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini