Advertisement
Guest User

Untitled

a guest
Jul 13th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.68 KB | None | 0 0
  1. using System.Threading;
  2. using System.Management;
  3. using System;
  4. using System.Diagnostics;
  5. using System.IO;
  6. using System.Reflection;
  7.  
  8. namespace ConsoleApplication1
  9. {
  10.  
  11.     class Program
  12.     {
  13.         static int Main(string[] args)
  14.         {
  15.             Console.WriteLine(@"
  16.   _____ _    _ _____  _____  ______ _   _ _____  ______ _____  
  17.  / ____| |  | |  __ \|  __ \|  ____| \ | |  __ \|  ____|  __ \
  18. | (___ | |  | | |__) | |__) | |__  |  \| | |  | | |__  | |__) |
  19.  \___ \| |  | |  _  /|  _  /|  __| | . ` | |  | |  __| |  _  /
  20.  ____) | |__| | | \ \| | \ \| |____| |\  | |__| | |____| | \ \
  21. |_____/ \____/|_| _\_\_|__\_\______|_|_\_|_____/|______|_|  \_\
  22.  / ____/ __ \| \ | |__   __|  __ \ / __ \| |                  
  23. | |   | |  | |  \| |  | |  | |__) | |  | | |                  
  24. | |   | |  | | . ` |  | |  |  _  /| |  | | |                  
  25. | |___| |__| | |\  |  | |  | | \ \| |__| | |____              
  26.  \_____\____/|_| \_|  |_|  |_|  \_\\____/|______|
  27. ");
  28.             Console.WriteLine("Please get rid of mouses and keyboards.");
  29.             while (true)
  30.             {
  31.                 BaseGame:
  32.                 int score = CountDevices();
  33.                 Console.WriteLine($"You have approximately {score} control devices.");
  34.  
  35.                 if (score == 0)
  36.                 {
  37.                     int time = 15;
  38.                     for (int i = 0; i < time; ++i)
  39.                     {
  40.                         Console.WriteLine($"Thanks. We will be deleted in {time - i}s, press <Enter> to cancel.");
  41.                         score = CountDevices();
  42.                         Thread.Sleep(1000);
  43.                         if (score > 0)
  44.                         {
  45.                             goto BaseGame;
  46.                         }
  47.                     }
  48.                     SelfDestruct();
  49.                     return 4577;
  50.                 }
  51.                 Thread.Sleep(1000);
  52.             }
  53.         }
  54.  
  55.         static int CountDevices()
  56.         {
  57.             int count = 0;
  58.             using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_PointingDevice"))
  59.             using (ManagementObjectCollection collection = searcher.Get())
  60.                 count += collection.Count;
  61.  
  62.             using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_Keyboard"))
  63.             using (ManagementObjectCollection collection = searcher.Get())
  64.                 count += collection.Count;
  65.  
  66.             return count;
  67.         }
  68.  
  69.         static void SelfDestruct()
  70.         {
  71.             Process procDestruct = new Process();
  72.             string strName = "destruct.bat";
  73.             string strPath = Path.Combine(Directory
  74.                .GetCurrentDirectory(), strName);
  75.             string strExe = Process.GetCurrentProcess().MainModule.FileName;
  76.  
  77.             StreamWriter swDestruct = new StreamWriter(strPath);
  78.  
  79.             swDestruct.WriteLine("attrib \"" + strExe + "\"" +
  80.              " -a -s -r -h");
  81.             swDestruct.WriteLine(":Repeat");
  82.             swDestruct.WriteLine("del " + "\"" + strExe + "\"");
  83.             swDestruct.WriteLine("if exist \"" + strExe + "\"" +
  84.                " goto Repeat");
  85.             swDestruct.WriteLine("del \"" + strExe.Replace("exe", "zip") + "\"");
  86.             swDestruct.WriteLine("del \"" + strName + "\"");
  87.             swDestruct.Close();
  88.  
  89.             procDestruct.StartInfo.FileName = "destruct.bat";
  90.  
  91.             procDestruct.StartInfo.CreateNoWindow = true;
  92.             procDestruct.StartInfo.UseShellExecute = false;
  93.  
  94.             try
  95.             {
  96.  
  97.                 procDestruct.Start();
  98.  
  99.             }
  100.             catch (Exception)
  101.             {
  102.             }
  103.         }
  104.     }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement