Exploit database

GH-557a35ec88cecc5153df8ffeda95d1c2

bob11vrdp/cve-2022-39425

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2022-39425

1 source

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.

Repository files5

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

VirtualBox-6.1.38/src/VBox/Additions/WINNT/SharedFolders/testcase/queryfileinfo-1.cpp

C++ · 5,994 bytes
/* $Id: queryfileinfo-1.cpp $ */
/** @file
 * VirtualBox Windows Guest Shared Folders FSD - Simple Testcase.
 */

/*
 * Copyright (C) 2019-2020 Oracle Corporation
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 */

#include <iprt/nt/nt-and-windows.h>
#include <stdio.h>

static const char * const g_apszFileInfoNames[] =
{
    "0",
    "FileDirectoryInformation",
    "FileFullDirectoryInformation",
    "FileBothDirectoryInformation",
    "FileBasicInformation",
    "FileStandardInformation",
    "FileInternalInformation",
    "FileEaInformation",
    "FileAccessInformation",
    "FileNameInformation",
    "FileRenameInformation",
    "FileLinkInformation",
    "FileNamesInformation",
    "FileDispositionInformation",
    "FilePositionInformation",
    "FileFullEaInformation",
    "FileModeInformation",
    "FileAlignmentInformation",
    "FileAllInformation",
    "FileAllocationInformation",
    "FileEndOfFileInformation",
    "FileAlternateNameInformation",
    "FileStreamInformation",
    "FilePipeInformation",
    "FilePipeLocalInformation",
    "FilePipeRemoteInformation",
    "FileMailslotQueryInformation",
    "FileMailslotSetInformation",
    "FileCompressionInformation",
    "FileObjectIdInformation",
    "FileCompletionInformation",
    "FileMoveClusterInformation",
    "FileQuotaInformation",
    "FileReparsePointInformation",
    "FileNetworkOpenInformation",
    "FileAttributeTagInformation",
    "FileTrackingInformation",
    "FileIdBothDirectoryInformation",
    "FileIdFullDirectoryInformation",
    "FileValidDataLengthInformation",
    "FileShortNameInformation",
    "FileIoCompletionNotificationInformation",
    "FileIoStatusBlockRangeInformation",
    "FileIoPriorityHintInformation",
    "FileSfioReserveInformation",
    "FileSfioVolumeInformation",
    "FileHardLinkInformation",
    "FileProcessIdsUsingFileInformation",
    "FileNormalizedNameInformation",
    "FileNetworkPhysicalNameInformation",
    "FileIdGlobalTxDirectoryInformation",
    "FileIsRemoteDeviceInformation",
    "FileUnusedInformation",
    "FileNumaNodeInformation",
    "FileStandardLinkInformation",
    "FileRemoteProtocolInformation",
    "FileRenameInformationBypassAccessCheck",
    "FileLinkInformationBypassAccessCheck",
    "FileVolumeNameInformation",
    "FileIdInformation",
    "FileIdExtdDirectoryInformation",
    "FileReplaceCompletionInformation",
    "FileHardLinkFullIdInformation",
    "FileIdExtdBothDirectoryInformation",
    "FileDispositionInformationEx",
    "FileRenameInformationEx",
    "FileRenameInformationExBypassAccessCheck",
    "FileDesiredStorageClassInformation",
    "FileStatInformation",
    "FileMemoryPartitionInformation",
    "FileStatLxInformation",
    "FileCaseSensitiveInformation",
    "FileLinkInformationEx",
    "FileLinkInformationExBypassAccessCheck",
    "FileStorageReserveIdInformation",
    "FileCaseSensitiveInformationForceAccessCheck",
    "FileMaximumInformation",
    "FileMaximumInformation+1",
    "FileMaximumInformation+2",
    "FileMaximumInformation+3",
    "FileMaximumInformation+4",
    "FileMaximumInformation+5",
    "FileMaximumInformation+6",
    "FileMaximumInformation+7",
    "FileMaximumInformation+8",
    "FileMaximumInformation+9",
    "FileMaximumInformation+10",
    "FileMaximumInformation+11",
    "FileMaximumInformation+12",
};

static const char *GetStatusName(NTSTATUS rcNt)
{
    switch (rcNt)
    {
        case STATUS_SUCCESS:                    return " (STATUS_SUCCESS)";
        case STATUS_INVALID_INFO_CLASS:         return " (STATUS_INVALID_INFO_CLASS)";
        case STATUS_INVALID_PARAMETER:          return " (STATUS_INVALID_PARAMETER)";
        case STATUS_INVALID_DEVICE_REQUEST:     return " (STATUS_INVALID_DEVICE_REQUEST)";
        case STATUS_NO_SUCH_DEVICE:             return " (STATUS_NO_SUCH_DEVICE)";
        case STATUS_NOT_SUPPORTED:              return " (STATUS_NOT_SUPPORTED)";
    }
    return "";
}

static void DoQueries(HANDLE hFile)
{
    union
    {
        uint8_t abBuf[4096];
    } uBuf;

    IO_STATUS_BLOCK const VirginIos = RTNT_IO_STATUS_BLOCK_INITIALIZER;
    for (unsigned iClass = 0; iClass < RT_ELEMENTS(g_apszFileInfoNames); iClass++)
    {
        IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER;
        NTSTATUS rcNt = NtQueryInformationFile(hFile, &Ios, &uBuf, sizeof(uBuf), (FILE_INFORMATION_CLASS)iClass);
        printf("  %45s: rcNt=%#x%s", g_apszFileInfoNames[iClass], rcNt, GetStatusName(rcNt));
        if (   Ios.Information == VirginIos.Information
            && Ios.Status == VirginIos.Status)
            printf(" Ios=<not modified>\n", Ios.Status, Ios.Information);
        else
            printf(" Ios.Status=%#x%s Ios.Information=%p\n", Ios.Status, GetStatusName(Ios.Status), Ios.Information);
        if (NT_SUCCESS(rcNt))
        {
        }
    }
}


int main(int argc, char **argv)
{
    for (int i = 1; i < argc; i++)
    {
        printf("Querying info for: %s\n", argv[i]);
        HANDLE hFile = CreateFileA(argv[i], GENERIC_READ, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
                                   NULL /*pSecAttr*/, OPEN_EXISTING,
                                   FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS,
                                   NULL /*hTemplate*/);
        if (hFile != INVALID_HANDLE_VALUE)
        {
            DoQueries(hFile);
            CloseHandle(hFile);
        }
        else
            fprintf(stderr, "error opening '%s': %u\n", GetLastError());
    }
    return 0;
}