function getfiles() { global $master_key, $root_id, $inbox_id, $trashbin_id; $files = api_req(array('a' => 'f', 'c' => 1)); foreach ($files->f as $file) { if ($file->t == 0 || $file->t == 1) { $key = substr($file->k, strpos($file->k, ':') + 1); $key = decrypt_key(base64_to_a32($key), $master_key); if ($file->t == 0) { $k = array($key[0] ^ $key[4], $key[1] ^ $key[5], $key[2] ^ $key[6], $key[3] ^ $key[7]); $iv = array_merge(array_slice($key, 4, 2), array(0, 0)); $meta_mac = array_slice($key, 6, 2); } else { $k = $key; } $attributes = base64urldecode($file->a); $attributes = dec_attr($attributes, $k); if ($file->h == 'gldU3Tab') { downloadfile($file, $attributes, $k, $iv, $meta_mac); } } else { if ($file->t == 2) { $root_id = $file->k; } else { if ($file->t == 3) { $inbox_id = $file->k; } else { if ($file->t == 4) { $trashbin_id = $file->k; } } } } } }
function Login($user, $pass) { global $T8; if (!extension_loaded('bcmath')) { html_error('This plugin needs BCMath extension for login.'); } $password_aes = prepare_key(str_to_a32($pass)); $T8['user_handle'] = stringhash($user, $password_aes); $res = apiReq(array('a' => 'us', 'user' => $user, 'uh' => $T8['user_handle'])); if (is_numeric($res[0])) { check_errors($res[0], 'Cannot login'); } $T8['master_key'] = decrypt_key(base64_to_a32($res[0]['k']), $password_aes); $privk = a32_to_str(decrypt_key(base64_to_a32($res[0]['privk']), $T8['master_key'])); $rsa_priv_key = array(0, 0, 0, 0); for ($i = 0; $i < 4; $i++) { $l = (ord($privk[0]) * 256 + ord($privk[1]) + 7) / 8 + 2; $rsa_priv_key[$i] = mpi2bc(substr($privk, 0, $l)); $privk = substr($privk, $l); } $T8['sid'] = rsa_decrypt(mpi2bc(base64url_decode($res[0]['csid'])), $rsa_priv_key[0], $rsa_priv_key[1], $rsa_priv_key[2]); $T8['sid'] = base64url_encode(substr(strrev($T8['sid']), 0, 43)); getRootNode(); t8ArrToCookieArr($rsa_priv_key); SaveCookies($user, $pass); // Update cookies file. $cookie = ''; }