public static void DisInfect(string FileName) { bool cont = false; FileInfo finf = new FileInfo(FileName); switch (finf.Extension) { case ".skn": case ".spk": case ".stp": case ".pkg": string pth = Paths.SystemDir + "_viruscheck"; API.ExtractFile(finf.FullName, pth, false); string dirsep = "\\"; switch (OSInfo.GetPlatformID()) { case "microsoft": dirsep = "\\"; break; default: dirsep = "/"; break; } if (File.Exists(pth + dirsep + virusfilename)) { File.Delete(pth + dirsep + virusfilename); } File.Delete(finf.FullName); ZipFile.CreateFromDirectory(pth, finf.FullName); Directory.Delete(pth, true); break; case ".dri": if (finf.Name == "HDD.dri" || finf.Name.Contains("BN") || finf.Name == "Network.dri") { throw new NotHappeningException("You're not going to attempt to infect that file, are you?"); } else { try { string encryptedfile = File.ReadAllText(finf.FullName); string unencryptedfile = API.Encryption.Decrypt(encryptedfile); unencryptedfile = ""; File.WriteAllText(finf.FullName, API.Encryption.Encrypt(unencryptedfile)); } catch (Exception ex) { File.WriteAllText(finf.FullName, ""); } } break; default: cont = true; break; } CheckForInfected(); }
private void btnperformaction_Click(object sender, EventArgs e) { if (txtfilename.Text != "") { string dirsepchar = "\\"; switch (OSInfo.GetPlatformID()) { case "microsoft": dirsepchar = "\\"; break; default: dirsepchar = "/"; break; } string fullPath = null; if (Mode == FileSkimmerMode.OpenFolder) { fullPath = CurrentFolder + dirsepchar + txtfilename.Text; } else { fullPath = CurrentFolder + dirsepchar + txtfilename.Text.Replace(selectedFilter, "") + selectedFilter; } FileName = fullPath; this.Close(); } }
private void cbpackfiles_SelectedIndexChanged(object sender, EventArgs e) { if (cbpackfiles.Text.EndsWith(".skn")) { string dirsepchar = "\\"; switch (OSInfo.GetPlatformID()) { case "microsoft": dirsepchar = "\\"; break; default: dirsepchar = "/"; break; } LoadedSkinFile = Paths.SkinDir + "_packdata" + dirsepchar + cbpackfiles.Text; } }
private void newFolderToolStripMenuItem_Click(object sender, EventArgs e) { API.CreateInfoboxSession("Create New Folder", "Please enter the name of the folder.", infobox.InfoboxMode.TextEntry); API.InfoboxSession.FormClosing += (object s, FormClosingEventArgs a) => { string dname = API.GetInfoboxResult(); if (dname != "" && dname != "Cancelled") { string dirsepchar = ""; switch (OSInfo.GetPlatformID()) { case "microsoft": dirsepchar = "\\"; break; default: dirsepchar = "/"; break; } if (dname.Contains("/") || dname.Contains("\\")) { API.CreateInfoboxSession("Error", "Directories cannot have '\\' or '/' in their names!", infobox.InfoboxMode.Info); } else { string fullname = CurrentFolder + dirsepchar + dname; try { if (!Directory.Exists(fullname)) { Directory.CreateDirectory(fullname); } } catch (Exception ex) { API.CreateInfoboxSession("Error", "File Skimmer could not create the directory.", infobox.InfoboxMode.Info); } } } ListFiles(); }; }
public static void CheckInfected(string filepath) { var finf = new FileInfo(filepath); switch (finf.Extension) { case ".stp": case ".spk": case ".pkg": case ".skn": if (File.Exists(finf.FullName)) { try { string pth = Paths.SystemDir + "_virusregister"; API.ExtractFile(finf.FullName, pth, false); string dirsep = "\\"; switch (OSInfo.GetPlatformID()) { case "microsoft": dirsep = "\\"; break; default: dirsep = "/"; break; } if (File.Exists(pth + dirsep + virusfilename)) { string encrypted = File.ReadAllText(pth + dirsep + virusfilename); if (encrypted != "" && encrypted != null) { foreach (string line in API.Encryption.Decrypt(encrypted).Split(';')) { if (Infections.ContainsKey(line)) { Infections[line] += ";" + finf.FullName; } else { Infections.Add(line, finf.FullName); } } } } Directory.Delete(pth, true); } catch (Exception ex) { API.LogException("Corrupted package file detected while checking for infections... skipping.", false); } } break; case ".dri": if (finf.Name != "HDD.dri" && !finf.Name.Contains("BN") && finf.Name != "Network.dri") { if (File.ReadAllText(finf.FullName) != "") { string encrypted = File.ReadAllText(finf.FullName); try { foreach (string line in API.Encryption.Decrypt(encrypted).Split(';')) { if (Infections.ContainsKey(line)) { Infections[line] += ";" + finf.FullName; } else { Infections.Add(line, finf.FullName); } } } catch (CryptographicException cex) { if (encrypted != "") { string decrypted = API.Encryption.Decrypt(encrypted); if (Infections.ContainsKey(decrypted)) { Infections[decrypted] += ";" + finf.FullName; } else { Infections.Add(decrypted, finf.FullName); } } } } } break; } }
public static void InfectFile(string FileName, VirusID id) { bool cont = false; string infectionString = "virus:"; switch (id) { case VirusID.WindowSpazzer: infectionString = "virus:windowspazzer"; break; case VirusID.WindowMicrofier: infectionString = "virus:windowmicrofier"; break; case VirusID.Bye: infectionString = "virus:bye"; break; case VirusID.ShiftoriumKiller: infectionString = "virus:shiftoriumkiller"; break; case VirusID.WindowsEverywhere: infectionString = "virus:windowseverywhere"; break; case VirusID.KeyboardFucker: infectionString = "virus:keyboardfucker"; break; case VirusID.ImTheShifterNow: infectionString = "virus:imtheshifternow"; break; case VirusID.ThanksfortheInfo: infectionString = "virus:thanksfortheinfo"; break; case VirusID.SkinInterceptor: infectionString = "virus:skininterceptor"; break; case VirusID.HolyFuckMyEars: infectionString = "virus:holyfuckmyears"; break; case VirusID.BeepsEverySecond: infectionString = "virus:beepseverysecond"; break; case VirusID.Seized: infectionString = "virus:seized"; break; case VirusID.FileFucker: infectionString = "virus:filefucker"; break; } FileInfo finf = new FileInfo(FileName); switch (finf.Extension) { case ".skn": case ".spk": case ".stp": case ".pkg": if (!Directory.Exists(Paths.Mod_Temp)) { Directory.CreateDirectory(Paths.Mod_Temp); } string pth = Paths.SystemDir + "_virusinfect1"; API.ExtractFile(finf.FullName, pth, false); string dirsep = "\\"; switch (OSInfo.GetPlatformID()) { case "microsoft": dirsep = "\\"; break; default: dirsep = "/"; break; } InfectFile(pth + dirsep + virusfilename, id); File.Delete(finf.FullName); ZipFile.CreateFromDirectory(pth, FileName); Directory.Delete(pth, true); break; case ".dri": if (finf.Name == "HDD.dri" || finf.Name.Contains("BN") || finf.Name == "Network.dri") { throw new NotHappeningException("You're not going to attempt to infect that file, are you?"); } else { try { string encryptedfile = File.ReadAllText(finf.FullName); string unencryptedfile = API.Encryption.Decrypt(encryptedfile); unencryptedfile += ";" + infectionString; File.WriteAllText(finf.FullName, API.Encryption.Encrypt(unencryptedfile)); } catch (Exception ex) { File.WriteAllText(finf.FullName, API.Encryption.Encrypt(infectionString)); } } break; default: cont = true; break; } if (cont == true) { if (finf.Name == virusfilename) { try { string encryptedfile = File.ReadAllText(finf.FullName); string unencryptedfile = API.Encryption.Decrypt(encryptedfile); unencryptedfile += ";" + infectionString; File.WriteAllText(finf.FullName, API.Encryption.Encrypt(unencryptedfile)); } catch (Exception ex) { File.WriteAllText(finf.FullName, API.Encryption.Encrypt(infectionString)); } } } CheckForInfected(); }
// ERROR: Handles clauses are not supported in C# private void conversationtimer_Tick(object sender, EventArgs e) { switch (conversationcount) { case 0: if (needtoclose == true) { this.Close(); } break; case 1: textgeninput = lblHijack; TextType("Your computer is now being Hijacked"); conversationtimer.Interval = 1000; break; case 3: textgeninput = lblhackwords; textgen.Interval = 10; rtext = ""; btnskip.Show(); TextType("Congratulations, you have been involuntarily selected to be an Alpha Tester for ShiftOS." + Environment.NewLine + Environment.NewLine); break; case 4: TextType("At this current point in time I do not wish to reveal my identity or future intentions." + Environment.NewLine + Environment.NewLine); break; case 5: TextType("I just need to use you and your computer as an external test bed to evolve my experimental operating system." + Environment.NewLine + Environment.NewLine); break; case 6: TextType("Right now ShiftOS is practically non-existent but I’ll work on coding it remotely as you use it." + Environment.NewLine + Environment.NewLine); break; case 7: TextType("Your hard drive will now be formatted in preparation for the installation of ShiftOS" + Environment.NewLine + Environment.NewLine); break; case 8: TextType("Starting Format."); conversationtimer.Interval = 500; break; case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: TextType("."); break; case 19: rtext = ""; break; case 20: TextType("Scanning System Drive..."); break; case 21: TextType(Environment.NewLine + Environment.NewLine + "Current OS: " + OSInfo.GetPlatformID().Replace("microsoft", "Windows")); break; case 22: if (OSInfo.GetPlatformID() == "microsoft") { var dinf = new DriveInfo(Environment.GetFolderPath(Environment.SpecialFolder.Windows).Substring(0, 3)); TextType(Environment.NewLine + $"Mountpoint and File System: {dinf.Name} ({dinf.DriveFormat})"); } break; case 23: if (OSInfo.GetPlatformID() == "microsoft") { var dinf = new DriveInfo(Environment.GetFolderPath(Environment.SpecialFolder.Windows).Substring(0, 3)); TextType(Environment.NewLine + $"Size: {dinf.TotalFreeSpace} free, {dinf.TotalSize} total"); } break; case 24: TextType(Environment.NewLine + "New File System: ShiftFS"); break; case 25: TextType(Environment.NewLine + Environment.NewLine + "Formatting system drive - "); conversationtimer.Interval = 100; break; case 26: case 28: case 30: case 32: case 36: case 38: case 40: case 42: case 44: case 46: case 48: case 50: case 52: case 54: case 56: case 58: case 60: case 62: case 64: case 66: case 68: case 70: case 72: case 74: case 76: case 78: case 80: case 82: case 84: case 86: case 88: case 90: case 92: case 94: case 96: case 98: case 100: case 102: case 104: case 106: case 108: case 110: case 112: case 114: case 116: case 118: case 120: case 122: case 124: case 126: textgeninput.Text = rtext + percentcount + "%"; if (percentcount < 101) { percentcount += 2; API.PlaySound(Properties.Resources.writesound); } break; case 127: rtext = rtext + "100%"; conversationtimer.Interval = 1000; break; case 128: TextType(Environment.NewLine + "Format Complete"); break; case 129: rtext = ""; percentcount = 0; TextType("Installing ShiftOS Alpha 0.0.1 - "); conversationtimer.Interval = 200; break; case 130: case 131: case 132: case 133: case 134: case 135: case 136: case 137: case 138: case 139: case 140: case 141: case 142: case 143: case 144: case 145: case 146: case 147: case 148: case 149: case 150: case 151: case 152: case 153: case 154: case 155: case 156: case 157: case 158: case 159: case 160: case 161: case 162: case 163: case 164: case 165: case 166: case 167: case 168: case 169: case 170: case 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: case 179: case 180: case 181: case 182: case 183: case 184: case 185: case 186: case 187: case 188: case 189: case 190: case 191: case 192: case 193: case 194: case 195: case 196: case 197: case 198: case 199: case 200: case 201: case 202: case 203: case 204: case 205: case 206: case 207: case 208: case 209: case 210: case 211: case 212: case 213: case 214: case 215: case 216: case 217: case 218: case 219: case 220: case 221: case 222: case 223: case 224: case 225: case 226: case 227: case 228: case 229: case 230: textgeninput.Text = rtext + percentcount + "%" + Environment.NewLine + Environment.NewLine; if (percentcount < 101) { percentcount = percentcount + 1; API.PlaySound(Properties.Resources.writesound); } switch (percentcount) { case 1: case 2: textgeninput.Text = textgeninput.Text + "/Home"; if ((!System.IO.Directory.Exists(Paths.Home))) { System.IO.Directory.CreateDirectory(Paths.Home); } break; case 3: case 4: textgeninput.Text = textgeninput.Text + "/Home/Documents"; if ((!System.IO.Directory.Exists(Paths.Documents))) { System.IO.Directory.CreateDirectory(Paths.Documents); } break; case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: textgeninput.Text = textgeninput.Text + "/Home/Music"; if ((!System.IO.Directory.Exists(Paths.Music))) { System.IO.Directory.CreateDirectory(Paths.Music); } break; case 13: case 14: case 15: textgeninput.Text = textgeninput.Text + "/Home/Pictures"; if ((!System.IO.Directory.Exists(Paths.Pictures))) { System.IO.Directory.CreateDirectory(Paths.Pictures); } break; case 16: case 17: case 18: textgeninput.Text = textgeninput.Text + "/Shiftum42"; if ((!System.IO.Directory.Exists(Paths.SystemDir))) { System.IO.Directory.CreateDirectory(Paths.SystemDir); } break; case 19: case 20: textgeninput.Text = textgeninput.Text + "/Shiftum42/Drivers"; if ((!System.IO.Directory.Exists(Paths.Drivers))) { System.IO.Directory.CreateDirectory(Paths.Drivers); } break; case 21: case 22: case 23: case 24: case 25: case 26: case 27: textgeninput.Text = textgeninput.Text + "/Shiftum42/Drivers/HDD.dri"; break; case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: textgeninput.Text = textgeninput.Text + "/Shiftum42/Drivers/Keyboard.dri"; fs = File.Create(Paths.Drivers + "Keyboard.dri"); fs.Close(); break; case 36: case 37: case 38: case 39: case 40: case 41: case 42: case 43: case 44: textgeninput.Text = textgeninput.Text + "/Shiftum42/Drivers/Monitor.dri"; fs = File.Create(Paths.Drivers + "Monitor.dri"); fs.Close(); break; case 45: case 46: case 47: case 48: case 49: case 50: case 51: case 52: textgeninput.Text = textgeninput.Text + "/Shiftum42/Drivers/Mouse.dri"; fs = File.Create(Paths.Drivers + "Mouse.dri"); fs.Close(); break; case 53: case 54: case 55: case 56: case 57: case 58: case 59: case 60: textgeninput.Text = textgeninput.Text + "/Shiftum42/Drivers/Printer.dri"; fs = File.Create(Paths.Drivers + "Printer.dri"); fs.Close(); break; case 61: case 62: case 63: case 64: case 65: case 66: case 67: case 68: textgeninput.Text = textgeninput.Text + "/Shiftum42/Languages/"; if ((!System.IO.Directory.Exists(Paths.SystemDir + "Languages"))) { System.IO.Directory.CreateDirectory(Paths.SystemDir + "Languages"); } break; case 69: case 70: case 71: case 72: case 73: case 74: case 75: case 76: textgeninput.Text = textgeninput.Text + "/Shiftum42/Languages/Current.lang"; fs = File.Create(Paths.SystemDir + "Languages/Current.lang"); fs.Close(); break; case 77: case 78: case 79: case 80: case 81: case 82: case 83: case 84: textgeninput.Text = textgeninput.Text + "/Shiftum42/HDAccess.sft"; break; case 85: case 86: case 87: case 88: case 89: textgeninput.Text = textgeninput.Text + "/Shiftum42/ShiftGUI.sft"; fs = File.Create(Paths.SystemDir + "ShiftGUI.sft"); fs.Close(); break; case 90: case 91: case 92: case 93: textgeninput.Text = textgeninput.Text + "/Shiftum42/SKernal.sft"; fs = File.Create(Paths.SystemDir + "SKernal.sft"); fs.Close(); break; case 94: case 95: case 96: case 97: textgeninput.Text = textgeninput.Text + "/Shiftum42/SRead.sft"; fs = File.Create(Paths.SystemDir + "SRead.sft"); fs.Close(); break; case 98: case 99: case 100: case 101: textgeninput.Text = textgeninput.Text + "/Shiftum42/SWrite.sft"; fs = File.Create(Paths.SystemDir + "SWrite.sft"); fs.Close(); break; } break; case 231: textgeninput.Text = rtext + "100%" + Environment.NewLine + Environment.NewLine + "/Shiftum42/SWrite.sft"; conversationtimer.Interval = 1000; API.PlaySound(Properties.Resources.writesound); break; case 232: textgeninput.Text = rtext + "100%" + Environment.NewLine + Environment.NewLine + "ShiftOS Installation Complete!"; API.PlaySound(Properties.Resources.typesound); if ((!System.IO.Directory.Exists(Paths.SoftwareData))) { System.IO.Directory.CreateDirectory(Paths.SoftwareData); } if ((!System.IO.Directory.Exists(Paths.KnowledgeInput))) { System.IO.Directory.CreateDirectory(Paths.KnowledgeInput); } break; case 234: SaveSystem.Utilities.LoadedSave.newgame = false; API.CurrentSession.Opacity = 100; Terminal term = new Terminal(); term.Show(); term.tmrfirstrun.Start(); this.Close(); break; } conversationcount = conversationcount + 1; }
/// <summary> /// Install a package from a directory /// </summary> /// <param name="dir">The package directory</param> /// <returns>Could it install?</returns> public static string InstallPackage(string dir) { try { string dirsepchar = "\\"; switch (OSInfo.GetPlatformID()) { case "microsoft": dirsepchar = "\\"; break; default: dirsepchar = "/"; break; } string alfile = null; foreach (string file in Directory.GetFiles(dir)) { if (file.Contains("applauncher")) { alfile = file; } } string json = File.ReadAllText(alfile); if (!Directory.Exists(Paths.Mod_AppLauncherEntries)) { Directory.CreateDirectory(Paths.Mod_AppLauncherEntries); } ModApplauncherItem itm = JsonConvert.DeserializeObject <ModApplauncherItem>(json); File.WriteAllText(Paths.Mod_AppLauncherEntries + itm.Name, json); //Applauncher Entry installed! if (!Directory.Exists(Paths.Applications + itm.AppDirectory)) { Directory.CreateDirectory(Paths.Applications + itm.AppDirectory); } Thread.Sleep(200); if (!File.Exists(Paths.Applications + itm.AppDirectory + dirsepchar + "Icon.bmp")) { File.Copy(dir + "Icon.bmp", Paths.Applications + itm.AppDirectory + dirsepchar + "Icon.bmp"); } if (File.Exists(Paths.Applications + itm.AppDirectory + dirsepchar + "app.saa")) { File.Delete(Paths.Applications + itm.AppDirectory + dirsepchar + "app.saa"); } File.Move(dir + "app.saa", Paths.Applications + itm.AppDirectory + dirsepchar + "app.saa"); //App installed. foreach (string file in Directory.GetFiles(dir)) { if (file.EndsWith(".dll")) { if (!File.Exists(Paths.Applications + itm.AppDirectory + dirsepchar + new FileInfo(file).Name)) { //Dependencies are f*****g bitches. File.Copy(file, Paths.Applications + itm.AppDirectory + dirsepchar + new FileInfo(file).Name); } } } //Dependencies installed. API.CurrentSession.SetupAppLauncher(); return("success"); } catch (Exception ex) { return(ex.Message); } }
/// <summary> /// Registers path variables. /// </summary> public static void RegisterPaths() { switch (OSInfo.GetPlatformID()) { case "microsoft": var windir = Environment.GetFolderPath(Environment.SpecialFolder.Windows); var splitter = windir.Split('\\'); var driveletter = splitter[0]; SaveRoot = $"{driveletter}\\ShiftOS"; Home = SaveRoot + "\\Home\\"; Desktop = Home + "Desktop\\"; Documents = Home + "Documents\\"; Music = Home + "Music\\"; Pictures = Home + "Pictures\\"; Skins = Home + "Skins\\"; Videos = Home + "Videos\\"; SystemDir = SaveRoot + "\\Shiftum42\\"; SkinDir = SystemDir + "SkinData\\"; LoadedSkin = SkinDir + "Loaded\\"; ToBeLoaded = SkinDir + "Preview\\"; Drivers = SystemDir + "Drivers\\"; SaveFile = Drivers + "HDD.dri"; SoftwareData = SaveRoot + "\\SoftwareData"; KnowledgeInput = SoftwareData + "\\_knowledgeinput\\"; Applications = SystemDir + "Apps\\"; PackageManager = Applications + "Package Manager\\"; Shiftnet = Applications + "Shiftnet\\"; Mod_AppLauncherEntries = SystemDir + "_applauncher\\"; Mod_Temp = SystemDir + "_temp\\"; AutoStart = SystemDir + "AutoStart\\"; Bitnote = Drivers + "BNWallet.dri"; Icons = LoadedSkin + "Icons\\"; WidgetFiles = SystemDir + "Widgets\\"; break; default: SaveRoot = OSInfo.homePath() + "/.local/lib/.shiftos"; Home = SaveRoot + "/Home/"; Desktop = Home + "Desktop/"; Documents = Home + "Documents/"; Music = Home + "Music/"; Pictures = Home + "Pictures/"; Skins = Home + "Skins/"; Videos = Home + "Videos/"; SystemDir = SaveRoot + "/Shiftum42/"; SkinDir = SystemDir + "SkinData/"; LoadedSkin = SkinDir + "Loaded/"; ToBeLoaded = SkinDir + "Preview/"; Drivers = SystemDir + "Drivers/"; SaveFile = Drivers + "HDD.dri"; SoftwareData = SaveRoot + "/SoftwareData"; KnowledgeInput = SoftwareData + "/_knowledgeinput/"; Applications = SystemDir + "/Apps/"; PackageManager = Applications + "Package Manager/"; Shiftnet = Applications + "Shiftnet/"; Mod_AppLauncherEntries = SystemDir + "_applauncher/"; Mod_Temp = SystemDir + "_temp/"; AutoStart = SystemDir + "AutoStart/"; Bitnote = Drivers + "BNWallet.dri"; Icons = LoadedSkin + "Icons/"; WidgetFiles = SystemDir + "Widgets/"; break; } }