forked from hackedteam/core-win32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_functions.cpp
187 lines (148 loc) · 4.14 KB
/
demo_functions.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#include "demo_functions.h"
HWND g_report_hwnd = NULL;
#include "common.h"
#include "H4-DLL.h"
#include <string>
#define DESKTOP_BMP_NAME "infected.bmp"
BOOL is_exit_scheduled = FALSE;
std::string g_log_report = "";
void SetDesktopBackground()
{
HANDLE hfile;
DWORD dummy;
char bitmap_path[_MAX_PATH + 1];
if (!is_demo_version)
return;
HM_CompletePath(DESKTOP_BMP_NAME, bitmap_path);
// Adesso il file nella versione demo viene scritto dal dropper
/*hfile = FNC(CreateFileA)(bitmap_path, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, NULL, NULL);
if (hfile != INVALID_HANDLE_VALUE) {
FNC(WriteFile)(hfile, biohazard_bmp, biohazard_bmp_len, &dummy, NULL);
CloseHandle(hfile);
}*/
FNC(SystemParametersInfoA)(SPI_SETDESKWALLPAPER, 0, bitmap_path, 0);
}
void RemoveDesktopBackground()
{
if (!is_demo_version)
return;
FNC(SystemParametersInfoA)(SPI_SETDESKWALLPAPER, 0, "", 0);
}
LRESULT CALLBACK WndProcDemo(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
HRGN hRgn;
HBRUSH hBrush;
HFONT hFont;
LOGFONT logFont;
HFONT ccFont;
switch (msg) {
case WM_COPYDATA:
return 1;
break;
case WM_CHAR:
if (is_exit_scheduled && wParam == VK_RETURN)
FNC(ExitProcess)(0);
break;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps);
GetClientRect (hwnd, &rect);
hRgn = CreateRectRgn (0, 0, rect.right, rect.bottom);
hBrush = CreateSolidBrush (0x00000000);
FillRgn (hdc, hRgn, hBrush);
DeleteObject (hRgn);
DeleteObject (hBrush);
SetTextColor(hdc, RGB(0xFF,0xFF,0xFF));
SetBkColor(hdc, RGB(0,0,0));
hFont = (HFONT)GetStockObject(ANSI_FIXED_FONT);
GetObject(hFont, sizeof(logFont), &logFont);
logFont.lfHeight *= 2;
logFont.lfWidth *= 2;
ccFont = CreateFontIndirect(&logFont);
SelectObject(hdc, ccFont);
DrawText (hdc, TEXT (g_log_report.c_str()), -1, &rect, DT_LEFT) ;
EndPaint (hwnd, &ps) ;
return 0 ;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
return 1;
}
BOOL CreateLogWindow()
{
WNDCLASSEX wc;
char szClassName[] = "LogWindowClass";
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_NOCLOSE;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = NULL;
wc.hIcon = LoadIcon(NULL, IDI_INFORMATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = 0;
wc.lpszMenuName = NULL;
wc.lpszClassName = szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_INFORMATION);
if (is_demo_version) {
wc.lpfnWndProc = WndProcDemo;
if(!RegisterClassEx(&wc)) {
MessageBox(NULL, "Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
return FALSE;
}
g_report_hwnd = CreateWindowEx( NULL, szClassName, "StatusLog", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 500, NULL, NULL, NULL, NULL);
if (!g_report_hwnd) {
MessageBox(NULL, "Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
return FALSE;
}
ShowWindow(g_report_hwnd, SW_SHOW);
UpdateWindow(g_report_hwnd);
return TRUE;
} else {
wc.lpfnWndProc = WndProc;
if(!RegisterClassEx(&wc))
return FALSE;
g_report_hwnd = CreateWindowEx( NULL, szClassName, "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 1, 1, NULL, NULL, NULL, NULL);
if (!g_report_hwnd)
return FALSE;
return TRUE;
}
}
void ReportStatusLog(char *status_log)
{
if (!is_demo_version)
return;
if (g_report_hwnd) {
g_log_report += status_log;
InvalidateRect(g_report_hwnd, NULL, FALSE);
UpdateWindow(g_report_hwnd);
}
}
void ReportExitProcess()
{
MSG msg;
if (!is_demo_version)
ExitProcess(0);
ReportStatusLog("\r\nExecution Terminated\r\nPress CR to exit...");
is_exit_scheduled = TRUE;
// Entra in un ciclo infinito dispatchando i messaggi alla window proc
// che fara' la exit process quando si preme invio
for (;;) {
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
} else
Sleep(200);
}
}
void ReportCannotInstall()
{
if (!is_demo_version)
return;
MessageBox(NULL, "Insufficient privileges", "Warning", MB_OK);
}