internal ExtensionWrapper(int targetProcessId, string dllPath, bool randomiseDllName) { // Ensure the users operating system is supported ValidationHandler.ValidateOperatingSystem(); // Ensure the arguments passed in are valid if (targetProcessId <= 0 || string.IsNullOrWhiteSpace(dllPath)) { throw new ArgumentException("One or more of the arguments provided were invalid"); } if (randomiseDllName) { // Assume the DLL is the newest file in the temporary directory var temporaryDirectoryInfo = new DirectoryInfo(Path.Combine(Path.GetTempPath(), "Bleak")); var newestTemporaryFile = temporaryDirectoryInfo.GetFiles().OrderByDescending(file => file.LastWriteTime).First(); _propertyWrapper = new PropertyWrapper(targetProcessId, newestTemporaryFile.FullName); } else { _propertyWrapper = new PropertyWrapper(targetProcessId, dllPath); } ValidationHandler.ValidateDllArchitecture(_propertyWrapper); }
internal MethodWrapper(int targetProcessId, string dllPath, bool randomiseDllName, bool methodIsManualMap) { // Ensure the users operating system is supported ValidationHandler.ValidateOperatingSystem(); // Ensure the arguments passed in are valid if (targetProcessId <= 0 || string.IsNullOrWhiteSpace(dllPath)) { throw new ArgumentException("One or more of the arguments provided were invalid"); } if (randomiseDllName) { // Create a temporary DLL on disk var temporaryDllName = WrapperTools.GenerateRandomDllName(); var temporaryDllPath = WrapperTools.CreateTemporaryDll(temporaryDllName, File.ReadAllBytes(dllPath)); _propertyWrapper = methodIsManualMap ? new PropertyWrapper(targetProcessId, File.ReadAllBytes(temporaryDllPath)) : new PropertyWrapper(targetProcessId, temporaryDllPath); } else { _propertyWrapper = methodIsManualMap ? new PropertyWrapper(targetProcessId, File.ReadAllBytes(dllPath)) : new PropertyWrapper(targetProcessId, dllPath); } // Ensure the architecture of the DLL is valid ValidationHandler.ValidateDllArchitecture(_propertyWrapper); }
public Injector(InjectionMethod injectionMethod, string processName, string dllPath, bool randomiseDllName = false) { // Ensure the users operating system is valid ValidationHandler.ValidateOperatingSystem(); // Ensure the arguments passed in are valid if (string.IsNullOrWhiteSpace(processName) || string.IsNullOrWhiteSpace(dllPath)) { throw new ArgumentException("One or more of the arguments provided were invalid"); } // Ensure a valid DLL exists at the provided path if (!File.Exists(dllPath) || Path.GetExtension(dllPath) != ".dll") { throw new ArgumentException("No DLL exists at the provided path"); } if (randomiseDllName) { // Create a temporary DLL on disk var temporaryDllPath = DllTools.CreateTemporaryDll(DllTools.GenerateRandomDllName(), File.ReadAllBytes(dllPath)); _injectionManager = new InjectionManager(injectionMethod, processName, temporaryDllPath); } else { _injectionManager = new InjectionManager(injectionMethod, processName, dllPath); } }
internal MethodWrapper(string targetProcessName, byte[] dllBytes, bool randomiseDllName, bool methodIsManualMap) { // Ensure the users operating system is supported ValidationHandler.ValidateOperatingSystem(); // Ensure the arguments passed in are valid if (string.IsNullOrWhiteSpace(targetProcessName) || dllBytes is null || dllBytes.Length == 0) { throw new ArgumentException("One or more of the arguments provided were invalid"); } if (methodIsManualMap) { _propertyWrapper = new PropertyWrapper(targetProcessName, dllBytes); } else { // Create a temporary DLL on disk var temporaryDllName = randomiseDllName ? WrapperTools.GenerateRandomDllName() : WrapperTools.GenerateDllName(dllBytes); var temporaryDllPath = WrapperTools.CreateTemporaryDll(temporaryDllName, dllBytes); _propertyWrapper = new PropertyWrapper(targetProcessName, temporaryDllPath); } // Ensure the architecture of the DLL is valid ValidationHandler.ValidateDllArchitecture(_propertyWrapper); }
/// <summary> /// Initialises an instance capable of managing memory in a specified remote process /// </summary> public MemoryModule(string processName) { ValidationHandler.ValidateOperatingSystem(); _memoryManager = new MemoryManager(processName); _patternScanner = new PatternScanner(_memoryManager); }
/// <summary> /// An instance capable of injecting a DLL into a remote process /// </summary> public Injector(string processName, byte[] dllBytes, InjectionMethod injectionMethod, InjectionFlags injectionFlags = InjectionFlags.None) { ValidationHandler.ValidateOperatingSystem(); // Ensure the arguments passed in are valid if (string.IsNullOrWhiteSpace(processName) || dllBytes is null || dllBytes.Length == 0) { throw new ArgumentException("One or more of the arguments provided were invalid"); } _injectionManager = new InjectionManager(processName, dllBytes, injectionMethod, injectionFlags); }
internal InjectionManager(int targetProcessId, string dllPath, bool isExtension, bool randomiseDllName) { // Ensure the users operating system is valid ValidationHandler.ValidateOperatingSystem(); // Ensure the arguments passed in are valid if (targetProcessId <= 0 || string.IsNullOrWhiteSpace(dllPath)) { throw new ArgumentException("One or more of the arguments provided were invalid"); } // Ensure a valid DLL exists at the provided path if (!File.Exists(dllPath) || Path.GetExtension(dllPath) != ".dll") { throw new ArgumentException("No DLL file exists at the provided path"); } if (randomiseDllName && isExtension) { // Assume the DLL is the newest file in the directory var directoryInfo = new DirectoryInfo(Path.Combine(Path.GetTempPath(), "Bleak")); var newestFile = directoryInfo.GetFiles().OrderByDescending(file => file.LastWriteTime).First(); _injectionProperties = new InjectionProperties(targetProcessId, newestFile.FullName); } else if (randomiseDllName) { // Create a temporary DLL on disk var temporaryDllPath = DllTools.CreateTemporaryDll(DllTools.GenerateRandomDllName(), File.ReadAllBytes(dllPath)); _injectionProperties = new InjectionProperties(targetProcessId, temporaryDllPath); } else { _injectionProperties = new InjectionProperties(targetProcessId, dllPath); } // Ensure the architecture of the DLL is valid ValidationHandler.ValidateDllArchitecture(_injectionProperties); }
public Injector(InjectionMethod injectionMethod, string processName, byte[] dllBytes) { // Ensure the users operating system is valid ValidationHandler.ValidateOperatingSystem(); // Ensure the arguments passed in are valid if (string.IsNullOrWhiteSpace(processName) || dllBytes is null || dllBytes.Length == 0) { throw new ArgumentException("One or more of the arguments provided were invalid"); } _injectionManager = injectionMethod == InjectionMethod.ManualMap ? new InjectionManager(injectionMethod, processName, dllBytes) : new InjectionManager(injectionMethod, processName, DllTools.CreateTemporaryDll(DllTools.GenerateRandomDllName(), dllBytes)); }
public Injector(InjectionMethod injectionMethod, int processId, byte[] dllBytes) { // Ensure the users operating system is valid ValidationHandler.ValidateOperatingSystem(); // Ensure the arguments passed in are valid if (processId <= 0 || dllBytes is null || dllBytes.Length == 0) { throw new ArgumentException("One or more of the arguments provided were invalid"); } _injectionContext = injectionMethod == InjectionMethod.ManualMap ? new InjectionContext(injectionMethod, processId, dllBytes) : new InjectionContext(injectionMethod, processId, DllTools.CreateTemporaryDll(DllTools.GenerateDllName(dllBytes), dllBytes)); }
internal InjectionManager(int targetProcessId, byte[] dllBytes, bool manualMap, bool isExtension, bool randomiseDllName) { // Ensure the users operating system is valid ValidationHandler.ValidateOperatingSystem(); // Ensure the arguments passed in are valid if (targetProcessId <= 0 || dllBytes is null || dllBytes.Length == 0) { throw new ArgumentException("One or more of the arguments provided were invalid"); } if (manualMap) { _injectionProperties = new InjectionProperties(targetProcessId, dllBytes); } else if (randomiseDllName && isExtension) { // Assume the DLL is the newest file in the directory var directoryInfo = new DirectoryInfo(Path.Combine(Path.GetTempPath(), "Bleak")); var newestFile = directoryInfo.GetFiles().OrderByDescending(file => file.LastWriteTime).First(); _injectionProperties = new InjectionProperties(targetProcessId, newestFile.FullName); } else { // Create a temporary DLL on disk var temporaryDllName = randomiseDllName ? DllTools.GenerateRandomDllName() : DllTools.GenerateDllName(dllBytes); _injectionProperties = new InjectionProperties(targetProcessId, DllTools.CreateTemporaryDll(temporaryDllName, dllBytes)); } // Ensure the architecture of the DLL is valid ValidationHandler.ValidateDllArchitecture(_injectionProperties); }
/// <summary> /// An instance capable of injecting a DLL into a remote process /// </summary> public Injector(string processName, string dllPath, InjectionMethod injectionMethod, InjectionFlags injectionFlags = InjectionFlags.None) { ValidationHandler.ValidateOperatingSystem(); // Ensure the arguments passed in are valid if (string.IsNullOrWhiteSpace(processName) || string.IsNullOrWhiteSpace(dllPath)) { throw new ArgumentException("One or more of the arguments provided were invalid"); } // Ensure a valid DLL exists at the provided path if (!File.Exists(dllPath) || Path.GetExtension(dllPath) != ".dll") { throw new ArgumentException("No DLL exists at the provided path"); } _injectionManager = new InjectionManager(processName, dllPath, injectionMethod, injectionFlags); }
internal ExtensionWrapper(int targetProcessId, byte[] dllBytes, bool randomiseDllName) { // Ensure the users operating system is supported ValidationHandler.ValidateOperatingSystem(); // Ensure the arguments passed in are valid if (targetProcessId <= 0 || dllBytes is null || dllBytes.Length == 0) { throw new ArgumentException("One or more of the arguments provided were invalid"); } if (randomiseDllName) { // Assume the DLL is the newest file in the temporary directory var temporaryDirectoryInfo = new DirectoryInfo(Path.Combine(Path.GetTempPath(), "Bleak")); var newestTemporaryFile = temporaryDirectoryInfo.GetFiles().OrderByDescending(file => file.LastWriteTime).First(); _propertyWrapper = new PropertyWrapper(targetProcessId, newestTemporaryFile.FullName); } else { // Get the file path of the DLL on disk var temporaryDirectory = Path.Combine(Path.GetTempPath(), "Bleak"); var temporaryDllName = WrapperTools.GenerateDllName(dllBytes); var temporaryDllPath = Path.Combine(temporaryDirectory, temporaryDllName); _propertyWrapper = new PropertyWrapper(targetProcessId, temporaryDllPath); } // Ensure the architecture of the DLL is valid ValidationHandler.ValidateDllArchitecture(_propertyWrapper); }