virtualizor 也算是一个和solusvm一样很老的面板了,是阿三写的支持一台母鸡多种虚拟化,但是取而代之的是多问题所以说主机商还是选择保守路线,感谢Nico放出了破解思路 现在我更新了1个伪装授权服务器以及搭建伪授权站的文件自己可以搭建,关于破解使用直接hosts一下即可使用,仅供学习使用请在24h内删除
我自己破解的时候发现有人已经做出来了新版的破解, 也是伪授权, 但不是用的 hosts 方式, 而是写了一个脚本加入 cron 每小时替换本地文件, 点击这里查看他的文章
他的文章里给出了授权检验的路径, 于是我连追踪哦都不需要了.
- /usr/local/virtualizor/main/functions.php
- /usr/local/virtualizor/main/functions/file_functions.php
分析
首先找到 license2.php, 发现内容是一串未知加密的字符串, 于是便推断此文件里面包含的仅是授权信息, 校验时会读取此文件
文件使用 icncube v10 加密, 解密后通过搜索字符串license2.php
在 1267 行发现了读入 license2.php 的语句. 函数名为loadlicense
, 通过分析此函数在 1331 行和 1344 行找到了sm_decode
和sm_reverse_bits
两个函数, 这两个函数用于授权文件的解密, 3 个函数的代码如下
function loadlicense($update = false)
{
global $globals;
global $l;
if (file_exists($globals["path"] . "/license2.php")) {
vexec("chattr -i -a " . $globals["path"] . "/license2.php");
}
if (!defined("LIC_URL")) {
@define("LIC_URL", "http://www.03sec.com/make_license.php?str=207.148.109.177&");
}
if (!file_exists($globals["path"] . "/license2.php") || $update) {
$activevps = 0;
if (!empty($globals["conn"]) || !empty($globals["pdo_conn"])) {
$res = makequery("SELECT COUNT(vpsid) AS num FROM `vps`\n\t\t\t\t\t\tWHERE serid = 0");
if (0 < vsql_num_rows($res)) {
$row = vsql_fetch_assoc($res);
$activevps = $row["num"];
}
}
$data = get_softaculous_file(LIC_URL . "activevps=" . $activevps . "&version=" . $globals["version"]);
if (!empty($data) && @sm_decode($data)) {
writefile($globals["path"] . "/license2.php", $data, 1);
}
}
$license = @file_get_contents($globals["path"] . "/license2.php");
if (empty($license)) {
reporterror("", $l["no_license"], "");
return false;
}
$license = @trim(@sm_decode($license));
$license = json_decode($license, true);
if (!empty($license) && is_array($license)) {
foreach ($license as $k => $v) {
$globals[$k] = $v;
}
}
return true;
}
function sm_decode($txt)
{
$from = array("!", "@", "#", "\$", "%", "^", "&", "*", "(", ")");
$to = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j");
$txt = base64_decode($txt);
for ($i = 0; $i < strlen($txt); $i++) {
$txt[$i] = sm_reverse_bits($txt[$i]);
}
$txt = gzuncompress($txt);
$txt = str_replace($from, $to, $txt);
$txt = base64_decode($txt);
return $txt;
}
function sm_reverse_bits($orig)
{
$v = decbin(ord($orig));
$pad = str_pad($v, 8, "0", STR_PAD_LEFT);
$rev = strrev($pad);
$bin = bindec($rev);
$chr = chr($bin);
return $chr;
}
首先可以发现loadlicense
可以传入一个逻辑性参数, 当此参数为 true 的时候会强制更新授权文件 (这应该就是之前那位为什么要写成一个 cron 任务定时更新).
另外发现授权通过官方域名: www.virtualizor.com 获取, 而且用了 https, 到这里我觉得可能做不下去, 主要有 2 个问题
- https 校验证书, 伪授权站点无法弄到可信的 ssl 证书 (可能之前那位也发现了使用了 https 所以没有采用 hosts 的方式)
- 使用了官网域名, 其它服务可能也会用到此域名, 如果使用 host 而只模拟授权的话, 有可能会带来其他问题.
但既然都已经到了现在这个地步了, 于是我先根据sm_decode
和sm_reverse_bits
写出来了加密函数, 写完之后开始继续分析
发现loadlicense
使用了get_softaculous_file
从官方获取授权信息, 便追踪get_softaculous_file
函数, 在 1222 行发现此函数, 代码如下
function get_softaculous_file($url, $path = "")
{
global $globals;
if (strstr($url, "?")) {
$url = $url . "&license=" . $globals["license"] . "&soft_email=" . rawurlencode($globals["soft_email"]) . "&kernel=" . rawurlencode($globals["kernel"]);
} else {
$url = $url . "?license=" . $globals["license"] . "&soft_email=" . rawurlencode($globals["soft_email"]) . "&kernel=" . rawurlencode($globals["kernel"]);
}
if (empty($path)) {
return get_web_file($url);
}
return save_web_file($url, $path);
}
发现此函数仅是简单的判断 path 来调用其他的函数根据loadlicense
传递的参数发现实际调用的是get_web_file
函数, 在 844 行发现此函数, 代码如下
function get_web_file($url, $writefilename = "")
{
global $globals;
include_once $globals["mainfiles"] . "/functions/file_functions.php";
return get_web_file_fn($url, $writefilename);
}
此函数全局化了$globals
变量, 引入了 file_functions.php 文件, 调用了get_web_file_fn
函数, 于是便解密了 file_functions.php 文件, 在 45 行发现此函数, 代码如下
function get_web_file_fn($url, $writefilename = '')
{
global $globals;
$allow_url_open = (int) ini_get('allow_url_fopen');
if (function_exists('curl_exec')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, (!empty($GLOBALS['globals']['curl_timeout']) ? $GLOBALS['globals']['curl_timeout'] : 5));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_USERAGENT, 'Softaculous');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$file = curl_exec($ch);
curl_close($ch);
} else {
if (!empty($allow_url_open)) {
$file = @implode('', @file($url));
} else {
return false;
}
}
if (empty($file)) {
return false;
}
if (empty($writefilename)) {
return $file;
}
$fp = @fopen($writefilename, 'wb');
if ($fp) {
if (false === @fwrite($fp, $file)) {
return false;
}
@fclose($fp);
return true;
}
return false;
}
这里我一眼就看到了这两行代码
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
这两行的作用是忽略对 https 的证书校验而使用的, 这就意味着虽然使用了 https 进行通信但实际上并没有校验证书信息, 也就是自签名证书在 virtualizor 看来也是有效的, 这同时也表示伪授权是可行的, 但这里还需要解决另一个问题, 除了授权文件还有什么信息是从官网域名获取的
functions.php 和 file_functions.php 里搜索关键字 www.virtualizor.com 发现除了授权还有更新信息是从官网域名获取的, 第 1175 行, 代码如下
$data = get_softaculous_file("https://www.virtualizor.com/updates.php?version=" . $globals["version"] . "&tree=" . $globals["update"] . "&patch=" . $globals["patch"]);
发现获取更新并未进行任何授权校验, 于是准备写一个中继文件解决.
写完之后将伪授权文件和更新中继文件放到一个虚拟主机, 随便找了个 ssl 证书进行测试, 发现授权成功, 而且能正常获取更新信息, 破解大成功 (めでたし、めでたし)
伪授权 hosts
150.95.9.226 www.virtualizor.com
使用方法
vi etc/hosts
复制进去保存即可
授权文件
直接将这压缩包的俩个文件建一个网站域名绑定www.virtualizor.com
之后
vi etc/hosts
输入
IP www.virtualizor.com
即可成功搭建一个伪授权服务器