mirror of
https://git.unlock-music.dev/um/cli.git
synced 2025-07-06 22:42:12 +08:00
feat: mmkv 加密数据库解析
This commit is contained in:
@ -16,6 +16,9 @@ import (
|
||||
"unlock-music.dev/cli/internal/sniff"
|
||||
)
|
||||
|
||||
var VaultPath = ""
|
||||
var VaultKey = ""
|
||||
|
||||
type Decoder struct {
|
||||
raw io.ReadSeeker // raw is the original file reader
|
||||
params *common.DecoderParams
|
||||
@ -140,11 +143,32 @@ func (d *Decoder) searchKey() (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
switch string(suffixBuf) {
|
||||
switch string(bytes.ReplaceAll(suffixBuf, []byte{0x00}, []byte{})) {
|
||||
case "QTag":
|
||||
return d.readRawMetaQTag()
|
||||
case "STag":
|
||||
return errors.New("qmc: file with 'STag' suffix doesn't contains media key")
|
||||
case "cex":
|
||||
d.decodedKey, err = readKeyFromMMKVCustom(d)
|
||||
if err == nil {
|
||||
suffix := []byte{0x63, 0x65, 0x78, 0x00} // cex
|
||||
for i := 0; i <= 3; i++ {
|
||||
// 末尾的信息数据每192字节出现一次,故只要循环判断末尾不为musicex时即为歌曲数据
|
||||
musicexLen, err := d.raw.Seek(int64(-(192*i)-4), io.SeekEnd)
|
||||
if err != nil {
|
||||
return fmt.Errorf("get musicexLen error: %w", err)
|
||||
}
|
||||
buf, err := io.ReadAll(io.LimitReader(d.raw, 4))
|
||||
if err != nil {
|
||||
return fmt.Errorf("get musicex error: %w", err)
|
||||
}
|
||||
if !bytes.Equal(buf, suffix) {
|
||||
d.audioLen = int(musicexLen) + 4
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
default:
|
||||
size := binary.LittleEndian.Uint32(suffixBuf)
|
||||
|
||||
|
Reference in New Issue
Block a user