CreateProcessWithLogonW 无法读取 0xCCCCCCCC 错误

CreateProcessWithLogonW can't read 0xCCCCCCCC Error

我目前正在尝试使用 C++ 将用户名和密码注入 lsass.exe,我是 C++ 的新手,所以这可能是一个愚蠢的问题,但它总是抛出错误“0xC0000005:访问冲突读取”在位置 0xCCCCCCCC'。这是我的代码:

#include <iostream>
#include <windows.h>
#include <processthreadsapi.h>

int main()
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    si.dwFlags = 0x00000001;
    si.wShowWindow = 0;
    LPCWSTR userName = L"username"; // The username that will be injected into LSASS
    LPCWSTR userDomain = L"domain"; // The Logon Domain that will be injected into LSASS
    LPCWSTR userPassword = L"password"; // The User Password that will be injected into LSASS
    LPCWSTR applicationName = L"path";
    LPCWSTR currentDirectory = L"C:\";

    bool r = CreateProcessWithLogonW(userName, userDomain, userPassword, 0x00000002, applicationName, NULL, 0x04000000, NULL, currentDirectory, &si, &pi);
    std::cout << r << std::endl;
    WaitForSingleObject(pi.hProcess, INFINITE);
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
}

我不确定,但在visual studio调试器的变量列表中,&pi和&si包含'0xCCCCCCCC',更具体地说:&pi的hProcess和hThread都有它

我几乎只是从这里复制粘贴代码:https://blog.spookysec.net/DnD-LSASS-Injection/ 这对他们有用...

提前感谢您的帮助

编辑:现在可以运行,我已经改了

STARTUPINFO si;
PROCESS_INFORMATION pi;

STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};

但我似乎没有应有的权限...我登录了自己的用户帐户,但甚至无法复制启动文件夹中的文件...

您需要对 STARTUPINFO 结构进行更多初始化。特别是结构的大小。操作系统使用结构的大小来确定存在哪些成员。好像是结构版。

STARTUPINFO si = {0};

si.cb = sizeof(si);