This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d8426a
commit a191156
Showing
21 changed files
with
942 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{9C7A7E96-A9D9-4D5B-9F70-8B84D1C50B5D}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>LoGiC.NET</RootNamespace> | ||
<AssemblyName>LoGiC.NET</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="dnlib, Version=3.3.1.0, Culture=neutral, PublicKeyToken=50e96378b6e77999, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\dnlib.3.3.1\lib\net45\dnlib.dll</HintPath> | ||
</Reference> | ||
<Reference Include="SharpConfigParser"> | ||
<HintPath>..\..\..\..\Desktop\My Projects\Goldfuscator\Goldfuscator Project\Goldfuscator\bin\Debug\SharpConfigParser.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Protections\IntEncoding.cs" /> | ||
<Compile Include="Protections\JunkMethods.cs" /> | ||
<Compile Include="Protections\ProxyAdder.cs" /> | ||
<Compile Include="Protections\Renamer.cs" /> | ||
<Compile Include="Protections\StringEncryption.cs" /> | ||
<Compile Include="Utils\Analyzer\DefAnalyzer.cs" /> | ||
<Compile Include="Utils\Analyzer\EventDefAnalyzer.cs" /> | ||
<Compile Include="Utils\Analyzer\FieldDefAnalyzer.cs" /> | ||
<Compile Include="Utils\Analyzer\MethodDefAnalyzer.cs" /> | ||
<Compile Include="Utils\Analyzer\ParameterAnalyzer.cs" /> | ||
<Compile Include="Utils\Analyzer\TypeDefAnalyzer.cs" /> | ||
<Compile Include="Utils\InjectContext.cs" /> | ||
<Compile Include="Utils\ProxyExtension.cs" /> | ||
<Compile Include="Utils\Randomizer.cs" /> | ||
<Compile Include="Utils\Reference.cs" /> | ||
<Compile Include="Utils\Watermark.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup /> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using System.IO; | ||
using dnlib.DotNet; | ||
using dnlib.DotNet.Writer; | ||
using LoGiC.NET.Protections; | ||
using SharpConfigParser; | ||
using LoGiC.NET.Utils; | ||
|
||
namespace LoGiC.NET | ||
{ | ||
class Program | ||
{ | ||
public static ModuleDefMD Module { get; set; } | ||
|
||
public static string FileExtension { get; set; } | ||
|
||
public static bool DontRename { get; set; } | ||
public static bool ForceWinForms { get; set; } | ||
|
||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine("Drag & drop your file : "); | ||
string path = Console.ReadLine(); | ||
|
||
Console.WriteLine("Preparing obfuscation..."); | ||
Parser p = new Parser() { ConfigFile = "config.txt" }; | ||
ForceWinForms = bool.Parse(p.Read("ForceWinFormsCompatibility").ReadResponse().ReplaceSpaces()); | ||
DontRename = bool.Parse(p.Read("DontRename").ReadResponse().ReplaceSpaces()); | ||
|
||
Module = ModuleDefMD.Load(path); | ||
FileExtension = Path.GetExtension(path); | ||
|
||
Console.WriteLine("Renaming..."); | ||
Renamer.Execute(); | ||
|
||
Console.WriteLine("Adding junk methods..."); | ||
JunkMethods.Execute(); | ||
|
||
Console.WriteLine("Adding proxy calls..."); | ||
ProxyAdder.Execute(); | ||
|
||
Console.WriteLine("Encoding ints..."); | ||
IntEncoding.Execute(); | ||
|
||
Console.WriteLine("Encrypting strings..."); | ||
StringEncryption.Execute(); | ||
|
||
Console.WriteLine("Watermarking..."); | ||
Watermark.AddAttribute(); | ||
|
||
Console.WriteLine("Saving file..."); | ||
ModuleWriterOptions opts = new ModuleWriterOptions(Module) { Logger = DummyLogger.NoThrowInstance }; | ||
Module.Write(@"C:\Users\" + Environment.UserName + @"\Desktop\" + Path.GetFileNameWithoutExtension(path) + "_protected" + | ||
FileExtension, opts); | ||
|
||
Console.WriteLine("Done! Press any key to exit..."); | ||
Console.ReadKey(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// Les informations générales relatives à un assembly dépendent de | ||
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations | ||
// associées à un assembly. | ||
[assembly: AssemblyTitle("LoGiC.NET")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("LoGiC.NET")] | ||
[assembly: AssemblyCopyright("Copyright © 2019")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly | ||
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de | ||
// COM, affectez la valeur true à l'attribut ComVisible sur ce type. | ||
[assembly: ComVisible(false)] | ||
|
||
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM | ||
[assembly: Guid("9c7a7e96-a9d9-4d5b-9f70-8b84d1c50b5d")] | ||
|
||
// Les informations de version pour un assembly se composent des quatre valeurs suivantes : | ||
// | ||
// Version principale | ||
// Version secondaire | ||
// Numéro de build | ||
// Révision | ||
// | ||
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut | ||
// en utilisant '*', comme indiqué ci-dessous : | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using dnlib.DotNet; | ||
using dnlib.DotNet.Emit; | ||
using LoGiC.NET.Utils; | ||
|
||
namespace LoGiC.NET.Protections | ||
{ | ||
public class IntEncoding : Randomizer | ||
{ | ||
/// <summary> | ||
/// The amount of encoded ints. | ||
/// </summary> | ||
private static int Amount { get; set; } | ||
|
||
/// <summary> | ||
/// Execution of the 'IntEncoding' method. It'll encodes the integers within different methods. | ||
/// Absolute : This method will add Math.Abs(int) before each integer. | ||
/// StringLen : This method will replace each integer by their string equivalent. | ||
/// </summary> | ||
public static void Execute() | ||
{ | ||
foreach (TypeDef type in Program.Module.Types) | ||
foreach (MethodDef method in type.Methods) | ||
{ | ||
if (!method.HasBody) continue; | ||
for (int i = 0; i < method.Body.Instructions.Count; i++) | ||
if (method.Body.Instructions[i].IsLdcI4()) | ||
{ | ||
int operand = method.Body.Instructions[i].GetLdcI4Value(); | ||
if (operand <= 0) continue; | ||
method.Body.Instructions.Insert(i + 1, OpCodes.Call.ToInstruction( | ||
Program.Module.Import(typeof(Math).GetMethod("Abs", new Type[] { typeof(int) })))); | ||
++Amount; | ||
} | ||
} | ||
|
||
foreach (TypeDef type in Program.Module.Types) | ||
foreach (MethodDef method in type.Methods) | ||
{ | ||
if (!method.HasBody) continue; | ||
for (int i = 0; i < method.Body.Instructions.Count; i++) | ||
if (method.Body.Instructions[i].IsLdcI4()) | ||
{ | ||
int operand = method.Body.Instructions[i].GetLdcI4Value(); | ||
if (operand <= 0) continue; | ||
method.Body.Instructions[i].OpCode = OpCodes.Ldstr; | ||
method.Body.Instructions[i].Operand = GenerateRandomString(operand); | ||
method.Body.Instructions.Insert(i + 1, OpCodes.Call.ToInstruction( | ||
Program.Module.Import(typeof(string).GetMethod("get_Length")))); | ||
++Amount; | ||
} | ||
} | ||
|
||
Console.WriteLine($"Encoded {Amount} ints."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using LoGiC.NET.Utils; | ||
using dnlib.DotNet; | ||
using dnlib.DotNet.Emit; | ||
|
||
namespace LoGiC.NET.Protections | ||
{ | ||
public class JunkMethods : Randomizer | ||
{ | ||
/// <summary> | ||
/// The amount of added junk methods. | ||
/// </summary> | ||
private static int Amount { get; set; } | ||
|
||
/// <summary> | ||
/// This obfuscation will add random junk methods to make the code harder to decrypt to people if they think the junk methods are actually used. | ||
/// </summary> | ||
public static void Execute() | ||
{ | ||
foreach (TypeDef type in Program.Module.Types) | ||
{ | ||
if (type.IsGlobalModuleType) continue; | ||
foreach (MethodDef _ in type.Methods.ToArray()) | ||
{ | ||
MethodDef strings = CreateReturnMethodDef(GenerateRandomString(Next(700, 500)), Program.Module); | ||
MethodDef ints = CreateReturnMethodDef(Next(500, 100), Program.Module); | ||
type.Methods.Add(strings); | ||
++Amount; | ||
type.Methods.Add(ints); | ||
++Amount; | ||
} | ||
} | ||
Console.WriteLine($"Added {Amount} junk methods."); | ||
} | ||
|
||
/// <summary> | ||
/// The return value for the randomly generated method. It can be an integer or a string. | ||
/// </summary> | ||
private static MethodDef CreateReturnMethodDef(object value, ModuleDefMD module) | ||
{ | ||
CorLibTypeSig corlib = null; | ||
if (value is int) corlib = module.CorLibTypes.Int32; | ||
else if (value is string) corlib = module.CorLibTypes.String; | ||
|
||
MethodDef newMethod = new MethodDefUser(GenerateRandomString(Next(700, 500)), | ||
MethodSig.CreateStatic(corlib), | ||
MethodImplAttributes.IL | MethodImplAttributes.Managed, | ||
MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.HideBySig) | ||
{ | ||
Body = new CilBody() | ||
}; | ||
if (value is int) | ||
newMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Ldc_I4, Convert.ToInt32(value))); | ||
else if (value is string) | ||
newMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Ldstr, value.ToString())); | ||
newMethod.Body.Instructions.Add(OpCodes.Ret.ToInstruction()); | ||
|
||
return newMethod; | ||
} | ||
} | ||
} |
Oops, something went wrong.