r197 vs r198
......
5757
아무리 생각해도 EnableAntiDebugChecks는 오탐지 가능성이 있다. 블랙 리스트에 추가되도록 할지 생각중...
5858
GZipStream을 이용해서 저장 용량을 50% 줄여보기.
5959
60
=== 본 코드 ===
60
=== 본코드 ===
6161
{{{#!syntax csharp
6262
using System;
6363
using System.IO;
6464
using System.Security.Cryptography;
6565
using System.Text;
6666
using UnityEngine;
67
using System.Diagnostics;
6867
using System.Runtime.CompilerServices;
6968
7069
[Serializable]
......
110109
Instance = this;
111110
DontDestroyOnLoad(gameObject);
112111
113
sessionNonce = GenerateRandomBytes(16);
112
sessionNonce = LoadOrCreateSessionNonce();
114113
filePath = Path.Combine(Application.persistentDataPath, ResolveFileName("playerData"));
115114
Warmup();
116115
}
117116
117
private byte[] LoadOrCreateSessionNonce()
118
{
119
const string key = "SecureManager_SessionNonce_v1";
120
try
121
{
122
if (PlayerPrefs.HasKey(key))
123
{
124
string b64 = PlayerPrefs.GetString(key);
125
byte[] stored = Convert.FromBase64String(b64);
126
if (stored != null && stored.Length > 0) return stored;
127
}
128
}
129
catch { }
130
131
byte[] nonce = GenerateRandomBytes(16);
132
try
133
{
134
PlayerPrefs.SetString(key, Convert.ToBase64String(nonce));
135
PlayerPrefs.Save();
136
}
137
catch { }
138
return nonce;
139
}
140
118141
private void Warmup()
119142
{
120143
try { _ = GetSecretBytes(); } catch { }
......
177200
}
178201
179202
byte[] s1 = DumbMixA(k);
180
int dynamicSeed = (int)(DateTime.UtcNow.Ticks ^ Application.identifier.GetHashCode() ^ Environment.TickCount);
181
byte[] s2 = DumbMixB(s1, dynamicSeed);
203
204
// 시간 의존 제거, 디바이스 기반 결정적 시드
205
int deviceSeed = Application.identifier.GetHashCode() ^ SystemInfo.deviceUniqueIdentifier.GetHashCode();
206
207
byte[] s2 = DumbMixB(s1, deviceSeed);
182208
byte[] s3 = DumbMixC(s2, sessionNonce);
183209
for (int r = 0; r < 2; r++)
184210
{
185211
byte[] t = DumbMixA(s3);
186
byte[] u = DumbMixB(t, dynamicSeed ^ r);
212
byte[] u = DumbMixB(t, deviceSeed ^ r);
187213
for (int i = 0; i < k.Length; i++) s3[i] = (byte)(s3[i] ^ u[i % u.Length]);
188214
Array.Clear(t, 0, t.Length);
189215
Array.Clear(u, 0, u.Length);
190216
}
191217
Array.Clear(s1, 0, s1.Length);
192218
Array.Clear(s2, 0, s2.Length);
219
193220
byte[] result = new byte[k.Length];
194221
for (int i = 0; i < k.Length; i++) result[i] = (byte)(k[i] ^ s3[i % s3.Length]);
195222
Array.Clear(k, 0, k.Length);
......
382409
{
383410
if (EnableAntiDebugChecks)
384411
{
385
if (Debug.isDebugBuild) return true;
386
if (Debugger.IsAttached) return true;
412
if (System.Diagnostics.Debugger.IsAttached) return true;
413
if (System.Diagnostics.Process.GetCurrentProcess().ProcessName.ToLower().Contains("debug")) return true;
387414
}
388415
}
389416
catch { }
......
398425
catch { }
399426
return false;
400427
}
401
} }}}
402
428
}
429
}}}
403430
=== 실행 코드 ===
404431
{{{#!syntax csharp
405432
using UnityEngine;
......