Windows Kernel Drivers fuzzer
This is a project from back in tha dayz, in 2011-2012. Kinda dirty code, but worked for me to find several bugs in Windows Drivers.
Here is one of them: https://www.exploit-db.com/exploits/17902/
More info about this tool and kernel exploitation at: http://poppopret.blogspot.fr/
For french people, an article was also written in MISC Magazine #62: http://connect.ed-diamond.com/MISC/MISC-062/De-la-decouverte-d-une-vulnerabilite-dans-un-driver-Windows-a-l-elevation-de-privileges
IOCTLbf is just a small tool (Proof of Concept) that can be used to search vulnerabilities in Windows kernel drivers by performing two tasks:
An advantage of this tool is that it does not rely on captured IOCTLs. Therefore, it is able to detect valid IOCTLs codes supported by drivers and that are not often, or even never, used by applications from user land.
For example, it may be the case for:
Once scanning is done and valid IOCTLs have been found for a given driver, the user can choose one IOCTL in the list to begin the fuzzing process. Note that this tool only performs generation-based fuzzing. Compared to mutation-based fuzzing (which consists in taking valid IOCTL buffers and adding anomalies), the code coverage is of course less important.
Note: for mutation-based IOCTL fuzzing, check out the great tool IOCTL fuzzer (http://code.google.com/p/ioctlfuzzer/). Basically, it hooks NtDeviceIoControlFile in order to take control of all IOCTL requests throughout the system.
…
Buffer sizes:
Input Size = nt!_IO_STACK_LOCATION.Parameters.DeviceIoControl.InputBufferLength
Output Size = nt!_IO_STACK_LOCATION.Parameters.DeviceIoControl.OutputBufferLength
The way buffers are passed from userland to kernelland, and from kernelland to userland, depends on the method which is used. Here are the differences:
Input Buffer = nt!_IRP.AssociatedIrp.SystemBuffer
Output Buffer = nt!_IRP.AssociatedIrp.SystemBuffer
input & output buffers use the same location, so the buffer allocated by the I/O manager is the size of the larger value (output vs. input).
Input Buffer = nt!_IRP.AssociatedIrp.SystemBuffer
Output Buffer = nt!_IRP.MdlAddress
the input buffer is passed in using "BUFFERED" implementation. The output buffer is passed in using a MDL (which permits Direct Memory Access). The difference between "IN" and "OUT" is that with "IN", you can use the output buffer to pass in data! The "OUT" is only used to return data.
Input Buffer = nt!_IO_STACK_LOCATION.Parameters.DeviceIoControl.Type3InputBuffer
Output Buffer = nt!_IRP.UserBuffer
input & output buffers sizes may be different. The I/O manager does not provide any system buffers or MDLs. The IRP supplies the user-mode virtual addresses of the input and output buffer
…
First of all, it is necessary to locate the target driver. A tool like DriverView (http://www.nirsoft.net/utils/driverview.html) can be used in order to easily spot non-Microsoft drivers (third-party drivers).
Then, it is necessary to check the device(s) associated with the target driver. A good tool to do this is DeviceTree for example (http://www.osronline.com/article.cfm?article=97)
Check the security attributes (DACL) of the device(s). It should be available for limited users in order to make it interesting froman attacker point of view. Indeed, vulnerabilities in drivers may lead to Local Privilege Escalation on the system, or just Denial of Service when it is not exploitable.
Retrieve the symbolic link used by applications to communicate with one device of the target driver. All symbolic links can be listed with the Sysinternal's tool WinObj in the "GLOBAL??" section (http://technet.microsoft.com/en-us/sysinternals/bb896657).
Finally, it is necessary to know at least one valid IOCTL code supported by the target driver. For example, it can be easily done by monitoring IRPs with a tool like OSR's IrpTracker Utility (http://www.osronline.com/article.cfm?article=199). Make sure to apply a filter on "DEVICE_CONTROL" only and to select only the target driver. Of course, it is also possible to retrieve valid IOCTL codes directly by reverse engineering the driver.
Once a valid IOCTL code is retrieved, ioctlbf can be used. One of the following IOCTL codes scanning modes can be chosen:
…
Go to the directory .\src\
Edit the file "makefile.txt" (set correct API directories "API_DIRx") and the PATH in the file "build.bat"
Execute ".\build.bat release"
No open issues yet, or sync has not completed.