Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        /// <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);
        }
Exemplo n.º 6
0
        /// <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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
        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));
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        /// <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);
        }
Exemplo n.º 12
0
        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);
        }