Guide: Reverse-engineering Xiaomi OTA Updates to Find Unreleased Versions

Ulver

Senior Member
Jan 4, 2011
1,894
487
113
I was able to find the first MIUI 9 Stable (non-developer) global build for Mix 2.
http://bigota.d.miui.com/V9.1.1.0.NDEMIEI/miui_MIMIX2Global_V9.1.1.0.NDEMIEI_232bee13eb_7.1.zip

Caveat is, I think it's actually older than the most recent developer build.
The global dev builds will always be newer and include the most recent bug fixes and security patches, so that's no surprise the stable was built before any of the recent developer ROMs.

Sent from my Mi MIX 2 using Tapatalk

---------- Post added at 08:28 PM ---------- Previous post was at 08:26 PM ----------

Has anyone tried this stable global MIUI 9?

Sent from my Mi MIX 2 using Tapatalk
 

ni554n

Member
Jan 21, 2012
47
10
38
26
Khulna
ni554n.github.io
Can you please look into the Mi 6 (Sagit) version for any upcoming Global Stable release?
Current stable version is: 9.0.1.0(NCAMIEI).

It will be very helpful because there is a critical display / touch response bug fix in Global Beta, but it's not added with the latest stable MIUI9 update.
 
  • Like
Reactions: Dobsgw

Dobsgw

Senior Member
Dec 16, 2015
2,100
1,674
0
Can you please look into the Mi 6 (Sagit) version for any upcoming Global Stable release?
Current stable version is: 9.0.1.0(NCAMIEI).

It will be very helpful because there is a critical display / touch response bug fix in Global Beta, but it's not added with the latest stable MIUI9 update.
So the touch fix is applied now?

Yes we desperately need those updates haha.

Someone on the Miui forum has shown an update they got by OTA for 9.0.5.0 now. So updates are happening even on stable.

Something like this thread on the Mi 6 forum would be good.

Also a slight issue will be that XDA just posted this on their analysis page so there's a chance Xiaomi sees this and shuts it down before we get anywhere....
 

duraaraa

Senior Member
@duraaraa
Could you look at unreleased msm8996 "gold" codename and msm8998 "centaur" devices? Found them mentioned in the libs of a few devices.
Please check the first post. I don't have any other tricks. I gave you the best fishing pole I could, so please catch the fish yourself :p
I wish I had time, but apart from Mix 2, I don't really have the time or interest to look for other devices.
 
  • Like
Reactions: Dobsgw

twu2

Senior Member
Oct 25, 2009
165
269
103
Taipei
blog.teatime.com.tw
I don't know why the pythod code is not working in my environment (can't decrypt the result correctly), so I write the code using php to do this.

Code:
<?php

$cipher = 'rijndael-128';
$mode = 'cbc';
$miui_key = 'miuiotavalided11';
$miui_iv = '0102030405060708';

function miui_decrypt($s)
{
    global $cipher, $mode, $miui_key, $miui_iv;

    $td = mcrypt_module_open($cipher, '', $mode, '');
    mcrypt_generic_init($td, $miui_key, $miui_iv);
    $decrypted = mdecrypt_generic($td, base64_decode($s));
    mcrypt_generic_deinit($td);
    mcrypt_module_close($td);
    $pos = strrpos($decrypted, '}');
    if ($pos !== false)
        return substr($decrypted, 0, $pos + 1);
    return $decrypted;
}

function miui_encrypt($s)
{
    global $cipher, $mode, $miui_key, $miui_iv;

    $td = mcrypt_module_open($cipher, '', $mode, '');
    mcrypt_generic_init($td, $miui_key, $miui_iv);
    $bs = mcrypt_get_block_size($cipher, $mode);
    $n = $bs - (strlen($s) % $bs);
    while ($bs - (strlen($s) % $bs) != $bs)
        $s .= chr($n);
    $encrypted = base64_encode(mcrypt_generic($td, $s));
    mcrypt_generic_deinit($td);
    mcrypt_module_close($td);
    return $encrypted;
}

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

$device_data = array(
    "a" => "0", # Don't know what this is.
    "c" => "7.0", # Same as 'c' above, it's the Android version.
    "b" => "F", # Same as above, 'X' for weekly build.
    "d" => "mido_global", # The device name, same as above, chiron for Chinese, chiron_global for global.
    "g" => "00000000000000000000000000000000", # This seems to be the android_id of the device. Maybe encoded somehow.
    "cts" => "0", # I don't know what this is.
    "i" => "0000000000000000000000000000000000000000000000000000000000000000", # This seems to be the imei of the device, obviously encoded somehow.
    "isR" => "0", # I don't know what this is.
    "f" => "1", # I don't know what this is.
    "l" => "en_US", # The locale.
    "n" => "",  # I don't know what this parameter is
    "sys" => "0", # I don't know what this is.
    "p" => "msm8953", # The chipset
    "unlock" => "1",  # 1 means bootloader is unlocked. 0 means locked.
    "r" => "CN", # I don't know what this is, maybe region of device?
    "sn" => "0x00000000", # Probably the serial number of the device, maybe encoded somehow.
    "v" => "MIUI-V9.0.5.0.NCFMIEI", # The version of MIUI installed.
    "bv" => "9", # I don't know what this is.
    "id" => "", # I don't' know what this is.
);

$js = json_encode($device_data);

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

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $checkurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$data = curl_exec($curl);
if ($data === false) {
    echo "*** curl_exec() failed: ".curl_errno($curl)." => ".curl_error($curl)."\n";
    curl_close($curl);
    exit;
}

$r = miui_decrypt($data);
$result = json_decode($r);
print_r($result);

exit;
the above code is for Redmi Note 4X, get the current stable nightly version V9.0.5.0.NCFMIEI => miui_HMNote4XGlobal_V9.0.5.0.NCFMIEI_d6176de291_7.0.zip