• XSS.stack #1 – первый литературный журнал от юзеров форума

syscall windows 7 (sp1) - STATUS_INVALID_PARAMETER

karelli

floppy-диск
Пользователь
Регистрация
16.01.2021
Сообщения
9
Реакции
1
Депозит
0.0002
Тестирование проходило на Windows XP (x86) и на Windows 7 SP1 (x86), на первом код отработал, на втором же возвращает STATUS_INVALID_PARAMETER. Я что-то делаю не так?


C++:
const unsigned char x86sc[] = {
    0xB8, 0xB3, 0x00, 0x00, 0x00, 0x33, 0xC9, 0x8D, 0x54, 0x24, 0x08, 0xCD, 0x2E, 0xC3
};
/* ->
mov eax, 0xB3 (NtOpenFile ID (WIN7 SP1))
xor ecx ecx
lea edx, dword ptr ss:[esp+8]
int 2E
ret
*/

HANDLE hFile = NULL;
IO_STATUS_BLOCK IoStatusBlock;
OBJECT_ATTRIBUTES FileObjectAttributes;
InitializeObjectAttributes(&FileObjectAttributes, &szPath, OBJ_CASE_INSENSITIVE, NULL, NULL);

NTSTATUS NtStatus = reinterpret_cast<NTSTATUS(__stdcall*)(...)>(x86sc)(&hFile, GENERIC_READ | SYNCHRONIZE, &FileObjectAttributes, &IoStatusBlock, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE);
// result = STATUS_INVALID_PARAMETER
 
Номер сискола точно правильный? Не видно, как инициализируется путь к файлу.
точно Правильный, в ntdll сверял. szPath = \??\D:\file.txt
 
Пожалуйста, обратите внимание, что пользователь заблокирован
szPath = \??\D:\file.txt
Там же должна быть UNICODE_STRING , а не просто юникод строка.
 
Там же должна быть UNICODE_STRING , а не просто юникод строка.
я не на столько глупый, тут дело в чем-то другом
UNICODE_STRING uPath;
InitUnicodeString(&uPath, szPath);
 
Пожалуйста, обратите внимание, что пользователь заблокирован
да причем глупый, опечатка может быть.
напиши для начала вызов просто натив апи, без сискола, будет работать или нет? или скинь бинарник.
 
Пожалуйста, обратите внимание, что пользователь заблокирован
Отладь ядерным отладчиком и посмотри какая функция возвращает 0xC000000D, потом там же или идой посмотри подробнее в ntoskrnl.exe. Чтобы сузить круг, параметры атрибутов и имя объекта проверяются в ObOpenObjectByNameEx, ObpCaptureObjectName, ObpCaptureObjectCreateInformation (через них происходит валидация атрибутов internal-объектов: при создании потоков, процессов, файлов и т.д.). Внизу декомпиль с 10 винды, но на 7ке она тоже должна быть. В общем я бы начал с отлова возвращаемого значения этих трех функций, а потом уже смотрел дальше.

C:
// Routine Description:
//
//     This function captures the object creation information and stuff
//     it into the input variable ObjectCreateInfo
//
// Arguments:
//
//     ObjectType - Specifies the type of object we expect to capture,
//         currently ignored.
//
//     ProbeMode - Specifies the processor mode for doing our parameter
//         probes
//
//     CreatorMode - Specifies the mode the object is being created for
//
//     ObjectAttributes - Supplies the object attributes we are trying
//         to capture
//
//     CapturedObjectName - Recieves the name of the object being created
//
//     ObjectCreateInfo - Receives the create information for the object
//         like its root, attributes, and security information
//
//     UseLookaside - Specifies if we are to allocate the captured name
//         buffer from the lookaside list or from straight pool.
//
// Return Value:
//
//     An appropriate status value
NTSTATUS __fastcall ObpCaptureObjectCreateInformation(
        KPROCESSOR_MODE ProbeMode,
        KPROCESSOR_MODE CreatorMode,
        _OBJECT_ATTRIBUTES *ObjectAttributes,
        _UNICODE_STRING *CapturedObjectName,
        _OBJECT_CREATE_INFORMATION *ObCreateInfo,
        LOGICAL UseLookaside)
{
    __int64 Length_low; // rax
    unsigned int Attributes; // eax MAPDST
    UNICODE_STRING *ObjectName; // r14 MAPDST
    PVOID SecurityDescriptor; // r10 MAPDST
    unsigned __int64 SecurityQualityOfService; // rdi MAPDST
    __int64 v15; // rax
    NTSTATUS status; // r12d MAPDST
    __int64 *p_SecurityDescriptor; // r13
    unsigned int v20; // [rsp+34h] [rbp-64h] BYREF
    struct _KTHREAD *CurrentThread; // [rsp+60h] [rbp-38h]
    struct _KTHREAD *Thread; // [rsp+68h] [rbp-30h]

    v20 = 0;
    *CapturedObjectName = 0i64;
    *(_OWORD *)&ObCreateInfo->Attributes = 0i64;
    *(_OWORD *)&ObCreateInfo->ProbeMode = 0i64;
    *(_OWORD *)&ObCreateInfo->SecurityDescriptor = 0i64;
    *(_OWORD *)&ObCreateInfo->SecurityQualityOfService.Length = 0i64;
    if ( !ObjectAttributes )
    {
        return STATUS_SUCCESS;
    }
    ObCreateInfo->ProbeMode = ProbeMode;
    if ( ProbeMode )
    {
        CurrentThread = KeGetCurrentThread();
        if ( CurrentThread->PreviousMode )
        {
            if ( ((unsigned __int8)ObjectAttributes & 7) != 0 )
            {
                goto LABEL_23;
            }
            if ( (unsigned __int64)ObjectAttributes >= 0x7FFFFFFF0000i64 )
            {
                ObjectAttributes = (_OBJECT_ATTRIBUTES *)0x7FFFFFFF0000i64;
            }
            Length_low = LOBYTE(ObjectAttributes->Length);
        }
    }
    if ( ObjectAttributes->Length != 0x30 )
    {
        [COLOR=rgb(226, 80, 65)]status = STATUS_INVALID_PARAMETER;[/COLOR]
        goto LABEL_38;
    }
    ObCreateInfo->RootDirectory = ObjectAttributes->RootDirectory;
    Attributes = ObjectAttributes->Attributes;
    if ( CreatorMode )
    {
        Attributes &= ~0x200u;
    }
    if ( (Attributes & 0xFFFEE00D) != 0 )
    {
        status = STATUS_INVALID_PARAMETER;
        goto LABEL_38;
    }
    ObCreateInfo->Attributes = Attributes;
    ObjectName = ObjectAttributes->ObjectName;
    SecurityDescriptor = ObjectAttributes->SecurityDescriptor;
    SecurityQualityOfService = (unsigned __int64)ObjectAttributes->SecurityQualityOfService;
    if ( SecurityQualityOfService )
    {
        if ( !ProbeMode )
        {
            goto LABEL_19;
        }
        Thread = KeGetCurrentThread();
        if ( !Thread->PreviousMode )
        {
LABEL_19:
            ObCreateInfo->SecurityQualityOfService = *(_SECURITY_QUALITY_OF_SERVICE *)SecurityQualityOfService;
            goto LABEL_24;
        }
        if ( (SecurityQualityOfService & 3) == 0 )
        {
            if ( SecurityQualityOfService >= 0x7FFFFFFF0000i64 )
            {
                SecurityQualityOfService = 0x7FFFFFFF0000i64;
            }
            v15 = *(unsigned __int8 *)SecurityQualityOfService;
            goto LABEL_19;
        }
LABEL_23:
        ExRaiseDatatypeMisalignment();
    }
LABEL_24:
    if ( SecurityDescriptor )
    {
        p_SecurityDescriptor = (__int64 *)&ObCreateInfo->SecurityDescriptor;
        status = SeCaptureSecurityDescriptor(
                     (__int64)SecurityDescriptor,
                     ProbeMode,
                     PagedPool,
                     1,
                     &ObCreateInfo->SecurityDescriptor);
        if ( status < 0 )
        {
            *p_SecurityDescriptor = 0i64;
            goto LABEL_38;
        }
        SeComputeQuotaInformationSize(*p_SecurityDescriptor, &v20);
        ObCreateInfo->SecurityDescriptorCharge = v20;
    }
    if ( !SecurityQualityOfService )
    {
        goto LABEL_26;
    }
    ObCreateInfo->SecurityQualityOfService.Length = 0xC;
    ObCreateInfo->SecurityQos = &ObCreateInfo->SecurityQualityOfService;
    if ( ObCreateInfo->SecurityQualityOfService.ContextTrackingMode >= 2u )
    {
        status = STATUS_INVALID_PARAMETER;
        goto LABEL_38;
    }
    if ( ObCreateInfo->SecurityQualityOfService.ImpersonationLevel > (unsigned int)SecurityDelegation )
    {
        status = STATUS_BAD_IMPERSONATION_LEVEL;
    }
    else
    {
LABEL_26:
        if ( ObjectName )
        {
            status = ObpCaptureObjectName(ProbeMode, ObjectName, CapturedObjectName, UseLookaside);
            if ( status >= 0 )
            {
                return STATUS_SUCCESS;
            }
        }
        else
        {
            if ( !ObCreateInfo->RootDirectory )
            {
                return STATUS_SUCCESS;
            }
            status = STATUS_OBJECT_NAME_INVALID;
        }
    }
LABEL_38:
    SecurityDescriptor = ObCreateInfo->SecurityDescriptor;
    if ( SecurityDescriptor )
    {
        SeReleaseSecurityDescriptor(SecurityDescriptor, ObCreateInfo->ProbeMode, 1);
        ObCreateInfo->SecurityDescriptor = 0i64;
    }
    return status;
}
 
Последнее редактирование:


Напишите ответ...
  • Вставить:
Прикрепить файлы
Верх