Skip to content

Commit c2fa0c8

Browse files
Working Flash Fixer
1 parent 420e940 commit c2fa0c8

File tree

7 files changed

+296
-0
lines changed

7 files changed

+296
-0
lines changed

COFlashFixer/COFlashFixer.sln

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30907.101
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "COFlashFixer", "COFlashFixer\COFlashFixer.csproj", "{590EC7EB-2F29-49C5-9501-0169B84C61CB}"
7+
EndProject
8+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "COFlashFixer_DLL", "COFlashFixer_DLL\COFlashFixer_DLL.vcxproj", "{01358812-493C-4A24-8630-F71DF28D47D8}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Debug|x86 = Debug|x86
14+
Release|Any CPU = Release|Any CPU
15+
Release|x86 = Release|x86
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{590EC7EB-2F29-49C5-9501-0169B84C61CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{590EC7EB-2F29-49C5-9501-0169B84C61CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{590EC7EB-2F29-49C5-9501-0169B84C61CB}.Debug|x86.ActiveCfg = Debug|Any CPU
21+
{590EC7EB-2F29-49C5-9501-0169B84C61CB}.Debug|x86.Build.0 = Debug|Any CPU
22+
{590EC7EB-2F29-49C5-9501-0169B84C61CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{590EC7EB-2F29-49C5-9501-0169B84C61CB}.Release|Any CPU.Build.0 = Release|Any CPU
24+
{590EC7EB-2F29-49C5-9501-0169B84C61CB}.Release|x86.ActiveCfg = Release|Any CPU
25+
{590EC7EB-2F29-49C5-9501-0169B84C61CB}.Release|x86.Build.0 = Release|Any CPU
26+
{01358812-493C-4A24-8630-F71DF28D47D8}.Debug|Any CPU.ActiveCfg = Debug|Win32
27+
{01358812-493C-4A24-8630-F71DF28D47D8}.Debug|x86.ActiveCfg = Debug|Win32
28+
{01358812-493C-4A24-8630-F71DF28D47D8}.Debug|x86.Build.0 = Debug|Win32
29+
{01358812-493C-4A24-8630-F71DF28D47D8}.Release|Any CPU.ActiveCfg = Release|Win32
30+
{01358812-493C-4A24-8630-F71DF28D47D8}.Release|x86.ActiveCfg = Release|Win32
31+
{01358812-493C-4A24-8630-F71DF28D47D8}.Release|x86.Build.0 = Release|Win32
32+
EndGlobalSection
33+
GlobalSection(SolutionProperties) = preSolution
34+
HideSolutionNode = FALSE
35+
EndGlobalSection
36+
GlobalSection(ExtensibilityGlobals) = postSolution
37+
SolutionGuid = {75BEB7C5-00CF-4A93-A7D7-491D0B238CA0}
38+
EndGlobalSection
39+
EndGlobal
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.8" />
5+
</startup>
6+
</configuration>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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>{590EC7EB-2F29-49C5-9501-0169B84C61CB}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>COFlashFixer</RootNamespace>
10+
<AssemblyName>COFlashFixer</AssemblyName>
11+
<TargetFrameworkVersion>v4.8</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+
<PropertyGroup>
36+
<ApplicationIcon>flashicon.ico</ApplicationIcon>
37+
</PropertyGroup>
38+
<ItemGroup>
39+
<Reference Include="System" />
40+
<Reference Include="System.Core" />
41+
<Reference Include="System.Xml.Linq" />
42+
<Reference Include="System.Data.DataSetExtensions" />
43+
<Reference Include="Microsoft.CSharp" />
44+
<Reference Include="System.Data" />
45+
<Reference Include="System.Net.Http" />
46+
<Reference Include="System.Xml" />
47+
</ItemGroup>
48+
<ItemGroup>
49+
<Compile Include="Injector.cs" />
50+
<Compile Include="Program.cs" />
51+
<Compile Include="Properties\AssemblyInfo.cs" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<None Include="App.config" />
55+
</ItemGroup>
56+
<ItemGroup>
57+
<Content Include="flashicon.ico" />
58+
</ItemGroup>
59+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
60+
</Project>
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
namespace COFlashFixer
2+
{
3+
#region References
4+
5+
using System;
6+
using System.Runtime.InteropServices;
7+
using System.Text;
8+
9+
#endregion
10+
public static class Injector
11+
{
12+
#region Win32
13+
[DllImport("KERNEL32.DLL")]
14+
private static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, uint dwProcessId);
15+
16+
[DllImport("KERNEL32.DLL")]
17+
private static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAdress, UIntPtr dwSize, uint flAllocationType, uint flProtect);
18+
19+
[DllImport("KERNEL32.DLL")]
20+
private static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAdress, uint dwSize, uint dwFreeType);
21+
22+
[DllImport("KERNEL32.DLL")]
23+
private static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, int nSize, int lpNumberOfBytesWritten);
24+
25+
[DllImport("KERNEL32.DLL")]
26+
private static extern IntPtr CreateRemoteThread(IntPtr hProcess, IntPtr se, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, uint lpThreadId);
27+
28+
[DllImport("KERNEL32.DLL", CharSet = CharSet.Ansi)]
29+
private extern static IntPtr GetProcAddress(IntPtr hModule, string lpProcName);
30+
31+
[DllImport("KERNEL32.DLL", CharSet = CharSet.Ansi)]
32+
private static extern IntPtr GetModuleHandle(string lpModuleName);
33+
34+
[DllImport("KERNEL32.DLL")]
35+
private static extern bool CloseHandle(IntPtr hObject);
36+
37+
[DllImport("KERNEL32.DLL")]
38+
private static extern uint WaitForSingleObject(IntPtr hHandle, uint dwMilliSeconds);
39+
40+
private const uint PROCESS_ALL_ACCESS = (uint)(0x0002 | 0x0400 | 0x0008 | 0x0010 | 0x0020);
41+
private const uint MEM_COMMIT = 0x1000;
42+
private const uint MEM_RELEASE = 0x8000;
43+
private const uint PAGE_EXECUTE_READWRITE = 0x40;
44+
private const uint WAIT_ABANDONED = 0x00000080;
45+
private const uint WAIT_OBJECT_0 = 0x00000000;
46+
private const uint WAIT_TIMEOUT = 0x00000102;
47+
private const uint WAIT_FAILED = 0xFFFFFFFF;
48+
#endregion
49+
50+
/// <summary>
51+
/// Function to inject a Dll
52+
/// </summary>
53+
/// <param name="DllName">Name of dll for inject.</param>
54+
/// <param name="ProcessName">Nombre del proceso en el que sera injectada la Dll.</param>
55+
public static bool StartInjection(string DllName, uint ProcessID)
56+
{
57+
bool Injected = false;
58+
try
59+
{
60+
IntPtr hProcess = new IntPtr(0); //openprocess
61+
IntPtr hModule = new IntPtr(0); //vritualAllocex
62+
IntPtr Injector = new IntPtr(0); //getprocadress
63+
IntPtr hThread = new IntPtr(0); //createremotethread
64+
int LenWrite = DllName.Length + 1;
65+
hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, ProcessID);
66+
if (hProcess != IntPtr.Zero)
67+
{
68+
hModule = VirtualAllocEx(hProcess, IntPtr.Zero, (UIntPtr)LenWrite, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
69+
if (hModule != IntPtr.Zero)
70+
{
71+
ASCIIEncoding Encoder = new ASCIIEncoding();
72+
int Written = 0;
73+
if (WriteProcessMemory(hProcess, hModule, Encoder.GetBytes(DllName), LenWrite, Written))
74+
{
75+
Injector = GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
76+
77+
if (Injector != IntPtr.Zero)
78+
{
79+
hThread = CreateRemoteThread(hProcess, IntPtr.Zero, 0, Injector, hModule, 0, 0);
80+
81+
if (hThread != IntPtr.Zero)
82+
{
83+
uint Result = WaitForSingleObject(hThread, 10 * 1000);
84+
if (Result != WAIT_FAILED || Result != WAIT_ABANDONED
85+
|| Result != WAIT_OBJECT_0 || Result != WAIT_TIMEOUT)
86+
{
87+
if (VirtualFreeEx(hProcess, hModule, 0, MEM_RELEASE))
88+
{
89+
if (hThread != IntPtr.Zero)
90+
{
91+
CloseHandle(hThread);
92+
Injected = true;
93+
return Injected;
94+
}
95+
else Console.WriteLine("Bad thread handle ... injection failed");
96+
}
97+
else Console.WriteLine("Memory free problem ... injection failed");
98+
}
99+
else Console.WriteLine("WaitForSingle failed: " + Result.ToString() + "...injection failed");
100+
}
101+
else Console.WriteLine("Problem when starting the thread ... injection failed");
102+
}
103+
else Console.WriteLine("LoadLibraryA address not found ... injection failed");
104+
}
105+
else Console.WriteLine("Write error in process ... injection failed");
106+
}
107+
else Console.WriteLine("Unallocated memory ... injection failed");
108+
}
109+
else Console.WriteLine("Unopened process ... injection failed");
110+
}
111+
catch (Exception Exc) { Console.WriteLine("Injection Error: " + Exc.ToString()); }
112+
return Injected;
113+
}
114+
}
115+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
using System.Diagnostics;
3+
using System.IO;
4+
using System.Threading;
5+
6+
namespace COFlashFixer
7+
{
8+
class Program
9+
{
10+
static void Main(string[] args)
11+
{
12+
string ConquerExePath = Path.Combine(Directory.GetCurrentDirectory(), "Conquer.exe");
13+
string DllPath = Path.Combine(Directory.GetCurrentDirectory(), "COFlashFixer_DLL.dll");
14+
if (args.Length > 0)
15+
{
16+
ConquerExePath = args[0];
17+
DllPath = args[1];
18+
} else
19+
{
20+
Console.WriteLine("Specify Path of Conquer.exe (First Parameter) [Detected: {0}]", ConquerExePath);
21+
Console.WriteLine("Specify Path of Dll Fixer (Second Parameter) [Detected: {0}]", DllPath);
22+
Console.WriteLine("Is Valid? [Y/N]");
23+
string YN = Console.ReadLine().ToUpper();
24+
if (YN == "Y")
25+
{
26+
27+
} else
28+
{
29+
Console.WriteLine("Please run with the valid parameters.");
30+
}
31+
}
32+
Process p = Process.Start(ConquerExePath, "blacknull");
33+
if (!Injector.StartInjection(DllPath, (uint)p.Id))
34+
{
35+
Console.WriteLine("Error on injection. Path is valid?");
36+
Console.ReadKey();
37+
}
38+
}
39+
}
40+
}
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+
// La información general de un ensamblado se controla mediante el siguiente
6+
// conjunto de atributos. Cambie estos valores de atributo para modificar la información
7+
// asociada a un ensamblado.
8+
[assembly: AssemblyTitle("COFlashFixer")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("DaRkFoxDeveloper")]
12+
[assembly: AssemblyProduct("COFlashFixer")]
13+
[assembly: AssemblyCopyright("Copyright © DaRkFoxDeveloper 2021")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Si establece ComVisible en false, los tipos de este ensamblado no estarán visibles
18+
// para los componentes COM. Si es necesario obtener acceso a un tipo en este ensamblado desde
19+
// COM, establezca el atributo ComVisible en true en este tipo.
20+
[assembly: ComVisible(false)]
21+
22+
// El siguiente GUID sirve como id. de typelib si este proyecto se expone a COM.
23+
[assembly: Guid("590ec7eb-2f29-49c5-9501-0169b84c61cb")]
24+
25+
// La información de versión de un ensamblado consta de los cuatro valores siguientes:
26+
//
27+
// Versión principal
28+
// Versión secundaria
29+
// Número de compilación
30+
// Revisión
31+
//
32+
// Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión
33+
// utilizando el carácter "*", como se muestra a continuación:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
121 KB
Binary file not shown.

0 commit comments

Comments
 (0)