public abstract void Install(DirectoryInfo systemDirectory, string systemName, SpecialSnowflake specialSnowflake, string filename, out MenuItemInfo menuItem, SystemProgressReporter progressReporter);
public override void Install(DirectoryInfo systemDirectory, string systemName, SpecialSnowflake specialSnowflake, string filename, out MenuItemInfo menuItem, SystemProgressReporter progressReporter) { progressReporter.ReportStatus(InstallationStatus.CopyFiles); var fileDirectory = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(filename), "kon-bootUSB", "USBFILES")); if (!fileDirectory.Exists) { throw new FileNotFoundException($"Could not find kon boot USB directory: \"{fileDirectory.FullName}\""); } File.Copy(Path.Combine(fileDirectory.FullName, "grldr"), Path.Combine(systemDirectory.FullName, "grldr")); progressReporter.ReportProgress(.4); File.Copy(Path.Combine(fileDirectory.FullName, "konboot.img"), Path.Combine(systemDirectory.FullName, "konboot.img")); progressReporter.ReportProgress(.8); File.Copy(Path.Combine(fileDirectory.FullName, "konbootOLD.img"), Path.Combine(systemDirectory.FullName, "konbootOLD.img")); progressReporter.ReportProgress(1); progressReporter.ReportStatus(InstallationStatus.WriteConfig); var pathWithoutDrive = RemoveDriveFromPath(systemDirectory.FullName).Replace("\\", "/"); var konbootVersionSelectionFile = $@"title Kon-Boot (CURRENT VERSION) map --mem {pathWithoutDrive}/konboot.img (fd0) map --hook chainloader (fd0)+1 map (hd1) (hd0) map --hook rootnoverify (fd0) title Kon-Boot v2.1 (OLD VERSION) map --mem {pathWithoutDrive}/konbootOLD.img (fd0) map --hook chainloader (fd0)+1 map (hd1) (hd0) map --hook rootnoverify (fd0)"; File.WriteAllText(Path.Combine(systemDirectory.FullName, "konboot.lst"), konbootVersionSelectionFile); menuItem = new MenuItemInfo($@"KERNEL /multiboot/grub.exe APPEND --config-file={pathWithoutDrive}/konboot.lst"); }
public override void Install(DirectoryInfo systemDirectory, string systemName, SpecialSnowflake specialSnowflake, string filename, out MenuItemInfo menuItem, SystemProgressReporter progressReporter) { FileInfo memtestFile = null; progressReporter.ReportStatus(InstallationStatus.ExtractFile); using (var fileStream = File.OpenRead(filename)) { var zipFile = new ZipFile(fileStream); foreach (ZipEntry zipEntry in zipFile) { if (zipEntry.Name.EndsWith(".bin", StringComparison.OrdinalIgnoreCase)) { memtestFile = new FileInfo(Path.Combine(systemDirectory.FullName, zipEntry.Name)); using (var zipStream = zipFile.GetInputStream(zipEntry)) using (var memetestFileStream = memtestFile.OpenWrite()) { var buffer = new byte[4096]; var totalRead = 0d; var length = zipEntry.Size; int read; while ((read = zipStream.Read(buffer, 0, buffer.Length)) > 0) { memetestFileStream.Write(buffer, 0, read); totalRead += read; progressReporter.ReportProgress(totalRead / length); } } break; } } } if (memtestFile == null) { throw new FileNotFoundException(); } var pathWithoutDrive = RemoveDriveFromPath(memtestFile.FullName).Replace('\\', '/'); menuItem = new MenuItemInfo($"LINUX {pathWithoutDrive}"); }
public override void Install(DirectoryInfo systemDirectory, string systemName, SpecialSnowflake specialSnowflake, string filename, out MenuItemInfo menuItem, SystemProgressReporter progressReporter) { progressReporter.ReportStatus(InstallationStatus.ExtractFile); using (var file = new SevenZipExtractor(filename)) { file.Extracting += (sender, args) => { progressReporter.ReportProgress(args.PercentDone / 100d); }; file.ExtractArchive(systemDirectory.FullName); } progressReporter.ReportStatus(InstallationStatus.WriteConfig); var configInfo = GetSystemBootInfo(systemDirectory.FullName); menuItem = new MenuItemInfo( $@"CONFIG /{Path.Combine("multiboot", systemDirectory.Name, configInfo.ConfigPath, configInfo.ConfigFile).Replace('\\', '/')} APPEND /multiboot/{systemDirectory.Name}/{configInfo.ConfigPath}"); //For Ubuntu Desktop and derivatives ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "isolinux\\txt.cfg"), new Dictionary <string, string> { { "file=/cdrom/preseed/", $"file=/cdrom/multiboot/{systemDirectory.Name}/preseed/" }, { "initrd=/casper/", $"cdrom-detect/try-usb=true noprompt floppy.allowed_drive_mask=0 ignore_uuid live-media-path=/multiboot/{systemDirectory.Name}/casper/ initrd=/multiboot/{systemDirectory.Name}/casper/" }, { "kernel /casper/", $"kernel /multiboot/{systemDirectory.Name}/casper/" } }); ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "isolinux\\text.cfg"), new Dictionary <string, string> { { "file=/cdrom/preseed/", $"file=/cdrom/multiboot/{systemDirectory.Name}/preseed/" }, { "initrd=/casper/", $"cdrom-detect/try-usb=true noprompt floppy.allowed_drive_mask=0 ignore_uuid live-media-path=/multiboot/{systemDirectory.Name}/casper/ initrd=/multiboot/{systemDirectory.Name}/casper/" }, { "kernel /casper/", $"kernel /multiboot/{systemDirectory.Name}/casper/" } }); ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "isolinux\\isolinux.cfg"), new Dictionary <string, string> { { "file=/cdrom/preseed/", $"file=/cdrom/multiboot/{systemDirectory.Name}/preseed/" }, { "initrd=/casper/", $"cdrom-detect/try-usb=true noprompt floppy.allowed_drive_mask=0 ignore_uuid live-media-path=/multiboot/{systemDirectory.Name}/casper/ initrd=/multiboot/{systemDirectory.Name}/casper/" }, { "kernel /casper/", $"kernel /multiboot/{systemDirectory.Name}/casper/" } }); //Alt For derivatives like Dr.Web Livedisk ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "syslinux\\txt.cfg"), new Dictionary <string, string> { { "file=/cdrom/preseed/", $"file=/cdrom/multiboot/{systemDirectory.Name}/preseed/" }, { "initrd=/casper/", $"cdrom-detect/try-usb=true noprompt floppy.allowed_drive_mask=0 ignore_uuid live-media-path=/multiboot/{systemDirectory.Name}/casper/ initrd=/multiboot/{systemDirectory.Name}/casper/" }, { "kernel /casper/", $"kernel /multiboot/{systemDirectory.Name}/casper/" } }); ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "syslinux\\text.cfg"), new Dictionary <string, string> { { "file=/cdrom/preseed/", $"file=/cdrom/multiboot/{systemDirectory.Name}/preseed/" }, { "initrd=/casper/", $"cdrom-detect/try-usb=true noprompt floppy.allowed_drive_mask=0 ignore_uuid live-media-path=/multiboot/{systemDirectory.Name}/casper/ initrd=/multiboot/{systemDirectory.Name}/casper/" }, { "kernel /casper/", $"kernel /multiboot/{systemDirectory.Name}/casper/" } }); ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "syslinux\\syslinux.cfg"), new Dictionary <string, string> { { "file=/cdrom/preseed/", $"file=/cdrom/multiboot/{systemDirectory.Name}/preseed/" }, { "initrd=/casper/", $"cdrom-detect/try-usb=true noprompt floppy.allowed_drive_mask=0 ignore_uuid live-media-path=/multiboot/{systemDirectory.Name}/casper/ initrd=/multiboot/{systemDirectory.Name}/casper/" }, { "kernel /casper/", $"kernel /multiboot/{systemDirectory.Name}/casper/" } }); //Rename the following for grub loopback.cfg ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "boot\\grub\\loopback.cfg"), new Dictionary <string, string> { { "file=/cdrom/preseed/", $"file=/cdrom/multiboot/{systemDirectory.Name}/preseed/" }, { "/casper/vmlinuz", $"/multiboot/{systemDirectory.Name}/casper/vmlinuz" }, { "/casper/initrd", $"/multiboot/{systemDirectory.Name}/casper/initrd" }, { "boot=casper", $"cdrom-detect/try-usb=true noprompt floppy.allowed_drive_mask=0 ignore_uuid boot=NULL live-media-path=/multiboot/{systemDirectory.Name}/casper/" }, { "boot=NULL", "boot=casper" }, }); //Rename the following for grub.cfg ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "boot\\grub\\grub.cfg"), new Dictionary <string, string> { { "file=/cdrom/preseed/", $"file=/cdrom/multiboot/{systemDirectory.Name}/preseed/" }, { "/casper/vmlinuz", $"/multiboot/{systemDirectory.Name}/casper/vmlinuz" }, { "/casper/initrd", $"/multiboot/{systemDirectory.Name}/casper/initrd" }, { "boot=casper", $"cdrom-detect/try-usb=true noprompt floppy.allowed_drive_mask=0 ignore_uuid boot=NULL live-media-path=/multiboot/{systemDirectory.Name}/casper/" }, { "boot=NULL", "boot=casper" }, }); //For Debian Based and derivatives ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "isolinux", "live.cfg"), new Dictionary <string, string> { { "linux /live/", $"linux /multiboot/{systemDirectory.Name}/live/" }, { "initrd /live/", $"initrd /multiboot/{systemDirectory.Name}/live/" }, { "append boot=live", $"append live-media-path=/multiboot/{systemDirectory.Name}/live/ cdrom-detect/try-usb=true noprompt boot=live" } }); ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "isolinux", "install.cfg"), new Dictionary <string, string> { { "linux /install/", $"linux /multiboot/{systemDirectory.Name}/install/" }, { "initrd /install/", $"initrd /multiboot/{systemDirectory.Name}/install/" }, { "-- quiet", "cdrom-detect/try-usb=true quiet" } }); //SolydX ReplaceStringInFile(Path.Combine(systemDirectory.FullName, configInfo.ConfigPath, configInfo.ConfigFile), new Dictionary <string, string> { { "kernel /solydxk", $"kernel /multiboot/{systemDirectory.Name}/solydxk" }, { "initrd=/solydxk", $"initrd=/multiboot/{systemDirectory.Name}/solydxk" }, { "live-media-path=/solydxk", $"live-media-path=/multiboot/{systemDirectory.Name}/solydxk" }, }); //For Desinfect Distro ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "isolinux\\os.cfg"), new Dictionary <string, string> { { "file=/cdrom/preseed/", $"file=/cdrom/multiboot/{systemDirectory.Name}/preseed/" }, { "initrd=/casper/", $"cdrom-detect/try-usb=true noprompt floppy.allowed_drive_mask=0 ignore_uuid live-media-path=/multiboot/{systemDirectory.Name}/casper/ initrd=/multiboot/{systemDirectory.Name}/casper/" }, { "kernel /casper/", $"kernel /multiboot/{systemDirectory.Name}/casper/" }, { "BOOT_IMAGE=/casper/", $"BOOT_IMAGE=/multiboot/{systemDirectory.Name}/casper/" }, }); //For Fedora Based and derivatives if (File.Exists(Path.Combine(systemDirectory.FullName, "isolinux\\isolinux.cfg")) && File.Exists(Path.Combine(systemDirectory.FullName, "LiveOS\\livecd-iso-to-disk"))) //Probably Fedora based { File.WriteAllText(Path.Combine(systemDirectory.FullName, "isolinux\\isolinux.cfg"), File.ReadAllText( Path.Combine(systemDirectory.FullName, "isolinux\\isolinux.cfg") .Replace("root=live:CDLABEL=", $"root=live:LABEL=MULTIBOOT live_dir=/multiboot/{systemDirectory.Name}/LiveOS NULL="))); } //For Puppy Based and derivatives if (File.Exists(Path.Combine(systemDirectory.FullName, "isolinux.cfg"))) { if (File.Exists(Path.Combine(systemDirectory.FullName, "help2.msg"))) //Probably Puppy based { ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "isolinux.cfg"), new Dictionary <string, string> { { "pmedia=cd", $"psubdir=/multiboot/{systemDirectory.Name} psubok=TRUE" }, }); } else if (File.Exists(Path.Combine(systemDirectory.FullName, "help.msg"))) //Probably Puppy based { ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "isolinux.cfg"), new Dictionary <string, string> { { "append search", $"append search psubdir=/multiboot/{systemDirectory.Name} psubok=TRUE" }, }); } } //For Clonezilla, and DRBL ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "syslinux\\syslinux.cfg"), new Dictionary <string, string> { { "kernel /live", $"kernel /multiboot/{systemDirectory.Name}/live" }, { "initrd=/live", $"live-media-path=/multiboot/{systemDirectory.Name}/live/ initrd=/multiboot/{systemDirectory.Name}/live" } }); ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "isolinux\\isolinux.cfg"), new Dictionary <string, string> { { "kernel /live", $"kernel /multiboot/{systemDirectory.Name}/live" }, { "initrd=/live", $"live-media-path=/multiboot/{systemDirectory.Name}/live/ initrd=/multiboot/{systemDirectory.Name}/live" }, { "live-media-path=/live", $"live-media-path=/multiboot/{systemDirectory.Name}/live" } //Linux Mint 2014 }); //Xpud if (File.Exists(Path.Combine(systemDirectory.FullName, "boot\\vesamenu.c32")) && File.Exists(Path.Combine(systemDirectory.FullName, "opt\\media"))) { ReplaceStringInFile(Path.Combine(systemDirectory.FullName, configInfo.ConfigPath, configInfo.ConfigFile), new Dictionary <string, string> { { "KERNEL /boot/", $"KERNEL /multiboot/{systemDirectory.Name}/boot/" }, { "/opt/media,/opt/scim", $"/multiboot/{systemDirectory.Name}/opt/media,/multiboot/{systemDirectory.Name}/opt/scim" }, { "DEFAULT /boot/", $"DEFAULT /multiboot/{systemDirectory.Name}/boot/" }, { "MENU BACKGROUND /boot/", $"MENU BACKGROUND /multiboot/{systemDirectory.Name}/boot/" }, { "APPEND initrd=/opt/media", $"APPEND initrd=/multiboot/{systemDirectory.Name}/opt/media" }, }); } //Panda Safe CD, Tails ReplaceStringInFile(Path.Combine(systemDirectory.FullName, Path.Combine(configInfo.ConfigPath.Replace('/', '\\'), "live.cfg")), new Dictionary <string, string> { { "kernel /live", $"kernel /multiboot/{systemDirectory.Name}/live" }, { "initrd=/live", $"initrd=/multiboot/{systemDirectory.Name}/live" }, { "append initrd=", $"append noprompt live-media-path=/multiboot/{systemDirectory.Name}/live initrd=" } }); ReplaceStringInFile(Path.Combine(systemDirectory.FullName, Path.Combine(configInfo.ConfigPath.Replace('/', '\\'), "live486.cfg")), //Tails Specific 486 new Dictionary <string, string> { { "kernel /live", $"kernel /multiboot/{systemDirectory.Name}/live" }, { "initrd=/live", $"initrd=/multiboot/{systemDirectory.Name}/live" }, { "append initrd=", $"append noprompt live-media-path=/multiboot/{systemDirectory.Name}/live initrd=" } }); ReplaceStringInFile(Path.Combine(systemDirectory.FullName, Path.Combine(configInfo.ConfigPath.Replace('/', '\\'), "live686.cfg")), //Tails Specific new Dictionary <string, string> { { "kernel /live", $"kernel /multiboot/{systemDirectory.Name}/live" }, { "initrd=/live", $"initrd=/multiboot/{systemDirectory.Name}/live" }, { "append initrd=", $"append noprompt live-media-path=/multiboot/{systemDirectory.Name}/live initrd=" } }); ReplaceStringInFile(Path.Combine(systemDirectory.FullName, Path.Combine(configInfo.ConfigPath.Replace('/', '\\'), configInfo.ConfigFile)), new Dictionary <string, string> { { "default /isolinux/vesamenu.c32", $"default /multiboot/{systemDirectory.Name}/isolinux/vesamenu.c32" } }); ReplaceStringInFile(Path.Combine(systemDirectory.FullName, Path.Combine(configInfo.ConfigPath.Replace('/', '\\'), "stdmenu.cfg")), new Dictionary <string, string> { { "menu background /isolinux", $"menu background /multiboot/{systemDirectory.Name}/isolinux" }, }); ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "isolinux\\liveamd64.cfg"), //Tails Specific new Dictionary <string, string> { { "kernel /live", $"kernel /multiboot/{systemDirectory.Name}/live" }, { "initrd=/live", $"initrd=/multiboot/{systemDirectory.Name}/live" }, { "append initrd=", $"append noprompt live-media-path=/multiboot/{systemDirectory.Name}/live initrd=" } }); switch (specialSnowflake) { case SpecialSnowflake.SystemRescueDisk: ReplaceStringInFile(Path.Combine(systemDirectory.FullName, configInfo.ConfigPath, configInfo.ConfigFile), new Dictionary <string, string> { { "INITRD initram.igz", $"INITRD NULL initram.igz\r\nAPPEND subdir=multiboot/{systemDirectory.Name}" }, { "INITRD NULL initram.igz", "INITRD initram.igz" }, { "APPEND docache", $"APPEND subdir=multiboot/{systemDirectory.Name} docache" }, { "APPEND nomodeset", $"APPEND subdir=multiboot/{systemDirectory.Name} nomodeset" }, { "APPEND video=800x600", $"APPEND subdir=multiboot/{systemDirectory.Name} video=800x600" }, { "APPEND root=auto", $"APPEND subdir=multiboot/{systemDirectory.Name} root=auto" }, { "APPEND dostartx", $"APPEND subdir=multiboot/{systemDirectory.Name} dostartx" }, { "kernel /bootdisk", $"kernel /multiboot/{systemDirectory.Name}/bootdisk" }, { "kernel /ntpasswd", $"kernel /multiboot/{systemDirectory.Name}/ntpasswd" }, { "/ntpasswd/initrd.cgz,/ntpasswd/scsi.cgz", $"/multiboot/{systemDirectory.Name}/ntpasswd/initrd.cgz,/multiboot/{systemDirectory.Name}/ntpasswd/scsi.cgz" }, { "initrd=/bootdisk", $"initrd=/multiboot/{systemDirectory.Name}/bootdisk" }, }); break; case SpecialSnowflake.IsoLinuxPrompt0: var isoLinuxFile = new FileInfo(Path.Combine(systemDirectory.FullName, "isolinux.cfg")); if (!isoLinuxFile.Exists) { break; //not important enough to crash, it's just a comfort solution to prevent that boot shit } var content = File.ReadAllText(isoLinuxFile.FullName); File.WriteAllText(isoLinuxFile.FullName, content.Replace("PROMPT 1", "PROMPT 0", StringComparison.OrdinalIgnoreCase)); break; case SpecialSnowflake.UbuntuStudio: ReplaceStringInFile(Path.Combine(systemDirectory.FullName, "isolinux", "isolinux.cfg"), new Dictionary <string, string> { { "ui gfxboot bootlogo", "#ui gfxboot bootlogo" } }); break; } }
public override void Install(DirectoryInfo systemDirectory, string systemName, SpecialSnowflake specialSnowflake, string filename, out MenuItemInfo menuItem, SystemProgressReporter progressReporter) { progressReporter.ReportStatus(InstallationStatus.ExtractFile); using (var file = new SevenZipExtractor(filename)) { file.Extracting += (sender, args) => { progressReporter.ReportProgress(args.PercentDone / 100d); }; file.ExtractArchive(systemDirectory.FullName); } menuItem = new MenuItemInfo($@"MENU BEGIN Kaspersky Rescue Disk LABEL LIVE MENU LABEL ^Run Kaspersky Rescue Disk from this USB kernel /multiboot/{systemDirectory.Name}/boot/rescue append root=live:LABEL={App.DriveLabel} live_dir=/multiboot/{systemDirectory.Name}/rescue/LiveOS/ subdir=/multiboot/{systemDirectory.Name}/rescue/LiveOS/ rootfstype=auto vga=791 init=/linuxrc loop=/multiboot/{systemDirectory.Name}/rescue/LiveOS/squashfs.img initrd=/multiboot/{systemDirectory.Name}/boot/rescue.igz kav_rescue_10_lang=en udev liveimg splash quiet doscsi nomodeset label text menu label ^Run Kaspersky Rescue Disk - Text Mode kernel /multiboot/{systemDirectory.Name}/boot/rescue append root=live:LABEL={App.DriveLabel} live_dir=/multiboot/{systemDirectory.Name}/rescue/LiveOS/ subdir=/multiboot/{systemDirectory.Name}/rescue/LiveOS/ rootfstype=auto vga=791 init=/linuxrc loop=/multiboot/{systemDirectory.Name}/rescue/LiveOS/squashfs.img initrd=/multiboot/{systemDirectory.Name}/boot/rescue.igz kav_rescue_10_lang=en udev liveimg quiet nox kav_rescue_10shell noresume doscsi nomodeset label hwinfo menu label ^Run Hardware Info kernel /multiboot/{systemDirectory.Name}/boot/rescue append root=live:LABEL={App.DriveLabel} live_dir=/multiboot/{systemDirectory.Name}/rescue/LiveOS/ subdir=/multiboot/{systemDirectory.Name}/rescue/LiveOS/ rootfstype=auto vga=791 init=/linuxrc loop=/multiboot/{systemDirectory.Name}/rescue/LiveOS/squashfs.img initrd=/multiboot/{systemDirectory.Name}/boot/rescue.igz kav_rescue_10_lang=en udev liveimg quiet softlevel=boot nox hwinfo noresume doscsi nomodeset MENU SEPARATOR LABEL exit_kaspersky MENU LABEL Return to Antivirus Tools MENU EXIT MENU END", true); }