請選擇 進入手機版 | 繼續訪問電腦版

米柚愛好者論壇

 找回密碼
 立即註冊
查看: 60|回覆: 0

[ROM] 知道小米版本號如何取得檔案下載網址的方式

[複製鏈接]

14

主題

1

好友

1172

積分

大二

Rank: 4Rank: 4

發表於 2017-11-26 11:28:14 |顯示全部樓層
其他
產品名稱: -
原作來自 XDA: https://forum.xda-developers.com ... xiaomi-ota-t3691612
方法一不能用了, 不過方法二仍可以使用, 而且... 是目前的更新機制, 應該不容易改... 也許一直能用下去.

不知道為什麼, 原作者的 python 程式碼在我的機器上無法正常執行, 在 decrypt 那一個部份一直無法成功.
所以... 就用 php 改寫一下.
  1. <?php

  2. $cipher = 'rijndael-128';
  3. $mode = 'cbc';
  4. $miui_key = 'miuiotavalided11';
  5. $miui_iv = '0102030405060708';

  6. function miui_decrypt($s)
  7. {
  8.     global $cipher, $mode, $miui_key, $miui_iv;

  9.     $td = mcrypt_module_open($cipher, '', $mode, '');
  10.     mcrypt_generic_init($td, $miui_key, $miui_iv);
  11.     $decrypted = mdecrypt_generic($td, base64_decode($s));
  12.     mcrypt_generic_deinit($td);
  13.     mcrypt_module_close($td);
  14.     $pos = strrpos($decrypted, '}');
  15.     if ($pos !== false)
  16.         return substr($decrypted, 0, $pos + 1);
  17.     return $decrypted;
  18. }

  19. function miui_encrypt($s)
  20. {
  21.     global $cipher, $mode, $miui_key, $miui_iv;

  22.     $td = mcrypt_module_open($cipher, '', $mode, '');
  23.     mcrypt_generic_init($td, $miui_key, $miui_iv);
  24.     $bs = mcrypt_get_block_size($cipher, $mode);
  25.     $n = $bs - (strlen($s) % $bs);
  26.     while ($bs - (strlen($s) % $bs) != $bs)
  27.         $s .= chr($n);
  28.     $encrypted = base64_encode(mcrypt_generic($td, $s));
  29.     mcrypt_generic_deinit($td);
  30.     mcrypt_module_close($td);
  31.     return $encrypted;
  32. }

  33. $checkurl = 'http://update.miui.com/updates/miotaV3.php';

  34. $device_data = array(
  35.     "a" => "0", # Don't know what this is.
  36.     "c" => "7.0", # Same as 'c' above, it's the Android version.
  37.     "b" => "F", # Same as above, 'X' for weekly build.
  38.     "d" => "mido_global", # The device name, same as above, chiron for Chinese, chiron_global for global.
  39.     "g" => "00000000000000000000000000000000", # This seems to be the android_id of the device. Maybe encoded somehow.
  40.     "cts" => "0", # I don't know what this is.
  41.     "i" => "0000000000000000000000000000000000000000000000000000000000000000", # This seems to be the imei of the device, obviously encoded somehow.
  42.     "isR" => "0", # I don't know what this is.
  43.     "f" => "1", # I don't know what this is.
  44.     "l" => "en_US", # The locale.
  45.     "n" => "",  # I don't know what this parameter is
  46.     "sys" => "0", # I don't know what this is.
  47.     "p" => "msm8953", # The chipset
  48.     "unlock" => "1",  # 1 means bootloader is unlocked. 0 means locked.
  49.     "r" => "CN", # I don't know what this is, maybe region of device?
  50.     "sn" => "0x00000000", # Probably the serial number of the device, maybe encoded somehow.
  51.     "v" => "MIUI-V9.0.5.0.NCFMIEI", # The version of MIUI installed.
  52.     //"v" => "MIUI-V8.5.8.0.NCFMIED",
  53.     "bv" => "9", # I don't know what this is.
  54.     "id" => "", # I don't' know what this is.
  55. );

  56. $js = json_encode($device_data);

  57. $postdata = "q=".urlencode(miui_encrypt($js))."&t=&s=1";

  58. $curl = curl_init();
  59. curl_setopt($curl, CURLOPT_URL, $checkurl);
  60. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  61. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
  62. curl_setopt($curl, CURLOPT_HEADER, 0);
  63. curl_setopt($curl, CURLOPT_POST, 1);
  64. curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
  65. $data = curl_exec($curl);
  66. if ($data === false) {
  67.     echo "*** curl_exec() failed: ".curl_errno($curl)." => ".curl_error($curl)."\n";
  68.     curl_close($curl);
  69.     exit;
  70. }

  71. $r = miui_decrypt($data);
  72. $result = json_decode($r);
  73. print_r($result);

  74. exit;
複製代碼
上面那個是用紅米 Note4X 國際版為例子. 找 MIUI-V9.0.5.0.NCFMIEI 的升級版本.
如果要找其他的機型, 請改 c, d, v 這三個值, c 是 Android 版本, d 是機型代碼 (國際版加上 _global), v 是版本名稱.

會列出該版本之後的版本 (如果是最新的, 就會列出目前這個版本).
所以... 我們就可以取得 V9.0.5.0.NCFMIEI 這個版本的檔名: miui_HMNote4XGlobal_V9.0.5.0.NCFMIEI_d6176de291_7.0.zip

有檔名之後, 小米的路徑規則是 http://bigota.d.miui.com/版本/檔案
所以下載的網址就是 http://bigota.d.miui.com/V9.0.5. ... _d6176de291_7.0.zip


您需要登錄後才可以回帖 登錄 | 立即註冊

手機版|米柚愛好者論壇

GMT+8, 2017-12-12 16:17 , Processed in 0.014160 second(s), 23 queries .

Powered by MIUI@EZBOX

© 2014-2017 EZBOX

回頂部