Skip to content

Oesis/Driver.NET

 
 

Repository files navigation

Driver.NET

Driver.NET is a lightweight library used to load and use Windows kernel drivers.

How does it load drivers ?

It can load drivers using different methods, including :

How to use it ?

namespace Driver.Example
{
    using System;
    using System.IO;
    using System.Threading.Tasks;

    using Driver.Enums;
    using Driver.Logic;

    internal static class Program
    {
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        private static async Task Main()
        {
            var CurrentPath      = Directory.GetCurrentDirectory();
            var CurrentDirectory = new DirectoryInfo(CurrentPath);
            var SystemFile       = new FileInfo(Path.Combine(CurrentPath, "DriverExample.sys"));
            var LoaderFile       = new FileInfo(Path.Combine(CurrentPath, "Loaders/DriverLoader.exe"));
	    
            if (SystemFile.Exists)
            {
                Console.WriteLine("[*] The driver's file has located at '" + SystemFile.FullName + "'.");

                // ..

                var Driver           = new Driver(new DriverConfig()
                {
                    ServiceName      = "DriverExample",
                    SymbolicLink     = @"\\.\DriverExample",
                    DriverFile       = SystemFile,
                    LoadMethod       = DriverLoad.Tdl

                }, LoaderPath: LoaderFile.FullName);

                // ..

                if (Driver.CanConnectTo(@"\\.\DriverExample"))
                {
                    Console.WriteLine();

                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("[*] The driver symbolic file is already created.");
                    Console.WriteLine("[*] Please make sure you are not loading the driver twice!");
                    Console.ResetColor();

                    Console.WriteLine();
                }

                // ..

                using (Driver)
                {
                    try
                    {
                        if (Driver.Load())
                        {
                            Console.WriteLine("[*] Driver has been loaded.");

                            if (Driver.IO.IsConnected)
                            {
                                Console.WriteLine("[*] Driver has created the symbolic file.");
                            }
                            else
                            {
                                Console.WriteLine("[*] Failed to open the symbolic file.");
                            }
                        }
                        else
                        {
                            Console.WriteLine("[*] Failed to load the driver.");
                        }
                    }
                    catch (Exception Exception)
                    {
                        Console.WriteLine("[*] " + Exception.Message + ".");
                    }

                    Console.WriteLine();
                    Console.WriteLine("[*] Driver->Handle       : 0x" + Driver.IO.Handle.DangerousGetHandle().ToString("X").PadLeft(8, '0'));
					Console.WriteLine("[*] Driver->IsConnected  : " + Driver.IO.IsConnected);
                    Console.WriteLine("[*] Driver->IsLoaded     : " + Driver.IsLoaded);
                    Console.WriteLine("[*] Driver->IsDisposed   : " + Driver.IsDisposed);
                }

                await Task.Delay(500);
            }
            else
            {
                Console.WriteLine("[*] The .sys file is corrupt or missing.");
            }

            Console.ReadKey(true);
        }
    }
}

About

Driver loading library for bypassing Windows Driver Signature Enforcement.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 89.3%
  • C# 9.0%
  • C++ 1.5%
  • Other 0.2%