Last active
January 7, 2024 12:39
-
-
Save in4in-dev/09f32f313f11b2c10778d9e2ffe7e60e to your computer and use it in GitHub Desktop.
PHP VK audio unmask (decode extras)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//(js -> php) code. letter by letter | |
global $n, $i, $id; | |
$n = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN0PQRSTUVWXYZO123456789+/="; | |
$id = 12345; //YOUR USER ID | |
$i = [ | |
'v' => function($e) { | |
return strrev($e); | |
}, | |
'r' => function($e, $t){ | |
global $n; | |
$e = str_split($e); | |
for ($o = $n . $n, $s = count($e); $s--;){ | |
$i = stripos($o, $e[$s]); | |
if(~$i){ | |
$e[$s] = substr($o, $i - $t, 1); | |
} | |
} | |
return implode("", $e); | |
}, | |
's' => function($e, $t) { | |
$n = strlen($e); | |
if ($n) { | |
$i = r($e, $t); | |
$o = 0; | |
$e = str_split($e); | |
for (; ++$o < $n;){ | |
$p = array_splice($e, $i[$n - 1 - $o], 1, $e[$o]); | |
$e[$o] = $p[0]; | |
} | |
$e = implode("", $e); | |
} | |
return $e; | |
}, | |
'i' => function($e, $t){ | |
global $i, $id; | |
$k = $i['s']; | |
return $k($e, $t ^ $id); | |
}, | |
]; | |
function o() { | |
return false; | |
} | |
function a($e){ | |
global $n; | |
if (!$e || strlen($e) % 4 == 1) { | |
return !1; | |
} | |
$s = 0; | |
for ($o = 0, $a = "";$s < strlen($e);) { | |
$i = $e[$s++]; | |
$i = strpos($n, $i); | |
if ($i !== false) { | |
$t = ($o % 4) ? 64 * $t + $i : $i; | |
if ($o++ % 4) { | |
$a .= chr(255 & $t >> (-2 * $o & 6)); | |
} | |
} | |
} | |
return $a; | |
} | |
function r($e, $t) { | |
$n = strlen($e); | |
$i = []; | |
if ($n) { | |
$o = $n; | |
$t = abs($t); | |
for (; $o--;){ | |
$t = ($n * ($o + 1) ^ $t + $o) % $n; | |
$i[$o] = $t; | |
} | |
} | |
return $i; | |
} | |
function s($e){ | |
global $i; | |
if (!o() && strpos($e, "audio_api_unavailable") !== false) { | |
$t = explode("?extra=", $e); | |
$t = $t[1]; | |
$t = explode("#", $t); | |
$n = ("" === $t[1]) ? "" : a($t[1]); | |
$t = a($t[0]); | |
if (!is_string($n) || !$t){ return $e;} | |
$n = $n ? explode(chr(9), $n) : []; | |
for ($l = count($n); $l--;) { | |
$r = explode(chr(11), $n[$l]); | |
$s = array_splice($r, 0, 1, $t); | |
$s = $s[0]; | |
if (!$i[$s]){ return $e; } | |
$t = $i[$s](...$r); | |
} | |
if ($t && "http" === substr($t, 0, 4)){ return $t;} | |
} | |
return $e; | |
} | |
//For example | |
//EASY <><<><><> | |
//$extra = s("https://m.vk.com/mp3/audio_api_unavailable.mp3?extra=encodevaluefromvk"); //Encode extra url -> Good extra url | |
//Or see -> test.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include_once(__DIR__ . "/perfect.php"); | |
$email = ""; //Login | |
$pass = ""; //Pass | |
$auth_url = "https://m.vk.com"; | |
if(array_key_exists("extra", $_GET)){ | |
header("Content-type: audio/mpeg"); | |
echo file_get_contents(urldecode($_GET['extra'])); | |
}else { | |
/* Auth .. Copied from stackoverflow */ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $auth_url); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | |
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
$login_page = curl_exec($ch); | |
curl_close($ch); | |
preg_match("/<form method=\"post\" action=\"([^\"]+)/", $login_page, $login_url); | |
$login_url = $login_url[1]; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $login_url); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, ["email" => $email, "pass" => $pass]); | |
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); | |
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_exec($ch); | |
curl_close($ch); | |
/* Get music */ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, "https://m.vk.com/audio"); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-Requested-With: XMLHttpRequest']); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, ["_ajax" => 1, 'q' => $_GET['search']]); | |
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
$page = curl_exec($ch); | |
curl_close($ch); | |
$html = json_decode($page, true); | |
$html = $html[3][0]; | |
$html = mb_convert_encoding($html, "UTF-8", "windows-1251"); | |
preg_match_all('/<span class="ai_title">(.+?)<\/span>/', $html, $titles); | |
$titles = $titles[1]; | |
preg_match_all('/<span class="ai_artist">(.+?)<\/span>/', $html, $artists); | |
$artists = $artists[1]; | |
//Get extras | |
preg_match_all('/"https:\/\/m\.vk\.com\/mp3\/audio_api_unavailable\.mp3\?extra=([^"]+)/', $html, $extras); | |
$extras = $extras[1]; | |
$result = array(); | |
foreach ($titles as $k => $title) { | |
$result[] = array( | |
"title" => strip_tags($title), | |
"artist" => strip_tags($artists[$k]), | |
"extra" => s("https://m.vk.com/mp3/audio_api_unavailable.mp3?extra=" . $extras[$k]) //Decooooooode | |
); | |
} | |
/* Html */ | |
?> | |
<!doctype html> | |
<html lang="ru"> | |
<head> | |
<meta charset="windows-1251"> | |
<title>Document</title> | |
</head> | |
<body> | |
<?php | |
echo "<table>"; | |
foreach ($result as $val) { | |
echo "<tr>"; | |
echo("<td>" . mb_convert_encoding($val['title'], "CP1251", "UTF8") . "</td><td>" . mb_convert_encoding($val['artist'], "CP1251", "UTF8") . "</td><td><a href='" . ("?extra=" . $val['extra']) . "'>Получить</a></td>"); | |
echo "</tr>"; | |
} | |
echo "</table>"; | |
?> | |
</body> | |
</html> | |
<?php | |
} |
Какой-то геморрой в качестве решения предлагаете. Там делов-то, одну строчку правильно порезать и даже ничего скачивать не нужно...
Вот рабочий пример на 31.07.2021 (извиняюсь, что на js):
var id = 0, // Ваш ID в ВК
ni = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN0PQRSTUVWXYZO123456789+/=",
ii = {
v: function(e) {
return e.split("").reverse().join("")
},
r: function(e, t) {
var n;
e = e.split("");
for (var i = ni + ni, a = e.length; a--;) ~(n = i.indexOf(e[a])) && (e[a] = i.substr(n - t, 1));
return e.join("")
},
s: function(e, t) {
var n = e.length;
if (n) {
var i = function(e, t) {
var n = e.length,
i = [];
if (n) {
var a = n;
for (t = Math.abs(t); a--;) t = (n * (a + 1) ^ t + a) % n, i[a] = t
}
return i
}(e, t),
a = 0;
for (e = e.split(""); ++a < n;) e[a] = e.splice(i[n - 1 - a], 1, e[a])[0];
e = e.join("")
}
return e
},
i: function(e, t) {
return ii.s(e, t ^ id)
},
x: function(e, t) {
var n = [];
return t = t.charCodeAt(0), each(e.split(""), (function(e, i) {
n.push(String.fromCharCode(i.charCodeAt(0) ^ t))
})), n.join("")
}
};
function ai(e) {
if ((!window.wbopen || !~(window.open + "").indexOf("wbopen")) && ~e.indexOf("audio_api_unavailable")) {
var t, n, i = e.split("?extra=")[1].split("#"),
a = "" === i[1] ? "" : oi(i[1]);
if (i = oi(i[0]), "string" != typeof a || !i) return e;
for (var o = (a = a ? a.split(String.fromCharCode(9)) : []).length; o--;) {
if (t = (n = a[o].split(String.fromCharCode(11))).splice(0, 1, i)[0], !ii[t]) return e;
i = ii[t].apply(null, n)
}
if (i && "http" === i.substr(0, 4)) return i
}
return e
}
function oi(e) {
if (!e || e.length % 4 == 1) return !1;
for (var t, n, i = 0, a = 0, o = ""; n = e.charAt(a++);) ~(n = ni.indexOf(n)) && (t = i % 4 ? 64 * t + n : n, i++ % 4) && (o += String.fromCharCode(255 & t >> (-2 * i & 6)));
return o
}
function getURL_MP3(str) {
var arr = ai(str).split("/");
arr[6] = arr[5] + ".mp3?" + arr[6].split('?')[1];
arr.splice(4, 2);
return arr.join("/");
}
Всем привет, в начале 22 года не работает
случайно нет рабочего кода у кого нибудь?
Всем привет, в начале 22 года не работает
случайно нет рабочего кода у кого нибудь?
Кури в сторону питона. Там есть рабочие библиотеки по ВК. К сожалению названия не помню.
Та есть. Одна единственная. Но рабочая))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ВК как обычно вставили палку в колеса, нужно обновление(