Skip to content

Commit

Permalink
32 bit support added
Browse files Browse the repository at this point in the history
  • Loading branch information
MrLiamMcQ committed Dec 30, 2018
1 parent 56d8c29 commit c8be748
Show file tree
Hide file tree
Showing 115 changed files with 841 additions and 79 deletions.
Binary file added .vs/DllEmbeddedInjectorMaker/v15/.suo
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 9 additions & 6 deletions DllEmbeddedInjectorMaker/DllEmbeddedInjectorMaker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -26,19 +27,20 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<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>
<Prefer32Bit>true</Prefer32Bit>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -109,9 +111,6 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="embedingCode.dll" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
<Visible>False</Visible>
Expand All @@ -125,7 +124,11 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="injecotor.exe" />
<EmbeddedResource Include="injector_x64.exe" />
<EmbeddedResource Include="injector_x86.exe" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="embedingCode.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
</Project>
122 changes: 104 additions & 18 deletions DllEmbeddedInjectorMaker/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,24 @@
using System.Windows.Shapes;
using System.Diagnostics;



public enum codeType
{
x64,
x86,
unknowen
}
// ONLY WORKS ON DEBUG COMPILE
namespace DllEmbeddedInjectorMaker
{

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{

DragEventArgs savedEvent = null;

public static byte[] readEmbeddedResource(string resourceName)
Expand All @@ -46,45 +56,121 @@ public static byte[] readEmbeddedResource(string resourceName)
}
}

public static void WriteDlls()
public static codeType FindDllBitType(string fileLocation)
{
using (FileStream fs = File.Create("embedingCode.dll"))
byte[] binaryData = File.ReadAllBytes(fileLocation);

byte[] output = new byte[500];
Buffer.BlockCopy(binaryData, 0, output, 0, 500);

char dllType = '\0';

for(int i=0;i<500;i++) {
if (output[i] == 'P') {
if (output[i + 1] == 'E') {
dllType = (char)output[i + 4];
}
}
}

if (dllType == 'd')
return codeType.x64;
if (dllType == 'L')
return codeType.x86;
return codeType.unknowen;
}

public static int getDllFromArray(string[] fileList)
{
int returnIndex=-1;
for (int i = 0; i < fileList.Length; i++)
{
byte[] bytes = readEmbeddedResource("DllEmbeddedInjectorMaker.embedingCode.dll");
fs.Write(bytes, 0, bytes.Length);
string fileExtension = fileList[i].Substring(fileList[i].LastIndexOf('.') + 1);
if (fileExtension == "dll")
{
returnIndex = i;
}
}
return returnIndex;
}

[DllImport(@"embedingCode.dll", EntryPoint = "?EmbedDllFile@@YAXPEAD0@Z")]
public static void WriteDlls(string outputName, string internalName)
{
using (FileStream fs = File.Create(outputName))//"embedingCode.dll"
{
byte[] bytes = readEmbeddedResource(internalName);//"DllEmbeddedInjectorMaker.embedingCode.dll"
fs.Write(bytes, 0, bytes.Length);
}
}

[DllImport(@"embedingCode.dll", EntryPoint = "?EmbedDllFile@@YAXQAD0@Z")]
public static extern void EmbedDllFile(char[] dllFile, char[] InjectorFile);

public MainWindow()
{
InitializeComponent();

if (!File.Exists("embedingCode.dll"))
{
WriteDlls();
WriteDlls("embedingCode.dll", "DllEmbeddedInjectorMaker.embedingCode.dll");
}
}
void drop_files(object sender, DragEventArgs e)
{
if (e == null)
return;
savedEvent = e;
string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
string fileName = FileList[0].Substring(FileList[0].LastIndexOf('\\') + 1);
string fileExtension = FileList[0].Substring(FileList[0].LastIndexOf('.') + 1);

if (fileExtension == "dll")
textBox.Text = fileName;
else return;
int indexLocation = getDllFromArray(FileList);
if (indexLocation == -1)
return;

string dllLocation = FileList[indexLocation];
string dllName = dllLocation.Substring(dllLocation.LastIndexOf('\\') + 1);
textBox.Text = dllName;


string outputName = "InjectorWithInbeddedDLL.exe";

string embededdInjector;

codeType machineType = FindDllBitType(dllLocation);
switch(machineType){
case codeType.x64:
embededdInjector = "DllEmbeddedInjectorMaker.injector_x64.exe";
break;
case codeType.x86:
embededdInjector = "DllEmbeddedInjectorMaker.injector_x86.exe";
break;
default:
return;
}
if (machineType == codeType.unknowen)
return;

using (FileStream fs = File.Create(outputName))
{
byte[] bytes = readEmbeddedResource("DllEmbeddedInjectorMaker.injecotor.exe");

//offset to injectors target exe is 23F8
var offsetAmount = 0x23F8;
byte[] bytes = readEmbeddedResource(embededdInjector);

// find PLACEHOLDER in byte array
string thingToFind = "PLACEHOLDER";
UInt32 count = 0;
bool found = false;
do {
count++;
int foundAmount = 0;
for (int i = 0; i< thingToFind.Length;i++) {
if ((char)bytes[count+i] == thingToFind[i]) {
foundAmount++;
if (foundAmount== thingToFind.Length-1) {
found = true;
}
} else break;
}
} while (!found);

var offsetAmount = count;

for (int i = 0; i < textBox1.Text.Length; i++) {

Expand All @@ -100,10 +186,10 @@ void drop_files(object sender, DragEventArgs e)
}
string loaction = AppDomain.CurrentDomain.BaseDirectory;
string targetLoc = loaction + outputName;

EmbedDllFile(FileList[0].ToCharArray(), targetLoc.ToCharArray());
Process.Start(loaction );//,"/select, " + outputName
}
Process.Start(loaction);// open file view expolrer
return;
}// use embedding code test to find my not append

private void button_Click(object sender, RoutedEventArgs e)
{
Expand Down
Binary file removed DllEmbeddedInjectorMaker/bin/Debug/Beep.dll
Binary file not shown.
Binary file not shown.
Binary file modified DllEmbeddedInjectorMaker/embedingCode.dll
Binary file not shown.
Binary file removed DllEmbeddedInjectorMaker/injecotor.exe
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5ededbc80f769cdf5ad01c69416e4073b3b01e34
37fbee0b433ebb173cb00b82b1d8df476f05f15a
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\bin\Debug\DllEmbeddedInjectorMaker.exe.config
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\bin\Debug\DllEmbeddedInjectorMaker.exe
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\bin\Debug\DllEmbeddedInjectorMaker.pdb
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\obj\Debug\DllEmbeddedInjectorMaker.csprojAssemblyReference.cache
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\obj\Debug\MainWindow.g.cs
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\obj\Debug\App.g.cs
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\obj\Debug\DllEmbeddedInjectorMaker_MarkupCompile.cache
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\obj\Debug\DllEmbeddedInjectorMaker_MarkupCompile.lref
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\obj\Debug\MainWindow.baml
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\obj\Debug\DllEmbeddedInjectorMaker.g.resources
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\obj\Debug\DllEmbeddedInjectorMaker.Properties.Resources.resources
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\obj\Debug\DllEmbeddedInjectorMaker.csproj.GenerateResource.cache
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\obj\Debug\DllEmbeddedInjectorMaker.csproj.CoreCompileInputs.cache
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\obj\Debug\DllEmbeddedInjectorMaker.exe
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\obj\Debug\DllEmbeddedInjectorMaker.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

[assembly: System.Windows.Resources.AssemblyAssociatedContentFileAttribute("embedingcode.dll")]


Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ DEBUG;TRACE
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\App.xaml
11151548125

9-993563708
5-2017746502
131569487696
MainWindow.xaml;

True
False

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
DllEmbeddedInjectorMaker


winexe
C#
.cs
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\obj\Debug\
DllEmbeddedInjectorMaker
none
false
DEBUG;TRACE
C:\Users\Liam\source\repos\DllEmbeddedInjectorMaker\DLL_embedded_Injector_maker_tool\DllEmbeddedInjectorMaker\App.xaml
11151548125

9-993563708
131569487696
MainWindow.xaml;

False

Binary file not shown.
70 changes: 70 additions & 0 deletions DllEmbeddedInjectorMaker/obj/Release/App.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#pragma checksum "..\..\App.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "55025F6EA4FB665EB755D756C048D9AF8D2C3449"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using DllEmbeddedInjectorMaker;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;


namespace DllEmbeddedInjectorMaker {


/// <summary>
/// App
/// </summary>
public partial class App : System.Windows.Application {

/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent() {

#line 5 "..\..\App.xaml"
this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative);

#line default
#line hidden
}

/// <summary>
/// Application Entry Point.
/// </summary>
[System.STAThreadAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public static void Main() {
DllEmbeddedInjectorMaker.App app = new DllEmbeddedInjectorMaker.App();
app.InitializeComponent();
app.Run();
}
}
}

0 comments on commit c8be748

Please sign in to comment.