Skip to content

Commit b0855e2

Browse files
committed
v 3.6.2
Method 75 added, see #130 for more info; Fix Win7 regression added in 3.6.1; Readme updated.
1 parent af0b0d6 commit b0855e2

26 files changed

Lines changed: 991 additions & 160 deletions

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2014 - 2022, UACMe authors
1+
Copyright (c) 2014 - 2022, UACMe Project
22

33
Redistribution and use in source and binary forms, with or without
44
modification, are permitted provided that the following conditions are met:

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,11 +758,21 @@ First parameter is number of method to use, second is optional command (executab
758758
* Method: IElevatedFactoryServer
759759
* Target(s): Attacker defined
760760
* Component(s): Attacker defined
761-
* Implementation: ucmVirtualFactoryServer
761+
* Implementation: ucmVFServerTaskSchedMethod
762762
* Works from: Windows 8.1 (9600)
763763
* Fixed in: unfixed :see_no_evil:
764764
* How: -
765765
* Code status: added in v3.6.1
766+
75. Author: zcgonvh derivative by Wh04m1001
767+
* Type: Elevated COM interface
768+
* Method: IDiagnosticProfile
769+
* Target(s): Attacker defined
770+
* Component(s): Attacker defined
771+
* Implementation: ucmVFServerDiagProfileMethod
772+
* Works from: Windows 7 RTM (7600)
773+
* Fixed in: unfixed :see_no_evil:
774+
* How: -
775+
* Code status: added in v3.6.2
766776

767777
</details>
768778

Source/Akagi/Resource.rc

0 Bytes
Binary file not shown.

Source/Akagi/console.c

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*******************************************************************************
2+
*
3+
* (C) COPYRIGHT AUTHORS, 2022
4+
*
5+
* TITLE: CONSOLE.C
6+
*
7+
* VERSION: 3.62
8+
*
9+
* DATE: 08 Jul 2022
10+
*
11+
* Debug console.
12+
*
13+
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
14+
* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
15+
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
16+
* PARTICULAR PURPOSE.
17+
*
18+
*******************************************************************************/
19+
20+
#include "global.h"
21+
22+
HANDLE StdOutputHandle = NULL;
23+
24+
pswprintf_s _swprintf_s = NULL;
25+
26+
VOID ConsolePrint(
27+
_In_ LPCWSTR Message
28+
)
29+
{
30+
WriteConsole(StdOutputHandle, Message, (ULONG)_strlen(Message), NULL, NULL);
31+
}
32+
33+
VOID ConsolePrintValueUlong(
34+
_In_ LPCWSTR Message,
35+
_In_ ULONG Value,
36+
_In_ BOOL Hexademical
37+
)
38+
{
39+
WCHAR szText[200];
40+
41+
if (_swprintf_s) {
42+
43+
_swprintf_s(szText, RTL_NUMBER_OF(szText),
44+
Hexademical ? TEXT("%ws 0x%lX\r\n") : TEXT("%ws %lu\r\n"),
45+
Message,
46+
Value);
47+
48+
ConsolePrint(szText);
49+
}
50+
}
51+
52+
VOID ConsolePrintStatus(
53+
_In_ LPCWSTR Message,
54+
_In_ NTSTATUS Status
55+
)
56+
{
57+
ConsolePrintValueUlong(Message, Status, TRUE);
58+
}
59+
60+
VOID ConsoleInit(
61+
VOID
62+
)
63+
{
64+
WCHAR szBuffer[100];
65+
HMODULE hNtdll = GetModuleHandle(L"ntdll.dll");
66+
67+
if (hNtdll == NULL || !AllocConsole())
68+
return;
69+
70+
_swprintf_s = (pswprintf_s)GetProcAddress(hNtdll, "swprintf_s");
71+
if (_swprintf_s == NULL)
72+
return;
73+
74+
StdOutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
75+
SetConsoleMode(StdOutputHandle, ENABLE_PROCESSED_OUTPUT |
76+
ENABLE_VIRTUAL_TERMINAL_PROCESSING);
77+
78+
_swprintf_s(szBuffer, RTL_NUMBER_OF(szBuffer), TEXT("[*] UACMe v%lu.%lu.%lu.%lu\r\n"),
79+
UCM_VERSION_MAJOR,
80+
UCM_VERSION_MINOR,
81+
UCM_VERSION_REVISION,
82+
UCM_VERSION_BUILD);
83+
84+
SetConsoleTitle(szBuffer);
85+
}
86+
87+
BOOL ConsoleIsKeyPressed(
88+
_In_ WORD VirtualKeyCode
89+
)
90+
{
91+
BOOL bResult = FALSE;
92+
DWORD numberOfEvents = 0;
93+
INPUT_RECORD inp1;
94+
HANDLE nStdHandle = GetStdHandle(STD_INPUT_HANDLE);
95+
96+
GetNumberOfConsoleInputEvents(nStdHandle, &numberOfEvents);
97+
98+
if (numberOfEvents) {
99+
100+
PeekConsoleInput(nStdHandle, &inp1, 1, &numberOfEvents);
101+
102+
bResult = (numberOfEvents != 0 &&
103+
inp1.EventType == KEY_EVENT &&
104+
inp1.Event.KeyEvent.bKeyDown &&
105+
inp1.Event.KeyEvent.wVirtualKeyCode == VirtualKeyCode);
106+
107+
FlushConsoleInputBuffer(nStdHandle);
108+
}
109+
110+
return bResult;
111+
}
112+
113+
VOID ConsoleRelease(
114+
VOID
115+
)
116+
{
117+
DWORD dwStop = GetTickCount() + (10 * 1000);
118+
119+
ConsolePrint(TEXT("[+] Press Enter to exit or wait few seconds and it will close automatically\r\n"));
120+
121+
while (!ConsoleIsKeyPressed(VK_RETURN) && GetTickCount() < dwStop)
122+
Sleep(50);
123+
124+
FreeConsole();
125+
}

Source/Akagi/console.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*******************************************************************************
2+
*
3+
* (C) COPYRIGHT AUTHORS, 2022
4+
*
5+
* TITLE: CONSOLE.H
6+
*
7+
* VERSION: 3.62
8+
*
9+
* DATE: 08 Jul 2022
10+
*
11+
* Debug console header file.
12+
*
13+
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
14+
* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
15+
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
16+
* PARTICULAR PURPOSE.
17+
*
18+
*******************************************************************************/
19+
20+
#pragma once
21+
22+
VOID ConsoleInit(
23+
VOID);
24+
25+
VOID ConsoleRelease(
26+
VOID);
27+
28+
VOID ConsolePrintStatus(
29+
_In_ LPCWSTR Message,
30+
_In_ NTSTATUS Status);
31+
32+
VOID ConsolePrint(
33+
_In_ LPCWSTR Message);
34+
35+
VOID ConsolePrintValueUlong(
36+
_In_ LPCWSTR Message,
37+
_In_ ULONG Value,
38+
_In_ BOOL Hexademical);
39+
40+
#ifdef _UCM_CONSOLE
41+
#define ucmConsoleInit ConsoleInit
42+
#define ucmConsoleRelease ConsoleRelease
43+
#define ucmConsolePrintStatus ConsolePrintStatus
44+
#define ucmConsolePrint ConsolePrint
45+
#define ucmConsolePrintValueUlong ConsolePrintValueUlong
46+
#else
47+
#define ucmConsoleInit()
48+
#define ucmConsoleRelease()
49+
#define ucmConsolePrintStatus(Message, Status)
50+
#define ucmConsolePrint(Message)
51+
#define ucmConsolePrintValueUlong(Message, Value, Hexademical)
52+
#endif

Source/Akagi/global.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
*
55
* TITLE: GLOBAL.H
66
*
7-
* VERSION: 3.61
7+
* VERSION: 3.62
88
*
9-
* DATE: 22 Jun 2022
9+
* DATE: 07 Jul 2022
1010
*
1111
* Common header file for the program support routines.
1212
*
@@ -82,6 +82,7 @@
8282
#include "compress.h"
8383
#include "aic.h"
8484
#include "stub.h"
85+
#include "console.h"
8586
#include "methods\methods.h"
8687

8788
//default execution flow
@@ -108,6 +109,8 @@ typedef struct _UACME_CONTEXT {
108109

109110
PVOID ucmHeap;
110111
pfnDecompressPayload DecompressRoutine;
112+
pswprintf_s swprintf_s;
113+
111114
UACME_FUSION_CONTEXT FusionContext;
112115
UACME_SHARED_CONTEXT SharedContext;
113116

Source/Akagi/main.c

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,6 @@ PUACMECONTEXT g_ctx;
2626
//Image Base Address global variable
2727
HINSTANCE g_hInstance;
2828

29-
#define ENABLE_OUTPUT
30-
#undef ENABLE_OUTPUT
31-
32-
#ifdef ENABLE_OUTPUT
33-
VOID ucmShowVersion(
34-
VOID)
35-
{
36-
DWORD bytesIO;
37-
WCHAR szVersion[100];
38-
39-
#ifdef _DEBUG
40-
if (!AllocConsole()) {
41-
return;
42-
}
43-
#else
44-
if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
45-
return;
46-
}
47-
#endif
48-
49-
RtlSecureZeroMemory(&szVersion, sizeof(szVersion));
50-
wsprintf(szVersion, TEXT("v%lu.%lu.%lu.%lu"),
51-
UCM_VERSION_MAJOR,
52-
UCM_VERSION_MINOR,
53-
UCM_VERSION_REVISION,
54-
UCM_VERSION_BUILD);
55-
56-
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), &szVersion, _strlen(szVersion), &bytesIO, NULL);
57-
58-
FreeConsole();
59-
}
60-
#endif
61-
6229
/*
6330
* ucmInit
6431
*
@@ -90,6 +57,8 @@ NTSTATUS ucmInit(
9057

9158
wdCheckEmulatedVFS();
9259

60+
ucmConsoleInit();
61+
9362
bytesIO = 0;
9463
RtlQueryElevationFlags(&bytesIO);
9564
if ((bytesIO & DBG_FLAG_ELEVATION_ENABLED) == 0)
@@ -109,9 +78,6 @@ NTSTATUS ucmInit(
10978
RtlSecureZeroMemory(szBuffer, sizeof(szBuffer));
11079
GetCommandLineParam(GetCommandLine(), 1, szBuffer, MAX_PATH, &bytesIO);
11180
if (bytesIO == 0) {
112-
#ifdef ENABLE_OUTPUT
113-
ucmShowVersion();
114-
#endif
11581
return STATUS_INVALID_PARAMETER;
11682
}
11783

@@ -193,6 +159,8 @@ NTSTATUS WINAPI ucmMain(
193159
OptionalParameter,
194160
OptionalParameterLength);
195161

162+
ucmConsolePrintStatus(TEXT("[*] ucmInit"), Status);
163+
196164
if (!NT_SUCCESS(Status))
197165
return Status;
198166

@@ -212,5 +180,15 @@ NTSTATUS WINAPI ucmMain(
212180
#pragma comment(linker, "/ENTRY:main")
213181
VOID __cdecl main()
214182
{
183+
#ifdef _UCM_CONSOLE
184+
ULONG result;
185+
186+
result = StubInit(ucmMain);
187+
ucmConsolePrintValueUlong(TEXT("[+] ucmMain"), result, TRUE);
188+
ucmConsoleRelease();
189+
ExitProcess(result);
190+
191+
#else
215192
ExitProcess(StubInit(ucmMain));
193+
#endif
216194
}

Source/Akagi/methods/comsup.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
*
55
* TITLE: COMSUP.H
66
*
7-
* VERSION: 3.61
7+
* VERSION: 3.62
88
*
9-
* DATE: 22 Jun 2022
9+
* DATE: 04 Jul 2022
1010
*
1111
* Prototypes and definitions for COM interfaces and routines.
1212
*

Source/Akagi/methods/elvint.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
*
55
* TITLE: ELVINT.H
66
*
7-
* VERSION: 3.61
7+
* VERSION: 3.62
88
*
9-
* DATE: 22 Jun 2022
9+
* DATE: 04 Jul 2022
1010
*
1111
* Prototypes and definitions for elevated interface methods.
1212
*
@@ -481,7 +481,7 @@ typedef struct IElevatedFactoryServerVtbl {
481481

482482
END_INTERFACE
483483

484-
} *PIElevatedFactoryServerVtbll;
484+
} *PIElevatedFactoryServerVtbl;
485485

486486
// INTERFACE DEF
487487

0 commit comments

Comments
 (0)