Skip to content
This repository was archived by the owner on Oct 5, 2019. It is now read-only.

Commit f06d858

Browse files
author
Kamil Monicz
committed
Calculate MD5 hash from source files instead of compiled file
1 parent 4eda91f commit f06d858

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

SharpLoader/Core/SourceRandomizer.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace SharpLoader.Core
1010
public class SourceRandomizer
1111
{
1212
public readonly List<string> InjectSources = new List<string>();
13-
public readonly List<string> InjectAssemblies = new List<string>();
13+
public readonly List<string> InjectReferences = new List<string>();
1414

1515
public readonly string InjectBytesNamespace;
1616
public readonly string InjectBytesClass;
@@ -695,7 +695,7 @@ private void Encrypt(ref string str)
695695
$"}}" +
696696
$"}}");
697697

698-
InjectAssemblies.Add("System.dll");
698+
InjectReferences.Add("System.dll");
699699

700700
_stringDecryptorInjected = true;
701701
_stringDecryptorFunction = $"{namespaceName}.{className}.{funcName}";
@@ -781,7 +781,7 @@ private void Encrypt(ref string str)
781781
$"}}" +
782782
$"}}");
783783

784-
InjectAssemblies.Add("System.dll");
784+
InjectReferences.Add("System.dll");
785785

786786
_charDecryptorInjected = true;
787787
_charDecryptorFunction = $"{namespaceName}.{className}.{funcName}";
@@ -866,7 +866,7 @@ private void Encrypt(ref string str)
866866
$"}}" +
867867
$"}}");
868868

869-
InjectAssemblies.Add("System.dll");
869+
InjectReferences.Add("System.dll");
870870

871871
_valueDecryptorInjected = true;
872872
_valueDecryptorFunction = $"{namespaceName}.{className}.{funcName}";
@@ -1126,7 +1126,7 @@ private void Flow(ref string str)
11261126
$"}}" +
11271127
$"}}");
11281128

1129-
InjectAssemblies.Add("System.dll");
1129+
InjectReferences.Add("System.dll");
11301130

11311131
_xorDecryptorInjected = true;
11321132
_xorDecryptorFunction = $"{namespaceName}.{className}.{funcName}";

SharpLoader/Program.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public static void Main(string[] args)
318318

319319
// Inject references
320320
var compileReferences = userReferences.ToList();
321-
foreach (var t in randomizer.InjectAssemblies)
321+
foreach (var t in randomizer.InjectReferences)
322322
{
323323
if (compileReferences.All(a => a != t))
324324
{
@@ -337,11 +337,15 @@ public static void Main(string[] args)
337337
Process.Start(outputName);
338338
}
339339

340-
var outputBytes = File.ReadAllBytes(outputName);
341-
var hash = MD5.Create().ComputeHash(outputBytes);
340+
var sourceBytes = new List<byte>();
341+
foreach (var s in compileSourceFiles)
342+
{
343+
sourceBytes.AddRange(Encoding.Default.GetBytes(s));
344+
}
345+
var sourceHash = MD5.Create().ComputeHash(sourceBytes.ToArray());
342346

343347
Console.ForegroundColor = ConsoleColor.Yellow;
344-
Console.WriteLine($"-=: MD5 : {ByteArrayToString(hash)}");
348+
Console.WriteLine($"-=: MD5 : {ByteArrayToString(sourceHash)}");
345349

346350
Console.ForegroundColor = ConsoleColor.Green;
347351
Console.Write($"-=: DONE [{outputName}] (press any key to exit)");

0 commit comments

Comments
 (0)