先解出keybox.xml,再rkpacker2生成rockchip需要的格式.kdb。
网站解密keybox使用说明
打开网站:http://192.168.8.113:5000/
点“选择文件” 可以批量选择.pgp文件
点“Upload & Run Decryption”解密 会显示每个解密的Result
下载
部署说明:
1.安装Python 3.8.10 (default, Mar 18 2025, 20:04:55)
2.安装pipe3 install Flask
3.运行python3 web.py
另外,目录可能需要权限,需要建文件夹uploads,首次使用请后后需要在后台输入密码。
出现下面即成功
1@ft-192-168-8-113:~/Desktop/rkp/一键解密keybox$ python3 web.py
- Serving Flask app ‘web’
- Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. - Running on all addresses (0.0.0.0)
- Running on http://127.0.0.1:5000
- Running on http://192.168.8.113:5000
Press CTRL+C to quit - Restarting with stat
- Debugger is active!
- Debugger PIN: 329-328-834
源码
"""
Keybox Decrypt Web UI (single-file Flask app)
Features:
- Upload multiple .pgp files at once
- For each uploaded file, executes ./run_keybox_decrypt.sh <filepath> (synchronous)
- Displays success / failure per file
- Lists files in ./out and shows download links
- Supports "Download all" (zips entire out/ folder)
- Supports "Download selected" (zips only checked files)
Security notes (read before running):
- This app executes an external shell script for each uploaded file. Only run this on a trusted machine and with a trusted script.
- The app trusts the provided run_keybox_decrypt.sh to safely handle the given .pgp files.
Usage:
1. Put this file and run_keybox_decrypt.sh in the same directory.
2. Ensure run_keybox_decrypt.sh is executable (chmod +x run_keybox_decrypt.sh).
3. Install dependencies: pip install flask
4. Run: python keybox_decrypt_web.py
5. Open http://127.0.0.1:5000 in your browser.
"""
import os
import shutil
import subprocess
import tempfile
import zipfile
from datetime import datetime
from flask import Flask, request, redirect, url_for, render_template_string, send_file, flash, jsonify
from werkzeug.utils import secure_filename
# Configuration
UPLOAD_FOLDER = os.path.abspath('uploads')
OUT_FOLDER = os.path.abspath('out')
ALLOWED_EXTENSIONS = {'.pgp', '.gpg'} # allow common extensions
DECRYPT_SCRIPT = './run_keybox_decrypt.sh' # script to be executed for each uploaded file
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
os.makedirs(OUT_FOLDER, exist_ok=True)
app = Flask(__name__)
app.secret_key = 'change-this-secret-in-production'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
app.config['OUT_FOLDER'] = OUT_FOLDER
INDEX_HTML = """
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Keybox Decrypt Web UI</title>
<style>
body { font-family: Arial, sans-serif; margin: 30px; }
.box { border: 1px solid #ddd; padding: 12px; margin-bottom: 12px; border-radius: 6px; }
.success { color: green; }
.fail { color: red; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 6px 8px; border-bottom: 1px solid #eee; }
.actions { margin-top: 12px; }
</style>
</head>
<body>
<h1>Keybox Decrypt</h1>
<div class="box">
<form action="/upload" method="post" enctype="multipart/form-data">
<label>Select .pgp/.gpg files (multiple allowed):</label><br>
<input type="file" name="files" multiple required accept=".pgp,.gpg"/><br/><br/>
<button type="submit">Upload & Run Decryption</button>
</form>
</div>
{% if results is defined %}
<div class="box">
<h3>Run results ({{ results|length }} files)</h3>
<table>
<tr><th>Uploaded file</th><th>Result</th><th>Notes</th></tr>
{% for r in results %}
<tr>
<td>{{ r.filename }}</td>
<td class="{{ 'success' if r.ok else 'fail' }}">{{ 'OK' if r.ok else 'Failed' }}</td>
<td><pre style="white-space:pre-wrap">{{ r.output }}</pre></td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}
<div class="box">
<h3>Out folder contents</h3>
<form id="downloadForm" method="post" action="/download_selected">
<table>
<tr><th></th><th>Filename</th><th>Size</th><th>Modified</th><th>Link</th></tr>
{% for f in out_files %}
<tr>
<td><input type="checkbox" name="files" value="{{ f.name }}" checked></td>
<td>{{ f.name }}</td>
<td>{{ f.size }}</td>
<td>{{ f.mtime }}</td>
<td><a href="/out/{{ f.name }}">Download</a></td>
</tr>
{% endfor %}
</table>
<div class="actions">
<button type="submit">Download selected as zip</button>
<a href="/download_all"><button type="button">Download all</button></a>
</div>
</form>
</div>
<script>
// keep simple - no JS needed beyond defaults
</script>
</body>
</html>
"""
def allowed_file(filename):
_, ext = os.path.splitext(filename)
return ext.lower() in ALLOWED_EXTENSIONS
def list_out_files():
items = []
try:
for name in sorted(os.listdir(OUT_FOLDER)):
path = os.path.join(OUT_FOLDER, name)
if os.path.isfile(path):
size = os.path.getsize(path)
mtime = datetime.fromtimestamp(os.path.getmtime(path)).strftime('%Y-%m-%d %H:%M:%S')
items.append({'name': name, 'size': f"{size} bytes", 'mtime': mtime})
except Exception:
pass
return items
@app.route('/')
def index():
out_files = list_out_files()
return render_template_string(INDEX_HTML, out_files=out_files)
@app.route('/upload', methods=['POST'])
def upload():
# 先清空 out 文件夹
for filename in os.listdir(OUT_FOLDER):
file_path = os.path.join(OUT_FOLDER, filename)
try:
if os.path.isfile(file_path):
os.unlink(file_path)
except Exception as e:
print('Failed to delete', file_path, e)
files = request.files.getlist('files')
if not files:
flash('No files uploaded')
return redirect(url_for('index'))
results = []
for f in files:
filename = secure_filename(f.filename)
if not filename:
results.append({'filename': '(invalid name)', 'ok': False, 'output': 'Invalid filename'})
continue
if not allowed_file(filename):
results.append({'filename': filename, 'ok': False, 'output': 'Extension not allowed'})
continue
save_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
f.save(save_path)
# Execute external script with safe args
cmd = [DECRYPT_SCRIPT, save_path]
try:
# Ensure the script exists
if not os.path.isfile(DECRYPT_SCRIPT):
raise FileNotFoundError(f"Decrypt script not found: {DECRYPT_SCRIPT}")
# Run synchronously and capture output
completed = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=False, text=True)
ok = (completed.returncode == 0)
out = completed.stdout or ('Exit code: ' + str(completed.returncode))
results.append({'filename': filename, 'ok': ok, 'output': out})
except Exception as e:
results.append({'filename': filename, 'ok': False, 'output': str(e)})
out_files = list_out_files()
return render_template_string(INDEX_HTML, results=results, out_files=out_files)
@app.route('/out/<path:filename>')
def download(filename):
safe = secure_filename(filename)
path = os.path.join(OUT_FOLDER, safe)
if not os.path.isfile(path):
return f'File not found: {safe}', 404
return send_file(path, as_attachment=True)
@app.route('/download_all')
def download_all():
# Create a zip of entire OUT_FOLDER
tmp = tempfile.NamedTemporaryFile(delete=False, suffix='.zip')
tmp.close()
with zipfile.ZipFile(tmp.name, 'w', compression=zipfile.ZIP_DEFLATED) as z:
for root, _, files in os.walk(OUT_FOLDER):
for file in files:
full = os.path.join(root, file)
arcname = os.path.relpath(full, OUT_FOLDER)
z.write(full, arcname)
return send_file(tmp.name, as_attachment=True, download_name='out_all.zip')
@app.route('/download_selected', methods=['POST'])
def download_selected():
selected = request.form.getlist('files')
if not selected:
return 'No files selected', 400
tmp = tempfile.NamedTemporaryFile(delete=False, suffix='.zip')
tmp.close()
with zipfile.ZipFile(tmp.name, 'w', compression=zipfile.ZIP_DEFLATED) as z:
for name in selected:
safe = secure_filename(name)
full = os.path.join(OUT_FOLDER, safe)
if os.path.isfile(full):
z.write(full, safe)
return send_file(tmp.name, as_attachment=True, download_name='selected_out.zip')
if __name__ == '__main__':
# Simple server for local use
app.run(host='0.0.0.0', port=5000, debug=True)
#!/bin/bash
xml_file="keybox.xml"
out_dir="out"
# 提取第一个 NumberOfKeyboxes
num=$(grep -m 1 -oP '(?<=<NumberOfKeyboxes>).*?(?=</NumberOfKeyboxes>)' "$xml_file")
# 提取第一个 DeviceID
deviceid=$(grep -m 1 -oP '(?<=<Keybox DeviceID=").*?(?=">)' "$xml_file")
# 检查是否读取成功
if [[ -z "$num" || -z "$deviceid" ]]; then
echo "❌ 未能正确读取 NumberOfKeyboxes 或 DeviceID"
exit 1
fi
echo "✅ NumberOfKeyboxes: $num"
echo "✅ DeviceID: $deviceid"
src_file="$out_dir/keybox.kdb"
if [[ ! -f "$src_file" ]]; then
echo "❌ 源文件 $src_file 不存在!"
exit 1
fi
# 生成新文件名
new_file="$out_dir/keybox_${deviceid}_Number_${num}.kdb"
rm -f "$new_file"
# 重命名文件
mv "$src_file" "$new_file"
echo "🎉 已重命名为: $new_file"
解密的脚本run_keybox_decrypt.sh就不公开了
可以直接用这个脚本就能处理。只是方便别人操作。
完全是ai生成的代码。
学习前新东西需要明确的内容
Learn about the kinds of problems XXs are needed to solve
Understand how XXs solve problems differently than ordinary computer programs
新东西是解决什么问题的?
新东西与老东西有什么不同?优势在哪?
1645

被折叠的 条评论
为什么被折叠?



