Skip to content
This repository was archived by the owner on Apr 17, 2022. It is now read-only.

Commit 951e2b7

Browse files
author
Sharkbyteprojects
committed
Projektdateien hinzufügen.
1 parent 6c7e33e commit 951e2b7

10 files changed

Lines changed: 371 additions & 0 deletions

File tree

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Sharkbyteprojects
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
USAGE: Drag and drop your IL file onto the executable of compilertools and it will add some debug Console.WriteLine

compilerTool/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>

compilerTool/Csharp decompiler.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using ICSharpCode.Decompiler;
2+
using ICSharpCode.Decompiler.CSharp;
3+
using ICSharpCode.Decompiler.TypeSystem;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.IO;
7+
using System.Linq;
8+
using System.Net.Http;
9+
using System.Threading;
10+
using System.Threading.Tasks;
11+
12+
13+
namespace compilerTools
14+
{
15+
class Csharp_decompiler : @base
16+
{
17+
public Csharp_decompiler()
18+
{
19+
id = "ICSharpCode.Decompiler";
20+
sid = "namespaces";
21+
}
22+
public override void writeFile()
23+
{
24+
base.writeFile();
25+
File.WriteAllText(string.Format("{0}.decompiled{1}.cs", Path.GetFileNameWithoutExtension(filename), Path.GetExtension(filename)), module);
26+
}
27+
public override void runPayload()
28+
{
29+
base.runPayload();
30+
var decompiler = new CSharpDecompiler(filename, new DecompilerSettings());
31+
32+
module = decompiler.DecompileWholeModuleAsString();
33+
INamespace icsdns = decompiler.TypeSystem.RootNamespace;
34+
foreach (var ns in icsdns.ChildNamespaces) namespacess.Add(ns.FullName);
35+
}
36+
}
37+
}

compilerTool/Program.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using compilerTools;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Net.Http;
7+
using System.Threading;
8+
using System.Threading.Tasks;
9+
10+
11+
class Prog
12+
{
13+
public static void Main(String[] args)
14+
{
15+
List<@base> r = new List<@base>();
16+
r.Add(new Csharp_decompiler());
17+
r.Add(new il_decoMod());
18+
19+
if (args.Length > 0)
20+
{
21+
foreach (var e in args)
22+
{
23+
if (File.Exists(e))
24+
{
25+
Console.WriteLine(string.Concat("Working on: ", e));
26+
foreach (var t in r)
27+
{
28+
Console.WriteLine(string.Concat("\tRun: ", t.id));
29+
try
30+
{
31+
t.setWorkOn(e);
32+
t.runPayload();
33+
t.writeFile();
34+
if (t.namespacess.Count > 0)
35+
{
36+
Console.WriteLine($"\t\t{t.sid}:");
37+
foreach (var n in t.namespacess)
38+
{
39+
Console.WriteLine(string.Concat("\t\t- ", n));
40+
}
41+
}
42+
}
43+
catch (Exception ex)
44+
{
45+
Console.WriteLine(string.Concat("\t\tERROR:", ex.Message));
46+
}
47+
Console.WriteLine(string.Concat("\tCompleted: ", t.id));
48+
}
49+
Console.WriteLine(string.Concat("Completed on: ", e, "\n"));
50+
}
51+
}
52+
}
53+
else
54+
Console.WriteLine("YOU SHOULD OPEN A FILE WITH THIS APPLICATION!");
55+
}
56+
}

compilerTool/base.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Net.Http;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
9+
namespace compilerTools
10+
{
11+
class @base
12+
{
13+
public string id = "";
14+
public virtual void writeFile() { }
15+
protected string filename = "";
16+
public string moduleType = "", module = "", sid = "";
17+
public List<string> namespacess = new List<string>();
18+
public void setWorkOn(string w) { filename = w; }
19+
public virtual void runPayload() { clean(); }
20+
public virtual void clean() { namespacess.Clear(); moduleType = ""; module = ""; }
21+
}
22+
}

compilerTool/compilerTool.csproj

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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>{B7404E02-580D-436E-BC38-5787137F6D04}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>compilerTool</RootNamespace>
10+
<AssemblyName>compilerTool</AssemblyName>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
<IsWebBootstrapper>false</IsWebBootstrapper>
16+
<PublishUrl>publish\</PublishUrl>
17+
<Install>true</Install>
18+
<InstallFrom>Disk</InstallFrom>
19+
<UpdateEnabled>false</UpdateEnabled>
20+
<UpdateMode>Foreground</UpdateMode>
21+
<UpdateInterval>7</UpdateInterval>
22+
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
23+
<UpdatePeriodically>false</UpdatePeriodically>
24+
<UpdateRequired>false</UpdateRequired>
25+
<MapFileExtensions>true</MapFileExtensions>
26+
<ApplicationRevision>0</ApplicationRevision>
27+
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
28+
<UseApplicationTrust>false</UseApplicationTrust>
29+
<BootstrapperEnabled>true</BootstrapperEnabled>
30+
</PropertyGroup>
31+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
32+
<PlatformTarget>AnyCPU</PlatformTarget>
33+
<DebugSymbols>true</DebugSymbols>
34+
<DebugType>full</DebugType>
35+
<Optimize>false</Optimize>
36+
<OutputPath>bin\Debug\</OutputPath>
37+
<DefineConstants>DEBUG;TRACE</DefineConstants>
38+
<ErrorReport>prompt</ErrorReport>
39+
<WarningLevel>4</WarningLevel>
40+
</PropertyGroup>
41+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
42+
<PlatformTarget>AnyCPU</PlatformTarget>
43+
<DebugType>pdbonly</DebugType>
44+
<Optimize>true</Optimize>
45+
<OutputPath>bin\Release\</OutputPath>
46+
<DefineConstants>TRACE</DefineConstants>
47+
<ErrorReport>prompt</ErrorReport>
48+
<WarningLevel>4</WarningLevel>
49+
</PropertyGroup>
50+
<ItemGroup>
51+
<None Include="App.config" />
52+
<None Include="packages.config" />
53+
</ItemGroup>
54+
<ItemGroup>
55+
<Reference Include="ICSharpCode.Decompiler, Version=7.2.1.6856, Culture=neutral, PublicKeyToken=d4bfe873e7598c49, processorArchitecture=MSIL">
56+
<HintPath>..\packages\ICSharpCode.Decompiler.7.2.1.6856\lib\netstandard2.0\ICSharpCode.Decompiler.dll</HintPath>
57+
</Reference>
58+
<Reference Include="Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
59+
<HintPath>..\packages\Microsoft.Win32.Registry.5.0.0\lib\net461\Microsoft.Win32.Registry.dll</HintPath>
60+
</Reference>
61+
<Reference Include="Mono.Cecil, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
62+
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.dll</HintPath>
63+
</Reference>
64+
<Reference Include="Mono.Cecil.Mdb, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
65+
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
66+
</Reference>
67+
<Reference Include="Mono.Cecil.Pdb, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
68+
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
69+
</Reference>
70+
<Reference Include="Mono.Cecil.Rocks, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
71+
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
72+
</Reference>
73+
<Reference Include="System" />
74+
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
75+
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
76+
</Reference>
77+
<Reference Include="System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
78+
<HintPath>..\packages\System.Collections.Immutable.5.0.0\lib\net461\System.Collections.Immutable.dll</HintPath>
79+
</Reference>
80+
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
81+
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
82+
</Reference>
83+
<Reference Include="System.Numerics" />
84+
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
85+
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
86+
</Reference>
87+
<Reference Include="System.Reflection.Metadata, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
88+
<HintPath>..\packages\System.Reflection.Metadata.5.0.0\lib\net461\System.Reflection.Metadata.dll</HintPath>
89+
</Reference>
90+
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
91+
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
92+
</Reference>
93+
<Reference Include="System.Security.AccessControl, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
94+
<HintPath>..\packages\System.Security.AccessControl.5.0.0\lib\net461\System.Security.AccessControl.dll</HintPath>
95+
</Reference>
96+
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
97+
<HintPath>..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
98+
</Reference>
99+
</ItemGroup>
100+
<ItemGroup>
101+
<Compile Include="base.cs" />
102+
<Compile Include="Csharp decompiler.cs" />
103+
<Compile Include="il decoMod.cs" />
104+
<Compile Include="Program.cs" />
105+
</ItemGroup>
106+
<ItemGroup>
107+
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
108+
<Visible>False</Visible>
109+
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 und x64%29</ProductName>
110+
<Install>true</Install>
111+
</BootstrapperPackage>
112+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
113+
<Visible>False</Visible>
114+
<ProductName>.NET Framework 3.5 SP1</ProductName>
115+
<Install>false</Install>
116+
</BootstrapperPackage>
117+
</ItemGroup>
118+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
119+
</Project>

compilerTool/il decoMod.cs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.IO;
6+
using System.Threading.Tasks;
7+
using Mono.Cecil.Cil;
8+
using Mono.Cecil;
9+
10+
namespace compilerTools
11+
{
12+
internal class il_decoMod : @base
13+
{
14+
public il_decoMod()
15+
{
16+
id = "Mono.Cecil";
17+
sid = "methods";
18+
}
19+
ModuleDefinition module;
20+
public override void runPayload()
21+
{
22+
base.runPayload();
23+
module = ModuleDefinition.ReadModule(filename);
24+
if (module != null)
25+
{
26+
moduleType = module.Kind == ModuleKind.Dll ? "DLL" : (module.Kind == ModuleKind.Console ? "Console" : (module.Kind == ModuleKind.Windows ? "Windows" : ""));
27+
if (module.Kind == ModuleKind.Windows)
28+
module.Kind = ModuleKind.Console;
29+
MethodReference clog = module.ImportReference(typeof(Console).GetMethod("WriteLine", new Type[] { typeof(object) })),
30+
amp = module.ImportReference(typeof(System.Reflection.Assembly).GetMethod("GetExecutingAssembly", Type.EmptyTypes)),
31+
concat = module.ImportReference(typeof(string).GetMethod("Format", new Type[] { typeof(string), typeof(string) }));
32+
Instruction loginst = Instruction.Create(OpCodes.Call, clog);
33+
foreach (var type in module.Types)
34+
{
35+
foreach (var method in type.Methods)
36+
{
37+
if (!method.HasBody) continue;
38+
var ilProc = method.Body.GetILProcessor();
39+
namespacess.Add($"${method.FullName}");
40+
var fi = method.Body.Instructions.First();
41+
var li = method.Body.Instructions.Last();
42+
ilProc.InsertBefore(fi, Instruction.Create(OpCodes.Ldstr,
43+
String.Concat(
44+
"-- Modified by SharkDebug\n",
45+
module.IsMain ? "-- Running as: \"{0}\"\n" : "",
46+
$"-- Entering \"{method.Name}\" of \"{type.Name}\""
47+
)));
48+
if (module.IsMain)
49+
{
50+
ilProc.InsertBefore(fi, Instruction.Create(OpCodes.Call, amp));// //
51+
ilProc.InsertBefore(fi, Instruction.Create(OpCodes.Callvirt, module.ImportReference(typeof(System.Reflection.Assembly).GetMethod("get_Location", Type.EmptyTypes)))); // System.Reflection.Assembly.GetExecutingAssembly().Location
52+
53+
ilProc.InsertBefore(fi, Instruction.Create(OpCodes.Call, concat));
54+
}
55+
56+
ilProc.InsertBefore(fi, loginst);
57+
ilProc.InsertBefore(li, Instruction.Create(OpCodes.Ldstr, $"-- Exiting {method.Name} of {type.Name}"));
58+
ilProc.InsertBefore(li, loginst);
59+
}
60+
}
61+
}
62+
}
63+
public override void writeFile()
64+
{
65+
string saveas = string.Format("{0}.dbg{1}", Path.GetFileNameWithoutExtension(filename), Path.GetExtension(filename));
66+
Console.WriteLine($"\t\tSave File: {saveas}");
67+
module.Write(saveas);
68+
}
69+
}
70+
}

compilerTool/packages.config

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="ICSharpCode.Decompiler" version="7.2.1.6856" targetFramework="net472" />
4+
<package id="Microsoft.Win32.Registry" version="5.0.0" targetFramework="net472" />
5+
<package id="Mono.Cecil" version="0.11.4" targetFramework="net472" />
6+
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
7+
<package id="System.Collections.Immutable" version="5.0.0" targetFramework="net472" />
8+
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
9+
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
10+
<package id="System.Reflection.Metadata" version="5.0.0" targetFramework="net472" />
11+
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net472" />
12+
<package id="System.Security.AccessControl" version="5.0.0" targetFramework="net472" />
13+
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net472" />
14+
</packages>

compilerTools.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.1.32407.343
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "compilerTool", "compilerTool\compilerTool.csproj", "{B7404E02-580D-436E-BC38-5787137F6D04}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{B7404E02-580D-436E-BC38-5787137F6D04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{B7404E02-580D-436E-BC38-5787137F6D04}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{B7404E02-580D-436E-BC38-5787137F6D04}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{B7404E02-580D-436E-BC38-5787137F6D04}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {C17969B1-673F-4941-B050-37DE813762F3}
24+
EndGlobalSection
25+
EndGlobal

0 commit comments

Comments
 (0)