virtualizor 破解
参考
老哥没给出破解的办法,我这边给了一个python脚本,定期运行即可,没有外部依赖
破解代码
- python
import base64
import zlib
import json
import argparse
import sys
import os
import datetime
import re
import shutil
# --- 核心工具函数 ---
def bit_reverse_byte(n):
"""字节位反转"""
return int('{:08b}'.format(n)[::-1], 2)
# --- 解密逻辑 ---
def sm_decode(encoded_txt):
if not encoded_txt:
return None
try:
if isinstance(encoded_txt, str):
encoded_txt = encoded_txt.encode('utf-8')
step1_data = base64.b64decode(encoded_txt)
step2_buffer = bytearray()
for byte in step1_data:
step2_buffer.append(bit_reverse_byte(byte))
step3_data = zlib.decompress(step2_buffer)
text_str = step3_data.decode('utf-8')
trans_table = str.maketrans("!@#$%^&*()", "abcdefghij")
step4_text = text_str.translate(trans_table)
final_data = base64.b64decode(step4_text)
return final_data.decode('utf-8')
except Exception as e:
sys.stderr.write(f"[!] 解密失败: {e}\n")
return None
# --- 加密逻辑 ---
def sm_encode(json_str):
if not json_str:
return None
try:
step1_b64 = base64.b64encode(json_str.encode('utf-8')).decode('utf-8')
trans_table = str.maketrans("abcdefghij", "!@#$%^&*()")
step2_replaced = step1_b64.translate(trans_table)
step3_compressed = zlib.compress(step2_replaced.encode('utf-8'))
step4_buffer = bytearray()
for byte in step3_compressed:
step4_buffer.append(bit_reverse_byte(byte))
final_encoded = base64.b64encode(step4_buffer).decode('utf-8')
return final_encoded
except Exception as e:
sys.stderr.write(f"[!] 加密失败: {e}\n")
return None
# --- 修改逻辑 ---
def modify_license_data(json_data):
"""修改过期时间为明天"""
# 获取当前时间 + 1天
now = datetime.datetime.now()
tomorrow = now + datetime.timedelta(days=1)
print(f"[*] 设置新的过期时间为: {tomorrow.strftime('%Y-%m-%d %H:%M:%S')}")
# 修改字段
json_data['active'] = 1
json_data['active_txt'] = '<font color="green">Active</font>'
# 格式: YYYYMMDD
json_data['licexpires'] = tomorrow.strftime("%Y%m%d")
# 格式: DD/MM/YYYY GMT
json_data['licexpires_txt'] = tomorrow.strftime("%d/%m/%Y GMT")
json_data['download_time'] = int(now.timestamp())
return json_data
# --- JSON 特殊处理 ---
def precise_json_escape(json_str):
"""只转义 fast_mirrors 和 licexpires_txt 中的斜杠"""
def escape_slash_in_match(match):
return match.group(0).replace('/', '\\/')
pattern_txt = r'"licexpires_txt":".*?"'
json_str = re.sub(pattern_txt, escape_slash_in_match, json_str)
pattern_mirrors = r'"fast_mirrors":\[.*?\]'
json_str = re.sub(pattern_mirrors, escape_slash_in_match, json_str)
return json_str
# --- 主程序 ---
def main():
parser = argparse.ArgumentParser(description="License 自动续期工具")
parser.add_argument("file_path", help="原始 License 文件路径")
# 新增 --replace 选项
parser.add_argument("--replace", action="store_true", help="生成临时文件后直接覆盖原文件")
args = parser.parse_args()
# 1. 读取文件
if not os.path.exists(args.file_path):
sys.stderr.write(f"[!] 错误: 文件不存在 -> {args.file_path}\n")
sys.exit(1)
print(f"[*] 正在读取文件: {args.file_path}")
with open(args.file_path, 'r', encoding='utf-8') as f:
original_content = f.read().strip()
# 2. 解密
decoded_json_str = sm_decode(original_content)
if not decoded_json_str:
sys.exit(1)
try:
json_data = json.loads(decoded_json_str)
# --- [需求] 打印刚读取出来的原始 JSON ---
print("\n" + "="*20 + " 原始 JSON 数据 " + "="*20)
print(json.dumps(json_data, indent=4, ensure_ascii=False))
print("="*56 + "\n")
except json.JSONDecodeError:
sys.stderr.write("[!] 解密成功但不是有效的 JSON\n")
sys.exit(1)
# 3. 修改数据 (日期改为明天)
modified_data = modify_license_data(json_data)
# 4. 生成 & 精准转义
compact_json_str = json.dumps(modified_data, separators=(',', ':'))
final_json_str = precise_json_escape(compact_json_str)
print("=============修改后的json=============")
print(final_json_str)
# 5. 加密
new_license_str = sm_encode(final_json_str)
# 6. 生成临时文件
tmp_file_path = "/tmp/license2.php"
try:
with open(tmp_file_path, 'w', encoding='utf-8') as f:
f.write(new_license_str)
print(f"[*] 临时文件已生成: {tmp_file_path}")
except IOError as e:
print(f"[!] 无法写入临时文件 {tmp_file_path}: {e}")
sys.exit(1)
# 7. 处理 --replace 逻辑
if args.replace:
print(f"[*] 检测到 --replace 参数,正在覆盖原文件...")
try:
shutil.copyfile(tmp_file_path, args.file_path)
print(f"[SUCCESS] 文件已更新: {args.file_path}")
except Exception as e:
print(f"[!] 覆盖文件失败: {e}")
else:
print("-" * 60)
print(f"[*] 未使用 --replace。新 License 内容如下 (也保存在 {tmp_file_path}):")
print(new_license_str)
print("-" * 60)
if __name__ == "__main__":
main()
- cron脚本
*/10 * * * * /usr/bin/python3 /root/crack.py /usr/local/virtualizor/license2.php --replace