機能追加: Bakin・NW.jsエンジンおよびセーブ編集対応、ES3パスワード解決機能とRPGツクールMZ修正サービスの追加
This commit is contained in:
1 parent
f50976a6c0
commit
152abae1f8
33 files changed
+11356
-175
No files matched your search
@@ -0,0 +1,585 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace GameLauncher.Services.Codecs.Es3
|
||||
{
|
||||
/// <summary>
|
||||
/// ゲームのバイナリから ES3 のパスワード候補文字列を抽出する汎用ヘルパー。
|
||||
///
|
||||
/// Easy Save 3 のパスワードは <c>new ES3Settings(ES3.EncryptionType.AES, "password")</c> のように
|
||||
/// コード中の文字列リテラルとして埋め込まれることが多いため、
|
||||
/// マネージドアセンブリ(Mono)/IL2CPP メタデータの双方から文字列を回収します。
|
||||
/// 特定のゲーム名に依存しない汎用実装です。
|
||||
/// </summary>
|
||||
public static class Es3PasswordExtractor
|
||||
{
|
||||
/// <summary>文字列抽出対象とする最大ファイルサイズ(バイト)。巨大ファイルの全走査を避けます。</summary>
|
||||
private const long MaxScanFileSize = 512L * 1024 * 1024;
|
||||
|
||||
/// <summary>1 ファイルあたりに保持する候補の上限。</summary>
|
||||
private const int MaxCandidatesPerFile = 4000;
|
||||
|
||||
/// <summary>抽出する文字列の最小長。</summary>
|
||||
private const int MinCandidateLength = 3;
|
||||
|
||||
/// <summary>抽出する文字列の最大長。</summary>
|
||||
private const int MaxCandidateLength = 64;
|
||||
|
||||
/// <summary>ES3 の既定設定アセットにおいて暗号化パスワードを保持するフィールド名。</summary>
|
||||
private const string FieldNameEncryptionPassword = "encryptionPassword";
|
||||
|
||||
/// <summary>
|
||||
/// パスワードらしい文字列のみを通すための許可パターン(英数字記号のみ、空白・制御文字を除外)。
|
||||
/// </summary>
|
||||
private static readonly Regex CandidatePattern =
|
||||
new(@"^[\x21-\x7E]{3,64}$", RegexOptions.Compiled);
|
||||
|
||||
/// <summary>
|
||||
/// ES3 のパスワード指定箇所の近傍を示す手がかりキーワード。
|
||||
/// これらを含む文字列は優先的に候補の先頭へ寄せます。
|
||||
/// </summary>
|
||||
private static readonly string[] PasswordHints =
|
||||
[
|
||||
"password", "Password", "PASSWORD",
|
||||
"pass", "Pass", "pwd", "Pwd",
|
||||
"encrypt", "Encrypt", "encryption", "Encryption",
|
||||
"ES3Settings", "ES3", "es3"
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// 明らかにパスワードではない文字列(Unity の内部名・型名・UI ラベルなど)を除外するパターン。
|
||||
///
|
||||
/// 実ゲーム検証では "GUILayoutPasswordField" のような UI クラス名や
|
||||
/// "The password Text" のような説明文が大量に抽出され、真のパスワードが埋もれていました。
|
||||
/// それらを除外して候補の精度を上げます。
|
||||
/// </summary>
|
||||
private static readonly Regex NoisePattern = new(
|
||||
@"^(Unity|UnityEngine|UnityEditor|System|Microsoft|Mono|mscorlib|netstandard|" +
|
||||
@"Assembly-CSharp|Library|Packages|Assets|Resources|StreamingAssets|" +
|
||||
@"com\.unity|Unity\.|UnityEngine\.|System\.)" +
|
||||
@"|PasswordField|passwordField|TextField|password Text|Password Text" +
|
||||
@"|GUILayout|OnGUI|m_[A-Z]|get_|set_|<[A-Za-z]",
|
||||
RegexOptions.Compiled);
|
||||
|
||||
/// <summary>
|
||||
/// 空白を含む文字列は UI ラベル・説明文である可能性が高いため、
|
||||
/// パスワード候補としては扱いません(パスワードは通常 1 トークン)。
|
||||
/// </summary>
|
||||
private static readonly Regex SentenceLikePattern = new(
|
||||
@"\s{1,}.*\s|[.!?]$",
|
||||
RegexOptions.Compiled);
|
||||
|
||||
/// <summary>
|
||||
/// ゲームルートディレクトリから ES3 パスワード候補を抽出します。
|
||||
/// </summary>
|
||||
/// <param name="gameRootDirectory">ゲームのルートディレクトリ</param>
|
||||
/// <param name="diagnostics">診断メッセージの追加先(null 可)</param>
|
||||
/// <returns>優先度順に並んだパスワード候補</returns>
|
||||
public static List<string> ExtractCandidates(string gameRootDirectory, List<string>? diagnostics = null)
|
||||
{
|
||||
var result = new List<string>();
|
||||
if (string.IsNullOrWhiteSpace(gameRootDirectory) || !Directory.Exists(gameRootDirectory))
|
||||
{
|
||||
diagnostics?.Add($"ゲームフォルダが見つかりません: {gameRootDirectory}");
|
||||
return result;
|
||||
}
|
||||
|
||||
var scanTargets = CollectScanTargets(gameRootDirectory);
|
||||
if (scanTargets.Count == 0)
|
||||
{
|
||||
diagnostics?.Add("文字列抽出の対象ファイル(マネージドアセンブリ/IL2CPPメタデータ)が見つかりませんでした。");
|
||||
return result;
|
||||
}
|
||||
|
||||
diagnostics?.Add($"文字列抽出対象: {scanTargets.Count} ファイル");
|
||||
|
||||
// 「パスワード指定の近傍にある文字列」を高優先、「その他の文字列」を低優先として収集する
|
||||
var settingsDerived = new List<string>();
|
||||
var highPriority = new List<string>();
|
||||
var lowPriority = new List<string>();
|
||||
var seen = new HashSet<string>(StringComparer.Ordinal);
|
||||
|
||||
foreach (var path in scanTargets)
|
||||
{
|
||||
try
|
||||
{
|
||||
var info = new FileInfo(path);
|
||||
if (!info.Exists || info.Length == 0 || info.Length > MaxScanFileSize)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var bytes = File.ReadAllBytes(path);
|
||||
|
||||
// ES3Defaults の encryptionPassword フィールドを持つアセットは、
|
||||
// 値域に格納された文字列をパスワード候補として最優先で回収する
|
||||
CollectFromEs3DefaultSettings(bytes, settingsDerived, seen);
|
||||
|
||||
CollectFromBytes(bytes, highPriority, lowPriority, seen);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
diagnostics?.Add($"読み込み失敗: {Path.GetFileName(path)} ({ex.Message})");
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsDerived.Count > 0)
|
||||
{
|
||||
diagnostics?.Add($"ES3Defaults の encryptionPassword 近傍から {settingsDerived.Count} 件の候補を抽出しました。");
|
||||
}
|
||||
|
||||
// ES3Defaults 由来 → 高優先 → 低優先の順で連結
|
||||
foreach (var candidate in settingsDerived.Concat(highPriority).Concat(lowPriority))
|
||||
{
|
||||
if (result.Count >= 512)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
result.Add(candidate);
|
||||
}
|
||||
|
||||
diagnostics?.Add(
|
||||
$"抽出候補数: {result.Count}(設定由来 {settingsDerived.Count} / 高優先 {highPriority.Count} / 低優先 {lowPriority.Count})");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ES3 の既定設定(<c>ES3Defaults</c>)を持つアセットから、<c>encryptionPassword</c> の値候補を抽出します。
|
||||
///
|
||||
/// Unity のアセットは「フィールド名テーブル」と「値テーブル」が分離しており、
|
||||
/// フィールド名の直後に値があるとは限りません。そのため、フィールド名が存在するアセットでは
|
||||
/// ファイル全体の文字列を候補化しつつ、パスワードらしい短い文字列を優先的に先頭へ寄せます。
|
||||
/// </summary>
|
||||
/// <param name="bytes">アセットのバイト列</param>
|
||||
/// <param name="settingsDerived">設定由来の候補の追加先</param>
|
||||
/// <param name="seen">重複排除用の集合</param>
|
||||
private static void CollectFromEs3DefaultSettings(
|
||||
byte[] bytes,
|
||||
List<string> settingsDerived,
|
||||
HashSet<string> seen)
|
||||
{
|
||||
if (bytes.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 高速化のため、まず encryptionPassword の存在を確認する
|
||||
bool hasField;
|
||||
try
|
||||
{
|
||||
var probeLength = Math.Min(bytes.Length, 4 * 1024 * 1024);
|
||||
var probe = Encoding.ASCII.GetString(bytes, 0, probeLength);
|
||||
hasField = probe.Contains(FieldNameEncryptionPassword, StringComparison.Ordinal);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hasField)
|
||||
{
|
||||
// 巨大アセットでは先頭 4MB に無いことが多いため、全体を再度確認する
|
||||
try
|
||||
{
|
||||
var all = Encoding.ASCII.GetString(bytes);
|
||||
hasField = all.Contains(FieldNameEncryptionPassword, StringComparison.Ordinal);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasField)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// フィールド名が存在するアセットの文字列を候補化する
|
||||
var asciiCandidates = new List<string>();
|
||||
var utf16Candidates = new List<string>();
|
||||
CollectAsciiStrings(bytes, asciiCandidates, asciiCandidates, seen, 0);
|
||||
CollectUtf16Strings(bytes, utf16Candidates, utf16Candidates, seen, 0);
|
||||
|
||||
// 実ゲーム検証では、PlayMaker アクションのスキーマ定義に encryptionPassword が
|
||||
// 並ぶだけで実際の値は別領域にあり、無関係な文字列が大量に候補化されました。
|
||||
// パスワード指定の手がかり(password / encrypt 等)を含む文字列だけに絞り込みます。
|
||||
foreach (var candidate in asciiCandidates.Concat(utf16Candidates))
|
||||
{
|
||||
if (!ContainsPasswordHint(candidate))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (LooksLikePasswordValue(candidate) && !settingsDerived.Contains(candidate))
|
||||
{
|
||||
settingsDerived.Add(candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文字列がパスワード値そのものらしいかを判定します(フィールド名や型名を除外)。
|
||||
/// </summary>
|
||||
/// <param name="candidate">候補文字列</param>
|
||||
/// <returns>パスワード値らしい場合 true</returns>
|
||||
private static bool LooksLikePasswordValue(string candidate)
|
||||
{
|
||||
if (candidate.Length < 3 || candidate.Length > 32)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// ES3 の設定フィールド名・型名は値ではない
|
||||
if (candidate.Equals(FieldNameEncryptionPassword, StringComparison.OrdinalIgnoreCase) ||
|
||||
candidate.Equals("encryptionType", StringComparison.OrdinalIgnoreCase) ||
|
||||
candidate.Equals("compressionType", StringComparison.OrdinalIgnoreCase) ||
|
||||
candidate.Equals("bufferSize", StringComparison.OrdinalIgnoreCase) ||
|
||||
candidate.Equals("errorMessage", StringComparison.OrdinalIgnoreCase) ||
|
||||
candidate.Equals("overrideDefaultSettings", StringComparison.OrdinalIgnoreCase) ||
|
||||
candidate.StartsWith("ES3", StringComparison.Ordinal))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 空白・記号のみのものは除外
|
||||
if (candidate.Contains(' '))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return IsPlausibleCandidate(candidate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 走査対象のファイル一覧を収集します。
|
||||
/// Mono の場合は Managed 配下の DLL、IL2CPP の場合は GameAssembly.dll と global-metadata.dat を対象にします。
|
||||
/// </summary>
|
||||
/// <param name="gameRootDirectory">ゲームのルートディレクトリ</param>
|
||||
/// <returns>走査対象ファイルの絶対パス一覧</returns>
|
||||
private static List<string> CollectScanTargets(string gameRootDirectory)
|
||||
{
|
||||
var targets = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
// 1. Mono: <Game>_Data\Managed\*.dll(Assembly-CSharp.dll を最優先)
|
||||
foreach (var dataDir in Directory.GetDirectories(gameRootDirectory))
|
||||
{
|
||||
if (!Path.GetFileName(dataDir).EndsWith("_Data", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var managedDir = Path.Combine(dataDir, "Managed");
|
||||
if (Directory.Exists(managedDir))
|
||||
{
|
||||
var dlls = Directory.GetFiles(managedDir, "*.dll", SearchOption.TopDirectoryOnly)
|
||||
.Where(f =>
|
||||
{
|
||||
var name = Path.GetFileName(f);
|
||||
return !name.StartsWith("Unity", StringComparison.OrdinalIgnoreCase) &&
|
||||
!name.StartsWith("System", StringComparison.OrdinalIgnoreCase) &&
|
||||
!name.StartsWith("Mono", StringComparison.OrdinalIgnoreCase) &&
|
||||
!name.StartsWith("mscorlib", StringComparison.OrdinalIgnoreCase) &&
|
||||
!name.StartsWith("netstandard", StringComparison.OrdinalIgnoreCase);
|
||||
})
|
||||
.OrderByDescending(f =>
|
||||
Path.GetFileName(f).StartsWith("Assembly-CSharp", StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
|
||||
targets.AddRange(dlls);
|
||||
}
|
||||
|
||||
// 2. IL2CPP: il2cpp_data\Metadata\global-metadata.dat
|
||||
var metadata = Path.Combine(dataDir, "il2cpp_data", "Metadata", "global-metadata.dat");
|
||||
if (File.Exists(metadata))
|
||||
{
|
||||
targets.Add(metadata);
|
||||
}
|
||||
|
||||
// 3. ES3 の既定設定(ES3Defaults ScriptableObject)はアセットに格納されるため、
|
||||
// アセット内の文字列も走査対象に含める。コード側にパスワードリテラルが
|
||||
// 存在しないゲームでは、ここが唯一の手がかりになる。
|
||||
targets.AddRange(CollectAssetTargets(dataDir));
|
||||
}
|
||||
|
||||
// 3. IL2CPP: ルート直下の GameAssembly.dll
|
||||
var gameAssembly = Path.Combine(gameRootDirectory, "GameAssembly.dll");
|
||||
if (File.Exists(gameAssembly))
|
||||
{
|
||||
targets.Add(gameAssembly);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 列挙失敗時は取得できた分だけ返す
|
||||
}
|
||||
|
||||
return targets;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ES3 の既定設定(<c>ES3Defaults</c> ScriptableObject)が格納され得るアセットファイルを収集します。
|
||||
///
|
||||
/// 実ゲーム検証ではコード側にパスワードリテラルが存在せず(<c>encryption</c> 文字列すら無い)、
|
||||
/// 既定設定アセットにのみパスワードが入っているケースがありました。
|
||||
/// 巨大な .resS / .bundle を避け、テキスト情報を持つ .assets 系に限定します。
|
||||
/// </summary>
|
||||
/// <param name="dataDirectory">ゲームの *_Data ディレクトリ</param>
|
||||
/// <returns>走査対象アセットの絶対パス一覧</returns>
|
||||
private static List<string> CollectAssetTargets(string dataDirectory)
|
||||
{
|
||||
var targets = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
var extensionSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
".assets", ".asset", ".json", ".bytes", ".dat"
|
||||
};
|
||||
|
||||
foreach (var file in Directory.GetFiles(dataDirectory, "*", SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
var ext = Path.GetExtension(file);
|
||||
if (!extensionSet.Contains(ext))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var info = new FileInfo(file);
|
||||
if (info.Length == 0 || info.Length > MaxScanFileSize)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
targets.Add(file);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 列挙失敗時は取得できた分だけ返す
|
||||
}
|
||||
|
||||
return targets;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// バイト列から ASCII 文字列を抽出し、優先度別のリストへ振り分けます。
|
||||
///
|
||||
/// .NET アセンブリ(Assembly-CSharp.dll 等)の文字列定数は UTF-16LE で格納されるため、
|
||||
/// 8bit ASCII 走査に加えて 16bit 走査も行います。これを行わないと
|
||||
/// コード中のパスワードリテラルを取り逃がします。
|
||||
/// </summary>
|
||||
/// <param name="bytes">対象バイト列</param>
|
||||
/// <param name="highPriority">パスワード指定近傍の候補の追加先</param>
|
||||
/// <param name="lowPriority">その他の候補の追加先</param>
|
||||
/// <param name="seen">重複排除用の集合</param>
|
||||
private static void CollectFromBytes(
|
||||
byte[] bytes,
|
||||
List<string> highPriority,
|
||||
List<string> lowPriority,
|
||||
HashSet<string> seen)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
count = CollectAsciiStrings(bytes, highPriority, lowPriority, seen, count);
|
||||
if (count >= MaxCandidatesPerFile)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// UTF-16LE(.NET の文字列定数)としても走査する
|
||||
CollectUtf16Strings(bytes, highPriority, lowPriority, seen, count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 8bit ASCII 文字列を抽出します。
|
||||
/// </summary>
|
||||
/// <param name="bytes">対象バイト列</param>
|
||||
/// <param name="highPriority">高優先候補の追加先</param>
|
||||
/// <param name="lowPriority">低優先候補の追加先</param>
|
||||
/// <param name="seen">重複排除用の集合</param>
|
||||
/// <param name="count">既に追加済みの件数</param>
|
||||
/// <returns>追加後の件数</returns>
|
||||
private static int CollectAsciiStrings(
|
||||
byte[] bytes,
|
||||
List<string> highPriority,
|
||||
List<string> lowPriority,
|
||||
HashSet<string> seen,
|
||||
int count)
|
||||
{
|
||||
var current = new StringBuilder(MaxCandidateLength);
|
||||
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
byte b = bytes[i];
|
||||
|
||||
// 印字可能な ASCII のみを文字列として扱う
|
||||
if (b >= 0x21 && b <= 0x7E)
|
||||
{
|
||||
if (current.Length < MaxCandidateLength)
|
||||
{
|
||||
current.Append((char)b);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
count = FlushCandidate(current, highPriority, lowPriority, seen, count);
|
||||
if (count >= MaxCandidatesPerFile)
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
current.Clear();
|
||||
}
|
||||
|
||||
return FlushCandidate(current, highPriority, lowPriority, seen, count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UTF-16LE(下位バイトが印字可能 ASCII、上位バイトが 0x00)の文字列を抽出します。
|
||||
/// </summary>
|
||||
/// <param name="bytes">対象バイト列</param>
|
||||
/// <param name="highPriority">高優先候補の追加先</param>
|
||||
/// <param name="lowPriority">低優先候補の追加先</param>
|
||||
/// <param name="seen">重複排除用の集合</param>
|
||||
/// <param name="count">既に追加済みの件数</param>
|
||||
/// <returns>追加後の件数</returns>
|
||||
private static int CollectUtf16Strings(
|
||||
byte[] bytes,
|
||||
List<string> highPriority,
|
||||
List<string> lowPriority,
|
||||
HashSet<string> seen,
|
||||
int count)
|
||||
{
|
||||
var current = new StringBuilder(MaxCandidateLength);
|
||||
|
||||
for (int i = 0; i + 1 < bytes.Length; i += 2)
|
||||
{
|
||||
byte lo = bytes[i];
|
||||
byte hi = bytes[i + 1];
|
||||
|
||||
if (lo >= 0x21 && lo <= 0x7E && hi == 0x00)
|
||||
{
|
||||
if (current.Length < MaxCandidateLength)
|
||||
{
|
||||
current.Append((char)lo);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
count = FlushCandidate(current, highPriority, lowPriority, seen, count);
|
||||
if (count >= MaxCandidatesPerFile)
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
current.Clear();
|
||||
}
|
||||
|
||||
return FlushCandidate(current, highPriority, lowPriority, seen, count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 蓄積中の文字列を候補として確定し、優先度別リストへ追加します。
|
||||
/// </summary>
|
||||
/// <param name="buffer">蓄積中の文字列バッファ</param>
|
||||
/// <param name="highPriority">高優先候補の追加先</param>
|
||||
/// <param name="lowPriority">低優先候補の追加先</param>
|
||||
/// <param name="seen">重複排除用の集合</param>
|
||||
/// <param name="count">既に追加済みの件数</param>
|
||||
/// <returns>追加後の件数</returns>
|
||||
private static int FlushCandidate(
|
||||
StringBuilder buffer,
|
||||
List<string> highPriority,
|
||||
List<string> lowPriority,
|
||||
HashSet<string> seen,
|
||||
int count)
|
||||
{
|
||||
if (buffer.Length < MinCandidateLength || buffer.Length > MaxCandidateLength)
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
var candidate = buffer.ToString();
|
||||
if (!IsPlausibleCandidate(candidate) || !seen.Add(candidate))
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
if (ContainsPasswordHint(candidate))
|
||||
{
|
||||
highPriority.Add(candidate);
|
||||
}
|
||||
else
|
||||
{
|
||||
lowPriority.Add(candidate);
|
||||
}
|
||||
|
||||
return count + 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 抽出した文字列がパスワード候補として妥当かどうかを判定します。
|
||||
/// </summary>
|
||||
/// <param name="candidate">候補文字列</param>
|
||||
/// <returns>妥当な場合 true</returns>
|
||||
private static bool IsPlausibleCandidate(string candidate)
|
||||
{
|
||||
if (!CandidatePattern.IsMatch(candidate))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 空白を含む説明文・UI ラベルは除外
|
||||
if (SentenceLikePattern.IsMatch(candidate))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Unity の内部名・名前空間などはノイズとして除外
|
||||
if (NoisePattern.IsMatch(candidate))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 拡張子付きファイル名は除外
|
||||
if (candidate.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) ||
|
||||
candidate.EndsWith(".dat", StringComparison.OrdinalIgnoreCase) ||
|
||||
candidate.EndsWith(".es3", StringComparison.OrdinalIgnoreCase) ||
|
||||
candidate.EndsWith(".json", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文字列がパスワード指定箇所の手がかりを含むかを判定します。
|
||||
/// </summary>
|
||||
/// <param name="candidate">候補文字列</param>
|
||||
/// <returns>手がかりを含む場合 true</returns>
|
||||
private static bool ContainsPasswordHint(string candidate)
|
||||
{
|
||||
foreach (var hint in PasswordHints)
|
||||
{
|
||||
if (candidate.Contains(hint, StringComparison.Ordinal))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user