Exploit databaseDownload repository ZIP
GH-c6b2bf9936e56cb95f0358e79df21ecb
sauercloud/rwctf21-virtualbox-61-escape
Sources for CVE-2021-2119
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files12
sauercloud/rwctf21-virtualbox-61-escapeRevision 9cbc6be62c7f
- ↑..Parent directory
- CMakeLists.txt
- Common.h
- HEVD.pfx
- HackSysExtremeVulnerableDriver.c
- HackSysExtremeVulnerableDriver.h
- HackSysExtremeVulnerableDriver.vcxproj
- HackSysExtremeVulnerableDriver.vcxproj.filters
- HackSysExtremeVulnerableDriver.vcxproj.user
- exploit_driver.inf
- ioctls.c
- ioctls.h
- rwctf_driver.sln
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
kernel_drivers/HackSysExtremeVulnerableDriver.c
C · 7,948 bytes/*++
## ## ######## ## ## ########
## ## ## ## ## ## ##
## ## ## ## ## ## ##
######### ###### ## ## ## ##
## ## ## ## ## ## ##
## ## ## ## ## ## ##
## ## ######## ### ########
HackSys Extreme Vulnerable Driver
Author : Ashfaq Ansari
Contact: ashfaq[at]payatu[dot]com
Website: http://www.payatu.com/
Copyright (C) 2015-2020 Payatu Software Labs LLP. All rights reserved.
This program is free software: you can redistribute it and/or modify it under the terms of
the GNU General Public License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see <http://www.gnu.org/licenses/>.
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
See the file 'LICENSE' for complete copying permission.
Module Name:
HackSysExtremeVulnerableDriver.c
Abstract:
This module implements the main kernel driver
of HackSys Extreme Vulnerable Driver.
--*/
#include "HackSysExtremeVulnerableDriver.h"
#include "Common.h"
#define OOB_BUFFER_SIZE 1024*16
#ifdef ALLOC_PRAGMA
#pragma alloc_text(INIT, DriverEntry)
#pragma alloc_text(PAGE, DriverUnloadHandler)
#pragma alloc_text(PAGE, IrpCreateCloseHandler)
#pragma alloc_text(PAGE, IrpDeviceIoCtlHandler)
#pragma alloc_text(PAGE, IrpNotImplementedHandler)
#endif // ALLOC_PRAGMA
/// <summary>
/// HackSys Extreme Vulnerable Driver Entry Point
/// </summary>
/// <param name="DriverObject">The pointer to DRIVER_OBJECT</param>
/// <param name="RegistryPath">The pointer to Unicode string specifying registry path</param>
/// <returns>NTSTATUS</returns>
NTSTATUS
DriverEntry(
_In_ PDRIVER_OBJECT DriverObject,
_In_ PUNICODE_STRING RegistryPath
)
{
UINT32 i = 0;
PDEVICE_OBJECT DeviceObject = NULL;
NTSTATUS Status = STATUS_UNSUCCESSFUL;
UNICODE_STRING DeviceName, DosDeviceName;
UNREFERENCED_PARAMETER(RegistryPath);
PAGED_CODE();
RtlInitUnicodeString(&DeviceName, L"\\Device\\ExploitDriver");
RtlInitUnicodeString(&DosDeviceName, L"\\DosDevices\\ExploitDriver");
//
// Create the device
//
Status = IoCreateDevice(
DriverObject,
0,
&DeviceName,
FILE_DEVICE_UNKNOWN,
FILE_DEVICE_SECURE_OPEN,
FALSE,
&DeviceObject
);
if (!NT_SUCCESS(Status))
{
if (DeviceObject)
{
//
// Delete the device
//
IoDeleteDevice(DeviceObject);
}
DbgPrint("[-] Error Initializing Exploit Driver\n");
return Status;
}
//
// Assign the IRP handlers
//
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
{
DriverObject->MajorFunction[i] = IrpNotImplementedHandler;
}
//
// Assign the IRP handlers for Create, Close and Device Control
//
DriverObject->MajorFunction[IRP_MJ_CREATE] = IrpCreateCloseHandler;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = IrpCreateCloseHandler;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = IrpDeviceIoCtlHandler;
//
// Assign the driver Unload routine
//
DriverObject->DriverUnload = DriverUnloadHandler;
//
// Set the flags
//
DeviceObject->Flags |= DO_DIRECT_IO;
DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
//
// Create the symbolic link
//
Status = IoCreateSymbolicLink(&DosDeviceName, &DeviceName);
//
// Show the banner
//
// Exploit code here
DbgPrint("%s", BANNER);
DbgPrint("[+] Exploit Driver Loaded\n");
return Status;
}
/// <summary>
/// IRP Create Close Handler
/// </summary>
/// <param name="DeviceObject">The pointer to DEVICE_OBJECT</param>
/// <param name="Irp">The pointer to IRP</param>
/// <returns>NTSTATUS</returns>
NTSTATUS
IrpCreateCloseHandler(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp
)
{
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = STATUS_SUCCESS;
UNREFERENCED_PARAMETER(DeviceObject);
PAGED_CODE();
//
// Complete the request
//
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
/// <summary>
/// Driver Unload Handler
/// </summary>
/// <param name="DeviceObject">The pointer to DEVICE_OBJECT</param>
/// <returns>NTSTATUS</returns>
VOID
DriverUnloadHandler(
_In_ PDRIVER_OBJECT DriverObject
)
{
UNICODE_STRING DosDeviceName = { 0 };
PAGED_CODE();
RtlInitUnicodeString(&DosDeviceName, L"\\DosDevices\\ExploitDriver");
//
// Delete the symbolic link
//
IoDeleteSymbolicLink(&DosDeviceName);
//
// Delete the device
//
IoDeleteDevice(DriverObject->DeviceObject);
DbgPrint("[-] Exploit Driver Unloaded\n");
}
/// <summary>
/// IRP Not Implemented Handler
/// </summary>
/// <param name="DeviceObject">The pointer to DEVICE_OBJECT</param>
/// <param name="Irp">The pointer to IRP</param>
/// <returns>NTSTATUS</returns>
NTSTATUS
IrpNotImplementedHandler(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp
)
{
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
UNREFERENCED_PARAMETER(DeviceObject);
PAGED_CODE();
//
// Complete the request
//
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_NOT_SUPPORTED;
}
/// <summary>
/// IRP Device IoCtl Handler
/// </summary>
/// <param name="DeviceObject">The pointer to DEVICE_OBJECT</param>
/// <param name="Irp">The pointer to IRP</param>
/// <returns>NTSTATUS</returns>
NTSTATUS
IrpDeviceIoCtlHandler(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp
)
{
ULONG IoControlCode = 0;
PIO_STACK_LOCATION IrpSp = NULL;
NTSTATUS Status = STATUS_NOT_SUPPORTED;
UNREFERENCED_PARAMETER(DeviceObject);
PAGED_CODE();
IrpSp = IoGetCurrentIrpStackLocation(Irp);
IoControlCode = IrpSp->Parameters.DeviceIoControl.IoControlCode;
if (IrpSp)
{
switch (IoControlCode)
{
case HEVD_IOCTL_WRITE_OOB:
break;
case HEVD_IOCTL_DO_INOUT:
ReadOOBIoctlHandler(Irp, IrpSp);
break;
default:
DbgPrint("[-] Invalid IOCTL Code: 0x%X\n", IoControlCode);
Status = STATUS_INVALID_DEVICE_REQUEST;
break;
}
}
//
// Update the IoStatus information
//
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
//
// Complete the request
//
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}