diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..eba1110 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4d13c54 --- /dev/null +++ b/.gitignore @@ -0,0 +1,334 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..7118023 --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +


deploya Logo

+ +

deploya

+

+ Configure Windows automatically +
+ Version: 12.0 +
+
+ No downloads available +
+
+ Report Bug + · + Discussions +

+

+ +![-----------------------------------------------------](https://dl.exploitox.de/t440p-oc/rainbow.png) + +## 🔔 Information +deploya is a little application for deploying Windows on a machine. + +- Deploy WIM-FIles on any drive. +- Auto initialize with AutoInit plugin + AutoDeploya +- Install applications like Firefox, Adobe Reader and Remote Management Control with winget. +- Capture Windows installation +- Install Windows from the Cloud + +⚠ **This tool is designed to use in a internal environment. If you want to use this tool as a "template" or just for testing, you will need to compile it for yourself.** + +## ℹ️ Disclaimer +> This application will modify the system. I won't be responsible for any damage you've done yourself trying to use this application. + +## ⚙️ Compiling the source code +For compiling, you'll need ```Visual Studio 2022``` and ```.NET 6.0```. +Clone this source and restore the NUGET Packages. + +## 🧾 License +deploya is licensed under [GNU GENERAL PUBLIC LICENSE](https://github.com/valnoxy/deploya/blob/main/LICENSE). So you are allowed to use freely and modify the application. I will not be responsible for any outcome. Proceed with any action at your own risk. + +```Copyright (c) 2018 - 2022 valnoxy. By Jonas G. ``` diff --git a/deploya-core/deploya-core.sln b/deploya-core/deploya-core.sln new file mode 100644 index 0000000..2144bcc --- /dev/null +++ b/deploya-core/deploya-core.sln @@ -0,0 +1,41 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32014.148 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "deploya-core", "deploya-core\deploya-core.csproj", "{1426C8F0-619B-44BA-8A0E-1ABFC1C6E50F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "deploya", "deploya\deploya.csproj", "{67E38F1B-7162-40AA-84A2-55131CDB631B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1426C8F0-619B-44BA-8A0E-1ABFC1C6E50F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1426C8F0-619B-44BA-8A0E-1ABFC1C6E50F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1426C8F0-619B-44BA-8A0E-1ABFC1C6E50F}.Debug|x64.ActiveCfg = Debug|x64 + {1426C8F0-619B-44BA-8A0E-1ABFC1C6E50F}.Debug|x64.Build.0 = Debug|x64 + {1426C8F0-619B-44BA-8A0E-1ABFC1C6E50F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1426C8F0-619B-44BA-8A0E-1ABFC1C6E50F}.Release|Any CPU.Build.0 = Release|Any CPU + {1426C8F0-619B-44BA-8A0E-1ABFC1C6E50F}.Release|x64.ActiveCfg = Release|x64 + {1426C8F0-619B-44BA-8A0E-1ABFC1C6E50F}.Release|x64.Build.0 = Release|x64 + {67E38F1B-7162-40AA-84A2-55131CDB631B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {67E38F1B-7162-40AA-84A2-55131CDB631B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {67E38F1B-7162-40AA-84A2-55131CDB631B}.Debug|x64.ActiveCfg = Debug|x64 + {67E38F1B-7162-40AA-84A2-55131CDB631B}.Debug|x64.Build.0 = Debug|x64 + {67E38F1B-7162-40AA-84A2-55131CDB631B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {67E38F1B-7162-40AA-84A2-55131CDB631B}.Release|Any CPU.Build.0 = Release|Any CPU + {67E38F1B-7162-40AA-84A2-55131CDB631B}.Release|x64.ActiveCfg = Release|x64 + {67E38F1B-7162-40AA-84A2-55131CDB631B}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4A0B5FB9-31AB-4973-AFC5-12CF9572E46C} + EndGlobalSection +EndGlobal diff --git a/deploya-core/deploya-core/ConsoleUtility.cs b/deploya-core/deploya-core/ConsoleUtility.cs new file mode 100644 index 0000000..3d2cd58 --- /dev/null +++ b/deploya-core/deploya-core/ConsoleUtility.cs @@ -0,0 +1,34 @@ +using System; + +namespace deploya_core +{ + static class ConsoleUtility + { + private const char _block = '■'; + private const string _back = "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"; + private const string _twirl = "-\\|/"; + + public static void WriteProgressBar(int percent, bool update = false) + { + if (update) + Console.Write("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); + Console.Write("["); + int num = (int)(percent / 10.0 + 0.5); + for (int index = 0; index < 10; ++index) + { + if (index >= num) + Console.Write(' '); + else + Console.Write('■'); + } + Console.Write("] {0,3:##0}%", percent); + } + + public static void WriteProgress(int progress, bool update = false) + { + if (update) + Console.Write("\b"); + Console.Write("-\\|/"[progress % "-\\|/".Length]); + } + } +} diff --git a/deploya-core/deploya-core/Program.cs b/deploya-core/deploya-core/Program.cs new file mode 100644 index 0000000..ba2e247 --- /dev/null +++ b/deploya-core/deploya-core/Program.cs @@ -0,0 +1,388 @@ +/* + * deploya - Fast and Easy way to deploy Windows + * Copyright (c) 2018 - 2022 Exploitox. + * + * deploya is licensed under MIT License (https://github.com/valnoxy/deploya/blob/main/LICENSE). + * So you are allowed to use freely and modify the application. + * I will not be responsible for any outcome. + * Proceed with any action at your own risk. + * + * Source code: https://github.com/valnoxy/deploya + */ + +using CommandLine; +using CommandLine.Text; +using Microsoft.Wim; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; + +namespace deploya_core +{ + internal class Program + { + public static string ver = "12.0.0"; + public static string build = "401"; + public static string codename = "deploya Core"; + public static string copyright = "Copyright (c) 2018 - 2022 Exploitox. All rights reserved."; + public static bool uimode = false; + + #region Parser options + class Options + { + [Option('w', "wim", Required = true, HelpText = "Input WIM-file to be processed.")] + public string wimfile { get; set; } + + + [Option(Default = false, Hidden = true, HelpText = "Used for deploya UI - Network Installation")] + public bool uimode { get; set; } + + + [Option('i', "index", Required = true, HelpText = "Index ID of the selected Windows-Installation.")] + public int index { get; set; } + + + [Option('e', "efi", Default = false, HelpText = "Use EFI for installation.")] + public bool efi { get; set; } + + + [Option('d', "driveid", Required = true, HelpText = "Hard Drive ID of the destination hard drive.")] + public int driveid { get; set; } + + + [Option('l', "legacy", Default = false, HelpText = "Use legacy bootloader for XP and below.")] + public bool legacy { get; set; } + + /* + [Usage(ApplicationAlias = "deployaCLI")] + public static IEnumerable Examples + { + get + { + return new List() { + new Example("Apply WIM file on a EFI system", new Options { driveid = 0, wimfile = "file.wim", index = 1, efi = true, legacy = false }) + }; + } + } + */ + } + + static void DisplayHelp(ParserResult result, IEnumerable errs) + { + var helpText = HelpText.AutoBuild(result, h => + { + h.AdditionalNewLineAfterOption = false; // Remove the extra newline between options + h.Heading = Program.codename + " [Version: " + Program.ver + "." + Program.build + "]"; // Change header + h.Copyright = Program.copyright; // Change copyright text + return HelpText.DefaultParsingErrorsHandler(result, h); + }, e => e); + Console.WriteLine(helpText); + } + #endregion + + static void Main(string[] args) + { + var parser = new CommandLine.Parser(with => with.HelpWriter = null); + var parserResult = parser.ParseArguments(args); + parserResult + .WithParsed(options => Run(options)) + .WithNotParsed(errs => DisplayHelp(parserResult, errs)); + } + + private static void Run(Options options) + { + string image = options.wimfile.ToString(); + string Index = options.index.ToString(); + string diskId = options.driveid.ToString(); + uimode = options.uimode; + + if (diskId.Contains("\\\\.\\PHYSICALDRIVE")) + diskId = new string(Enumerable.ToArray(Enumerable.Where((IEnumerable)diskId, new Func(char.IsDigit)))); + + // ----------------------------- + #region Check options + + #region WIM-File + Console.ForegroundColor = ConsoleColor.Magenta; + if (!File.Exists(image)) + { + Console.WriteLine("[i] Image not exist."); + Console.ForegroundColor = (ConsoleColor)15; + Environment.Exit(1); + } + Console.WriteLine("[i] Image = " + image); + #endregion + + #region Target + if (Program.GetDiskIndex(diskId) > 0U) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("[!] Target not exist. ID: " + Program.GetDiskIndex(diskId).ToString()); + Console.ResetColor(); + Environment.Exit(1); + } + Console.WriteLine("[i] Target = disk" + diskId); + #endregion + + #region BIOS type & Bootloader + + if (options.efi && options.legacy) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("[!] You cannot use EFI with a legacy bootloader. Aborting ..."); + Console.ResetColor(); + Environment.Exit(1); + } + + if (options.efi) + { + Console.WriteLine("[i] Firmware = EFI"); + Console.WriteLine("[i] Legacy = false"); + } + else if (options.legacy) + { + Console.WriteLine("[i] Firmware = BIOS"); + Console.WriteLine("[i] Legacy = true"); + } + else + { + Console.WriteLine("[i] Firmware = BIOS"); + Console.WriteLine("[i] Legacy = false"); + } + + #endregion + + #endregion + // ----------------------------- + + #region Partitioning destination + Process partDest = new Process(); + partDest.StartInfo.FileName = "diskpart.exe"; + partDest.StartInfo.UseShellExecute = false; + partDest.StartInfo.CreateNoWindow = true; + partDest.StartInfo.RedirectStandardInput = true; + partDest.StartInfo.RedirectStandardOutput = true; + partDest.Start(); + if (!options.efi) + { + if (options.legacy) + { + partDest.StandardInput.WriteLine("select disk " + diskId); + partDest.StandardInput.WriteLine("clean"); + partDest.StandardInput.WriteLine("create partition primary"); + partDest.StandardInput.WriteLine("format quick fs=ntfs label=Windows"); + partDest.StandardInput.WriteLine("active"); + partDest.StandardInput.WriteLine("assign letter=W"); + partDest.StandardInput.WriteLine("exit"); + partDest.WaitForExit(); + if (!Program.uimode) + ConsoleUtility.WriteProgressBar(100, true); + } + if (!options.legacy) + { + partDest.StandardInput.WriteLine("select disk " + diskId); + partDest.StandardInput.WriteLine("clean"); + partDest.StandardInput.WriteLine("create partition primary size=100"); + partDest.StandardInput.WriteLine("format quick fs=ntfs label=System"); + partDest.StandardInput.WriteLine("assign letter=S"); + partDest.StandardInput.WriteLine("active"); + partDest.StandardInput.WriteLine("create partition primary"); + partDest.StandardInput.WriteLine("shrink minimum=650"); + partDest.StandardInput.WriteLine("format quick fs=ntfs label=Windows"); + partDest.StandardInput.WriteLine("assign letter=W"); + partDest.StandardInput.WriteLine("create partition primary"); + partDest.StandardInput.WriteLine("format quick fs=ntfs label=Recovery"); + partDest.StandardInput.WriteLine("assign letter=R"); + partDest.StandardInput.WriteLine("set id=27"); + partDest.StandardInput.WriteLine("exit"); + partDest.WaitForExit(); + if (!Program.uimode) + ConsoleUtility.WriteProgressBar(100, true); + } + } + if (options.efi) + { + partDest.StandardInput.WriteLine("select disk " + diskId); + partDest.StandardInput.WriteLine("clean"); + partDest.StandardInput.WriteLine("convert gpt"); + partDest.StandardInput.WriteLine("create partition efi size=100"); + partDest.StandardInput.WriteLine("format quick fs=fat32 label=System"); + partDest.StandardInput.WriteLine("assign letter=S"); + partDest.StandardInput.WriteLine("create partition msr size=16"); + partDest.StandardInput.WriteLine("create partition primary"); + partDest.StandardInput.WriteLine("shrink minimum=650"); + partDest.StandardInput.WriteLine("format quick fs=ntfs label=Windows"); + partDest.StandardInput.WriteLine("assign letter=W"); + partDest.StandardInput.WriteLine("create partition primary"); + partDest.StandardInput.WriteLine("format quick fs=ntfs label=Recovery"); + partDest.StandardInput.WriteLine("assign letter=R"); + partDest.StandardInput.WriteLine("set id=de94bba4-06d1-4d40-a16a-bfd50179d6ac"); + partDest.StandardInput.WriteLine("gpt attributes=0x8000000000000001"); + partDest.StandardInput.WriteLine("exit"); + partDest.WaitForExit(); + if (!Program.uimode) + ConsoleUtility.WriteProgressBar(100, true); + } + + if (partDest.ExitCode != 0) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(""); + Console.WriteLine(" An Error has occurred."); + Console.WriteLine(" Error: " + partDest.ExitCode.ToString()); + if (!Program.uimode) + Console.WriteLine(); // Only write new line if ui mode is disabled, so that the ui can read the error code above. + Console.ResetColor(); + return; + } + #endregion + + #region Apply WIM file & Bootloader + Program.applyWim(image, Index, "W:\\"); + + if (!Program.uimode) + { + Console.Write("[*] Installing Bootloader ... "); + ConsoleUtility.WriteProgressBar(0); + } + if (Program.uimode) { Console.WriteLine("[A] Installing Bootloader ..."); } + + Process bootld = new Process(); + bootld.StartInfo.FileName = "cmd.exe"; + + #region Legacy check + if (options.legacy) + { + if (diskId.EndsWith("\\")) + { + diskId = diskId.Remove(diskId.Length - 1); + bootld.StartInfo.Arguments = "/c \"bootsect /nt52 " + diskId + " /force /mbr\""; + } + else + { + bootld.StartInfo.Arguments = "/c \"bootsect.exe /nt52 " + diskId + " /force /mbr > nul\""; + } + } + #endregion + + #region BIOS / EFI check + if (!options.legacy) + { + if (!options.efi) // BIOS + bootld.StartInfo.Arguments = "/c \"bcdboot.exe W:\\Windows /s S: /f BIOS >NUL\""; + + if (options.efi) // EFI + bootld.StartInfo.Arguments = "/c \"bcdboot.exe W:\\Windows /s S: /f UEFI >NUL\""; + } + #endregion + + bootld.Start(); + bootld.WaitForExit(); + + if (bootld.ExitCode != 0) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(""); + Console.WriteLine(" An Error has occurred."); + Console.WriteLine(" Error: " + bootld.ExitCode.ToString()); + if (!Program.uimode) + Console.WriteLine(); // Only write new line if ui mode is disabled, so that the ui can read the error code above. + Console.ResetColor(); + Environment.Exit(bootld.ExitCode); + } + + if (!Program.uimode) + { + ConsoleUtility.WriteProgressBar(100, true); + Console.WriteLine(""); + } + + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("[*] Installation completed."); + Console.ResetColor(); + Environment.Exit(0); + #endregion + } + + #region Modules + + #region Get Disk index + public static int GetDiskIndex(string diskId) + { + string tempPath = Path.GetTempPath(); + File.WriteAllText(tempPath + "getdiskindex.cmd", "@wmic diskdrive get index | more +1"); + Process process = new Process(); + process.StartInfo.UseShellExecute = false; + process.StartInfo.RedirectStandardOutput = true; + process.StartInfo.FileName = tempPath + "getdiskindex.cmd"; + process.Start(); + string end = process.StandardOutput.ReadToEnd(); + process.WaitForExit(); + + try { File.Delete(Path.Combine(tempPath, "getdiskindex.cmd")); } catch { } + return end.Contains(diskId) ? 0 : -1; + } + #endregion + + #region Apply Wim file + private static void applyWim(string ImagePath, string Index, string Drive) + { + Environment.GetCommandLineArgs(); + if (!Program.uimode) + { + Console.Write("[*] Applying Image ... "); + ConsoleUtility.WriteProgressBar(0); + } + if (Program.uimode) { Console.WriteLine("[A] Applying Image ..."); } + + string path = Drive; + using (WimHandle file = WimgApi.CreateFile(ImagePath, WimFileAccess.Read, WimCreationDisposition.OpenExisting, WimCreateFileOptions.None, WimCompressionType.None)) + { + WimgApi.SetTemporaryPath(file, Environment.GetEnvironmentVariable("TEMP")); + WimgApi.RegisterMessageCallback(file, new WimMessageCallback(Program.MyCallbackMethod)); + try + { + using (WimHandle imageHandle = WimgApi.LoadImage(file, Convert.ToInt32(Index))) + WimgApi.ApplyImage(imageHandle, path, WimApplyImageOptions.None); + } + finally + { + WimgApi.UnregisterMessageCallback(file, new WimMessageCallback(Program.MyCallbackMethod)); + } + } + } + #endregion + + #region WimCallbackMessage + private static WimMessageResult MyCallbackMethod(WimMessageType messageType, object message, object userData) + { + switch (messageType) + { + case WimMessageType.Progress: + WimMessageProgress wimMessageProgress = (WimMessageProgress)message; + if (!Program.uimode) + ConsoleUtility.WriteProgressBar(wimMessageProgress.PercentComplete, true); + if (Program.uimode) + { + Console.WriteLine(wimMessageProgress.PercentComplete); + break; + } + break; + case WimMessageType.Error: + WimMessageError wimMessageError = (WimMessageError)message; + Console.WriteLine($"Error: {0} ({1})", (object)wimMessageError.Path, (object)wimMessageError.Win32ErrorCode); + break; + case WimMessageType.Warning: + WimMessageWarning wimMessageWarning = (WimMessageWarning)message; + Console.WriteLine($"Warning: {0} ({1})", (object)wimMessageWarning.Path, (object)wimMessageWarning.Win32ErrorCode); + break; + } + return WimMessageResult.Success; + } + #endregion + + #endregion + } +} diff --git a/deploya-core/deploya-core/app.manifest b/deploya-core/deploya-core/app.manifest new file mode 100644 index 0000000..4d5c3f9 --- /dev/null +++ b/deploya-core/deploya-core/app.manifest @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/deploya-core/deploya-core/deploya-core - Backup.csproj b/deploya-core/deploya-core/deploya-core - Backup.csproj new file mode 100644 index 0000000..cf90172 --- /dev/null +++ b/deploya-core/deploya-core/deploya-core - Backup.csproj @@ -0,0 +1,35 @@ + + + + Exe + net6.0 + deploya_core + true + true + true + win-x64 + false + deployaCLI + deploya.ico + app.manifest + AnyCPU;x64 + embedded + False + deploya + 12.0.0.401 + valnoxy + Exploitox + deploya + CLI version of deploya + + + + + + + + + + + + diff --git a/deploya-core/deploya-core/deploya-core.csproj b/deploya-core/deploya-core/deploya-core.csproj new file mode 100644 index 0000000..1bd2623 --- /dev/null +++ b/deploya-core/deploya-core/deploya-core.csproj @@ -0,0 +1,38 @@ + + + + Exe + net6.0 + deploya_core + true + true + true + win-x64 + false + deployaCLI + deploya.ico + app.manifest + AnyCPU;x64 + embedded + False + deploya + 12.0.0.401 + valnoxy + Exploitox + deploya + CLI version of deploya + Copyright (c) 2018 - 2022 Exploitox. + https://github.com/valnoxy/deploya + CLI version of deploya + + + + + + + + + + + + diff --git a/deploya-core/deploya-core/deploya.ico b/deploya-core/deploya-core/deploya.ico new file mode 100644 index 0000000..834a5f9 Binary files /dev/null and b/deploya-core/deploya-core/deploya.ico differ diff --git a/deploya-core/deploya/App.xaml b/deploya-core/deploya/App.xaml new file mode 100644 index 0000000..702f187 --- /dev/null +++ b/deploya-core/deploya/App.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/deploya-core/deploya/App.xaml.cs b/deploya-core/deploya/App.xaml.cs new file mode 100644 index 0000000..94c961f --- /dev/null +++ b/deploya-core/deploya/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace deploya +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/deploya-core/deploya/AssemblyInfo.cs b/deploya-core/deploya/AssemblyInfo.cs new file mode 100644 index 0000000..8b5504e --- /dev/null +++ b/deploya-core/deploya/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/deploya-core/deploya/MainWindow.xaml b/deploya-core/deploya/MainWindow.xaml new file mode 100644 index 0000000..42fa81f --- /dev/null +++ b/deploya-core/deploya/MainWindow.xaml @@ -0,0 +1,17 @@ + + + + +