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

Commit 083b855

Browse files
author
Zaczero
committed
Merge
2 parents 67390e1 + f06d858 commit 083b855

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

SharpLoader/Core/RuntimeCompiler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.CodeDom.Compiler;
3+
using System.Collections.Generic;
34
using System.Diagnostics;
45
using Microsoft.CSharp;
56

@@ -11,7 +12,7 @@ public class RuntimeCompiler
1112

1213
public RuntimeCompiler()
1314
{
14-
_compiler = new CSharpCodeProvider();
15+
_compiler = new CSharpCodeProvider(new Dictionary<string, string> { { "CompilerVersion", "v4.0" } });
1516
}
1617

1718
public bool Compile(string outputName, string compilerArguments, string[] assemblies, params string[] sources)

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: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,8 @@ namespace SharpLoader
1111
{
1212
public class Program
1313
{
14-
/* Bugs:
15-
*/
16-
1714
/* Limitations:
18-
* doesn't support $ strings
19-
* doesn't support @ strings
20-
* doesn't support VS code
21-
* doesn't support => properties
22-
* doesn't support few unicode values
15+
* supports only c# 5.0
2316
*/
2417

2518
/* Exit codes:
@@ -325,7 +318,7 @@ public static void Main(string[] args)
325318

326319
// Inject references
327320
var compileReferences = userReferences.ToList();
328-
foreach (var t in randomizer.InjectAssemblies)
321+
foreach (var t in randomizer.InjectReferences)
329322
{
330323
if (compileReferences.All(a => a != t))
331324
{
@@ -344,11 +337,15 @@ public static void Main(string[] args)
344337
Process.Start(outputName);
345338
}
346339

347-
var outputBytes = File.ReadAllBytes(outputName);
348-
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());
349346

350347
Console.ForegroundColor = ConsoleColor.Yellow;
351-
Console.WriteLine($"-=: MD5 : {ByteArrayToString(hash)}");
348+
Console.WriteLine($"-=: MD5 : {ByteArrayToString(sourceHash)}");
352349

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

0 commit comments

Comments
 (0)