Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit a191156

Browse files
authored
Add files via upload
1 parent 8d8426a commit a191156

21 files changed

+942
-0
lines changed

App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>

LoGiC.NET.csproj

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{9C7A7E96-A9D9-4D5B-9F70-8B84D1C50B5D}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>LoGiC.NET</RootNamespace>
10+
<AssemblyName>LoGiC.NET</AssemblyName>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="dnlib, Version=3.3.1.0, Culture=neutral, PublicKeyToken=50e96378b6e77999, processorArchitecture=MSIL">
37+
<HintPath>..\packages\dnlib.3.3.1\lib\net45\dnlib.dll</HintPath>
38+
</Reference>
39+
<Reference Include="SharpConfigParser">
40+
<HintPath>..\..\..\..\Desktop\My Projects\Goldfuscator\Goldfuscator Project\Goldfuscator\bin\Debug\SharpConfigParser.dll</HintPath>
41+
</Reference>
42+
<Reference Include="System" />
43+
<Reference Include="System.Core" />
44+
<Reference Include="System.Xml.Linq" />
45+
<Reference Include="System.Data.DataSetExtensions" />
46+
<Reference Include="Microsoft.CSharp" />
47+
<Reference Include="System.Data" />
48+
<Reference Include="System.Net.Http" />
49+
<Reference Include="System.Xml" />
50+
</ItemGroup>
51+
<ItemGroup>
52+
<Compile Include="Program.cs" />
53+
<Compile Include="Properties\AssemblyInfo.cs" />
54+
<Compile Include="Protections\IntEncoding.cs" />
55+
<Compile Include="Protections\JunkMethods.cs" />
56+
<Compile Include="Protections\ProxyAdder.cs" />
57+
<Compile Include="Protections\Renamer.cs" />
58+
<Compile Include="Protections\StringEncryption.cs" />
59+
<Compile Include="Utils\Analyzer\DefAnalyzer.cs" />
60+
<Compile Include="Utils\Analyzer\EventDefAnalyzer.cs" />
61+
<Compile Include="Utils\Analyzer\FieldDefAnalyzer.cs" />
62+
<Compile Include="Utils\Analyzer\MethodDefAnalyzer.cs" />
63+
<Compile Include="Utils\Analyzer\ParameterAnalyzer.cs" />
64+
<Compile Include="Utils\Analyzer\TypeDefAnalyzer.cs" />
65+
<Compile Include="Utils\InjectContext.cs" />
66+
<Compile Include="Utils\ProxyExtension.cs" />
67+
<Compile Include="Utils\Randomizer.cs" />
68+
<Compile Include="Utils\Reference.cs" />
69+
<Compile Include="Utils\Watermark.cs" />
70+
</ItemGroup>
71+
<ItemGroup>
72+
<None Include="App.config" />
73+
<None Include="packages.config" />
74+
</ItemGroup>
75+
<ItemGroup />
76+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
77+
</Project>

Program.cs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using System;
2+
using System.IO;
3+
using dnlib.DotNet;
4+
using dnlib.DotNet.Writer;
5+
using LoGiC.NET.Protections;
6+
using SharpConfigParser;
7+
using LoGiC.NET.Utils;
8+
9+
namespace LoGiC.NET
10+
{
11+
class Program
12+
{
13+
public static ModuleDefMD Module { get; set; }
14+
15+
public static string FileExtension { get; set; }
16+
17+
public static bool DontRename { get; set; }
18+
public static bool ForceWinForms { get; set; }
19+
20+
static void Main(string[] args)
21+
{
22+
Console.WriteLine("Drag & drop your file : ");
23+
string path = Console.ReadLine();
24+
25+
Console.WriteLine("Preparing obfuscation...");
26+
Parser p = new Parser() { ConfigFile = "config.txt" };
27+
ForceWinForms = bool.Parse(p.Read("ForceWinFormsCompatibility").ReadResponse().ReplaceSpaces());
28+
DontRename = bool.Parse(p.Read("DontRename").ReadResponse().ReplaceSpaces());
29+
30+
Module = ModuleDefMD.Load(path);
31+
FileExtension = Path.GetExtension(path);
32+
33+
Console.WriteLine("Renaming...");
34+
Renamer.Execute();
35+
36+
Console.WriteLine("Adding junk methods...");
37+
JunkMethods.Execute();
38+
39+
Console.WriteLine("Adding proxy calls...");
40+
ProxyAdder.Execute();
41+
42+
Console.WriteLine("Encoding ints...");
43+
IntEncoding.Execute();
44+
45+
Console.WriteLine("Encrypting strings...");
46+
StringEncryption.Execute();
47+
48+
Console.WriteLine("Watermarking...");
49+
Watermark.AddAttribute();
50+
51+
Console.WriteLine("Saving file...");
52+
ModuleWriterOptions opts = new ModuleWriterOptions(Module) { Logger = DummyLogger.NoThrowInstance };
53+
Module.Write(@"C:\Users\" + Environment.UserName + @"\Desktop\" + Path.GetFileNameWithoutExtension(path) + "_protected" +
54+
FileExtension, opts);
55+
56+
Console.WriteLine("Done! Press any key to exit...");
57+
Console.ReadKey();
58+
}
59+
}
60+
}

Properties/AssemblyInfo.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// Les informations générales relatives à un assembly dépendent de
6+
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
7+
// associées à un assembly.
8+
[assembly: AssemblyTitle("LoGiC.NET")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("LoGiC.NET")]
13+
[assembly: AssemblyCopyright("Copyright © 2019")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
18+
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
19+
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
20+
[assembly: ComVisible(false)]
21+
22+
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
23+
[assembly: Guid("9c7a7e96-a9d9-4d5b-9f70-8b84d1c50b5d")]
24+
25+
// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
26+
//
27+
// Version principale
28+
// Version secondaire
29+
// Numéro de build
30+
// Révision
31+
//
32+
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
33+
// en utilisant '*', comme indiqué ci-dessous :
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

Protections/IntEncoding.cs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using dnlib.DotNet;
7+
using dnlib.DotNet.Emit;
8+
using LoGiC.NET.Utils;
9+
10+
namespace LoGiC.NET.Protections
11+
{
12+
public class IntEncoding : Randomizer
13+
{
14+
/// <summary>
15+
/// The amount of encoded ints.
16+
/// </summary>
17+
private static int Amount { get; set; }
18+
19+
/// <summary>
20+
/// Execution of the 'IntEncoding' method. It'll encodes the integers within different methods.
21+
/// Absolute : This method will add Math.Abs(int) before each integer.
22+
/// StringLen : This method will replace each integer by their string equivalent.
23+
/// </summary>
24+
public static void Execute()
25+
{
26+
foreach (TypeDef type in Program.Module.Types)
27+
foreach (MethodDef method in type.Methods)
28+
{
29+
if (!method.HasBody) continue;
30+
for (int i = 0; i < method.Body.Instructions.Count; i++)
31+
if (method.Body.Instructions[i].IsLdcI4())
32+
{
33+
int operand = method.Body.Instructions[i].GetLdcI4Value();
34+
if (operand <= 0) continue;
35+
method.Body.Instructions.Insert(i + 1, OpCodes.Call.ToInstruction(
36+
Program.Module.Import(typeof(Math).GetMethod("Abs", new Type[] { typeof(int) }))));
37+
++Amount;
38+
}
39+
}
40+
41+
foreach (TypeDef type in Program.Module.Types)
42+
foreach (MethodDef method in type.Methods)
43+
{
44+
if (!method.HasBody) continue;
45+
for (int i = 0; i < method.Body.Instructions.Count; i++)
46+
if (method.Body.Instructions[i].IsLdcI4())
47+
{
48+
int operand = method.Body.Instructions[i].GetLdcI4Value();
49+
if (operand <= 0) continue;
50+
method.Body.Instructions[i].OpCode = OpCodes.Ldstr;
51+
method.Body.Instructions[i].Operand = GenerateRandomString(operand);
52+
method.Body.Instructions.Insert(i + 1, OpCodes.Call.ToInstruction(
53+
Program.Module.Import(typeof(string).GetMethod("get_Length"))));
54+
++Amount;
55+
}
56+
}
57+
58+
Console.WriteLine($"Encoded {Amount} ints.");
59+
}
60+
}
61+
}

Protections/JunkMethods.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using LoGiC.NET.Utils;
7+
using dnlib.DotNet;
8+
using dnlib.DotNet.Emit;
9+
10+
namespace LoGiC.NET.Protections
11+
{
12+
public class JunkMethods : Randomizer
13+
{
14+
/// <summary>
15+
/// The amount of added junk methods.
16+
/// </summary>
17+
private static int Amount { get; set; }
18+
19+
/// <summary>
20+
/// 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.
21+
/// </summary>
22+
public static void Execute()
23+
{
24+
foreach (TypeDef type in Program.Module.Types)
25+
{
26+
if (type.IsGlobalModuleType) continue;
27+
foreach (MethodDef _ in type.Methods.ToArray())
28+
{
29+
MethodDef strings = CreateReturnMethodDef(GenerateRandomString(Next(700, 500)), Program.Module);
30+
MethodDef ints = CreateReturnMethodDef(Next(500, 100), Program.Module);
31+
type.Methods.Add(strings);
32+
++Amount;
33+
type.Methods.Add(ints);
34+
++Amount;
35+
}
36+
}
37+
Console.WriteLine($"Added {Amount} junk methods.");
38+
}
39+
40+
/// <summary>
41+
/// The return value for the randomly generated method. It can be an integer or a string.
42+
/// </summary>
43+
private static MethodDef CreateReturnMethodDef(object value, ModuleDefMD module)
44+
{
45+
CorLibTypeSig corlib = null;
46+
if (value is int) corlib = module.CorLibTypes.Int32;
47+
else if (value is string) corlib = module.CorLibTypes.String;
48+
49+
MethodDef newMethod = new MethodDefUser(GenerateRandomString(Next(700, 500)),
50+
MethodSig.CreateStatic(corlib),
51+
MethodImplAttributes.IL | MethodImplAttributes.Managed,
52+
MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.HideBySig)
53+
{
54+
Body = new CilBody()
55+
};
56+
if (value is int)
57+
newMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Ldc_I4, Convert.ToInt32(value)));
58+
else if (value is string)
59+
newMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Ldstr, value.ToString()));
60+
newMethod.Body.Instructions.Add(OpCodes.Ret.ToInstruction());
61+
62+
return newMethod;
63+
}
64+
}
65+
}

0 commit comments

Comments
 (0)