音乐控制/解密
This commit is contained in:
1 parent
9e6d73e191
commit
ff1d5cd517
41 files changed
+10827
-4
No files matched your search
@@ -0,0 +1,83 @@
|
||||
//! **临时**端到端验证:对真实 musicex 样本走完整「取密钥 → 解密 → 校验」流程。
|
||||
//!
|
||||
//! 用法(需要 QQ 音乐在运行且已登录):
|
||||
//! ```text
|
||||
//! cargo run --example decrypt_musicex_probe -- "C:\path\to\file.mflac"
|
||||
//! ```
|
||||
//! 验证完即可删除本文件。
|
||||
|
||||
use thing_lib::music::decrypt::probe::{probe_musicex, ProbeOutcome};
|
||||
|
||||
fn main() {
|
||||
let mut args = std::env::args().skip(1);
|
||||
let path = args.next().expect(
|
||||
"用法:decrypt_musicex_probe <文件路径> [输出目录]\n\
|
||||
给了输出目录则会用**生产路径**真正写盘(生成可播放文件)",
|
||||
);
|
||||
let out_dir = args.next();
|
||||
|
||||
match probe_musicex(std::path::Path::new(&path)) {
|
||||
Ok(ProbeOutcome {
|
||||
ekey_len,
|
||||
key_len,
|
||||
raw_key_bytes,
|
||||
cipher_magic,
|
||||
plain_magic,
|
||||
decrypted_bytes,
|
||||
guessed_format,
|
||||
expiration_secs,
|
||||
}) => {
|
||||
println!("=== 成功 ===");
|
||||
println!("ekey 长度 : {ekey_len}");
|
||||
println!("派生密钥长度 : {key_len}");
|
||||
println!(
|
||||
"密钥前 8 字节 : {:02x?}",
|
||||
&raw_key_bytes[..raw_key_bytes.len().min(8)]
|
||||
);
|
||||
println!("密文头 : {:02x?}", cipher_magic);
|
||||
println!("解密后字节数 : {decrypted_bytes}");
|
||||
println!("明文首帧魔数 : {:02x?}", plain_magic);
|
||||
println!("判定格式 : {guessed_format}");
|
||||
println!("ekey 有效期(秒) : {expiration_secs}");
|
||||
if guessed_format == "flac" && plain_magic.starts_with(b"fLaC") {
|
||||
println!("=> 合法 FLAC 头,产物可播");
|
||||
} else {
|
||||
println!("=> 头不合法,需要排查");
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
println!("=== 失败 ===");
|
||||
println!("{e}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// 可选:调用**生产路径**真正落盘(验证 decrypt_musicex 本身,而不只是核心算法)
|
||||
if let Some(dir) = out_dir {
|
||||
println!("\n=== 生产路径落盘 ===");
|
||||
match thing_lib::music::decrypt::qq_online::decrypt_musicex(
|
||||
std::path::Path::new(&path),
|
||||
std::path::Path::new(&dir),
|
||||
"QQ音乐",
|
||||
|done, total| {
|
||||
if done == total {
|
||||
println!("进度:{done} 字节(完成)");
|
||||
}
|
||||
},
|
||||
) {
|
||||
Ok(outcome) => {
|
||||
let size = std::fs::metadata(&outcome.output)
|
||||
.map(|m| m.len())
|
||||
.unwrap_or(0);
|
||||
println!("产物 : {}", outcome.output.display());
|
||||
println!("大小 : {size} 字节");
|
||||
println!("格式 : {}", outcome.format);
|
||||
println!("备注 : {}", outcome.note);
|
||||
}
|
||||
Err(e) => {
|
||||
println!("落盘失败:{e}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user