From 15c9839beca9f31c6a1493f41be1d7aa008e4e17 Mon Sep 17 00:00:00 2001 From: Alan Mason <1923621+2Shirt@users.noreply.github.com> Date: Mon, 27 Nov 2017 23:42:15 -0800 Subject: [PATCH 1/4] Added update section * Needs testing --- .bin/Scripts/build_pe.ps1 | 205 ++++++++++++++++++++++++++++++++------ 1 file changed, 174 insertions(+), 31 deletions(-) diff --git a/.bin/Scripts/build_pe.ps1 b/.bin/Scripts/build_pe.ps1 index 4a08a1b4..abcf3537 100644 --- a/.bin/Scripts/build_pe.ps1 +++ b/.bin/Scripts/build_pe.ps1 @@ -10,7 +10,7 @@ $Host.UI.RawUI.WindowTitle = "Wizard Kit: Windows PE Build Tool" $WD = $(Split-Path $MyInvocation.MyCommand.Path) $Bin = (Get-Item $WD -Force).Parent.FullName $Root = (Get-Item $Bin -Force).Parent.FullName -$Temp = "{0}\tmp" -f $Bin +$Temp = "$Bin\tmp" $Date = Get-Date -UFormat "%Y-%m-%d" $Host.UI.RawUI.BackgroundColor = "Black" $Host.UI.RawUI.ForegroundColor = "White" @@ -106,30 +106,29 @@ function MakeClean { function DownloadFile ($Path, $Name, $Url) { $OutFile = "{0}\{1}" -f $Path, $Name - Write-Host ("Downloading: {0}" -f $Name) + Write-Host ("Downloading: $Name") New-Item -Type Directory $Path 2>&1 | Out-Null try { - Invoke-Webrequest -Uri $Url -OutFile $OutFile + Invoke-WebRequest -Uri $Url -OutFile $OutFile } catch { Write-Host (" ERROR: Failed to download file." ) -ForegroundColor "Red" + $DownloadErrors += 1 } } function FindDynamicUrl ($SourcePage, $RegEx) { - $Url = "" - # Get source page Invoke-Webrequest -Uri $SourcePage -OutFile "tmp_page" # Search for real url $Url = Get-Content "tmp_page" | Where-Object {$_ -imatch $RegEx} - $Url = $Url -ireplace '.*(a |)href="([^"]+)".*', "$2" - $Url = $Url -ireplace ".*(a |)href='([^']+)'.*", "$2" + $Url = $Url -ireplace '.*(a |)href="([^"]+)".*', '$2' + $Url = $Url -ireplace ".*(a |)href='([^']+)'.*", '$2' # Remove tmp_page Remove-Item "tmp_page" - return $Url + $Url | Select-Object -First 1 } function WKPause ($Message = "Press Enter to continue... ") { Write-Host $Message -NoNewLine @@ -143,7 +142,7 @@ function WKPause ($Message = "Press Enter to continue... ") { # Asked by: https://stackoverflow.com/users/65164/mark-mascolino # Answer by: https://stackoverflow.com/users/696808/bacon-bits if ($MyInvocation.InvocationName -ne ".") { - # Clear-Host + Clear-Host Write-Host "Wizard Kit: Windows PE Build Tool`n" ## Prep ## @@ -157,6 +156,147 @@ if ($MyInvocation.InvocationName -ne ".") { Push-Location "$WD" MakeClean + if (Ask-User "Update Tools?") { + $DownloadErrors = 0 + $Path = $Temp + + ## Download Tools ## + # 7-Zip + DownloadFile -Path $Path -Name "7z-installer.msi" -Url "http://www.7-zip.org/a/7z1701.msi" + DownloadFile -Path $Path -Name "7z-extra.7z" -Url "http://www.7-zip.org/a/7z1701-extra.7z" + + # ConEmu + $Url = "https://github.com/Maximus5/ConEmu/releases/download/v17.11.09/ConEmuPack.171109.7z" + DownloadFile -Path $Path -Name "ConEmuPack.7z" -Url $Url + + # Notepad++ + $Url = "https://notepad-plus-plus.org/repository/7.x/7.5.2/npp.7.5.2.bin.minimalist.x64.7z" + DownloadFile -Path $Path -Name "nppamd64.7z" -Url $Url + $Url = "https://notepad-plus-plus.org/repository/7.x/7.5.2/npp.7.5.2.bin.minimalist.7z" + DownloadFile -Path $Path -Name "nppx86.7z" -Url $Url + + # Python + $Url = "https://www.python.org/ftp/python/3.6.3/python-3.6.3-embed-win32.zip" + DownloadFile -Path $Path -Name "python32.zip" -Url $Url + $Url = "https://www.python.org/ftp/python/3.6.3/python-3.6.3-embed-amd64.zip" + DownloadFile -Path $Path -Name "python64.zip" -Url $Url + + # Python: psutil + $DownloadPage = "https://pypi.python.org/pypi/psutil" + $RegEx = "href=.*-cp36-cp36m-win32.whl" + $Url = FindDynamicUrl $DownloadPage $RegEx + DownloadFile -Path $Path -Name "psutil32.whl" -Url $Url + $RegEx = "href=.*-cp36-cp36m-win_amd64.whl" + $Url = FindDynamicUrl $DownloadPage $RegEx + DownloadFile -Path $Path -Name "psutil64.whl" -Url $Url + + ## Bail ## + # If errors were encountered during downloads + if ($DownloadErrors -gt 0) { + Abort + } + + ## Extract ## + # 7-Zip + Write-Host "Extracting: 7-Zip" + try { + $ArgumentList = @("/a", "$Temp\7z-installer.msi", "TARGETDIR=$Temp\7zi", "/qn") + Start-Process -FilePath "$System32\msiexec.exe" -ArgumentList $ArgumentList -Wait + $SevenZip = "$Temp\7zi\Files\7-Zip\7z.exe" + $ArgumentList = @( + "e", "$Temp\7z-extra.7z", "-o$Root\WK\amd64\7-Zip", + "-aoa", "-bso0", "-bse0", "-bsp0", + "x64\7za.exe", "*.txt") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + $ArgumentList = @( + "e", "$Temp\7z-extra.7z", "-o$Root\WK\x86\7-Zip", + "-aoa", "-bso0", "-bse0", "-bsp0", + "7za.exe", "*.txt") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + Remove-Item "$Temp\7z*" -Recurse + $SevenZip = "$Root\WK\x86\7-Zip\7za.exe" + } + catch { + Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" + } + + # Notepad++ + Write-Host "Extracting: Notepad++" + try { + $ArgumentList = @( + "x", "$Temp\nppamd64.7z", "-o$Root\WK\amd64\NotepadPlusPlus", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + $ArgumentList = @( + "x", "$Temp\nppx86.7z", "-o$Root\WK\x86\NotepadPlusPlus", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + Remove-Item "$Temp\npp*.7z" + Move-Item "$Root\WK\amd64\NotepadPlusPlus\notepad++.exe" "$Root\WK\amd64\NotepadPlusPlus\notepadplusplus.exe" + Move-Item "$Root\WK\x86\NotepadPlusPlus\notepad++.exe" "$Root\WK\x86\NotepadPlusPlus\notepadplusplus.exe" + } + catch { + Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" + } + + # ConEmu + Write-Host "Extracting: ConEmu" + try { + $ArgumentList = @( + "x", "$Temp\ConEmuPack.7z", "-o$Root\WK\amd64\ConEmu", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + Remove-Item "$Root\WK\amd64\ConEmu\ConEmu.exe" + Remove-Item "$Root\WK\amd64\ConEmu\ConEmu.map" + Move-Item "$Root\WK\amd64\ConEmu\ConEmu64.exe" "$Root\WK\amd64\ConEmu\ConEmu.exe" + Move-Item "$Root\WK\amd64\ConEmu\ConEmu64.map" "$Root\WK\amd64\ConEmu\ConEmu.map" + $ArgumentList = @( + "x", "$Temp\ConEmuPack.7z", "-o$Root\WK\x86\ConEmu", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + Remove-Item "$Root\WK\x86\ConEmu\ConEmu64.exe" + Remove-Item "$Root\WK\x86\ConEmu\ConEmu64.map" + Remove-Item "$Temp\ConEmuPack.7z" + } + catch { + Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" + } + + # Python + Write-Host "Extracting: Python" + try { + $ArgumentList = @( + "x", "$Temp\python64.zip", "-o$Root\WK\amd64\python", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + $ArgumentList = @( + "x", "$Temp\python32.zip", "-o$Root\WK\x86\python", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + Remove-Item "$Temp\python*.zip" + } + catch { + Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" + } + + # Python: psutil + Write-Host "Extracting: Python" + try { + $ArgumentList = @( + "x", "$Temp\psutil64.whl", "-o$Root\WK\amd64\python", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + $ArgumentList = @( + "x", "$Temp\psutil32.whl", "-o$Root\WK\x86\python", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + Remove-Item "$Temp\*.whl" + } + catch { + Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" + } + } + ## Build ## foreach ($Arch in @("amd64", "x86")) { $Drivers = "$Root\Drivers\%arch" @@ -166,7 +306,7 @@ if ($MyInvocation.InvocationName -ne ".") { # Copy WinPE files Write-Host "Copying files..." $Cmd = ("{0}\copype.cmd" -f $Env:WinPERoot) - Start-Process $Cmd -ArgumentList @($Arch, $PEFiles) -NoNewWindow -Wait + Start-Process -FilePath $Cmd -ArgumentList @($Arch, $PEFiles) -NoNewWindow -Wait # Remove unwanted items foreach ($SubDir in @("media", "media\Boot", "media\EFI\Microsoft\Boot")) { @@ -195,7 +335,7 @@ if ($MyInvocation.InvocationName -ne ".") { ('/Image:"{0}"' -f $Mount), "/Set-ScratchSpace:512" ) - Start-Process $DISM -ArgumentList $ArgumentList -NoNewWindow -Wait + Start-Process -FilePath $DISM -ArgumentList $ArgumentList -NoNewWindow -Wait # Add WK tools Write-Host "Copying tools..." @@ -211,30 +351,33 @@ if ($MyInvocation.InvocationName -ne ".") { Copy-Item -Path "$Root\Scripts" -Destination "$Mount\WK\Scripts" -Recurse -Force # Add System32 items + $HostSystem32 = "{0}\System32" -f $Env:SystemRoot Copy-Item -Path "$Root\System32\*" -Destination "$Mount\Windows\System32" -Recurse -Force $ArgumentList = @("/f", "$Mount\Windows\System32\winpe.jpg", "/a") - Start-Process "C:\Windows\System32\takeown.exe" -ArgumentList $ArgumentList -NoNewWindow -Wait + Start-Process -FilePath "$HostSystem32\takeown.exe" -ArgumentList $ArgumentList -NoNewWindow -Wait $ArgumentList = @("$Mount\Windows\System32\winpe.jpg", "/grant", "Administrators:F") - Start-Process "C:\Windows\System32\icacls.exe" -ArgumentList $ArgumentList -NoNewWindow -Wait + Start-Process -FilePath "$HostSystem32\icacls.exe" -ArgumentList $ArgumentList -NoNewWindow -Wait Copy-Item -Path "$Root\WinPE.jpg" -Destination "$Mount\Windows\System32\winpe.jpg" -Recurse -Force - # Update registry + # Load registry hives Write-Host "Updating Registry..." - $Reg = "C:\Windows\System32\reg.exe" - Start-Process $Reg -ArgumentList @("load", "HKLM\WinPE-SW", "$Mount\Windows\System32\config\SOFTWARE") -NoNewWindow -Wait - Start-Process $Reg -ArgumentList @("load", "HKLM\WinPE-SYS", "$Mount\Windows\System32\config\SYSTEM") -NoNewWindow -Wait + $Reg = "$HostSystem32\reg.exe" + $ArgumentList = @("load", "HKLM\WinPE-SW", "$Mount\Windows\System32\config\SOFTWARE") + Start-Process -FilePath $Reg -ArgumentList $ArgumentList -NoNewWindow -Wait + $ArgumentList = @("load", "HKLM\WinPE-SYS", "$Mount\Windows\System32\config\SYSTEM") + Start-Process -FilePath $Reg -ArgumentList $ArgumentList -NoNewWindow -Wait - # Add 7-Zip and Python to path - $RegPath = "HKLM:\WinPE-SYS\ControlSet001\Control\Session Manager\Environment" - $RegKey = Get-ItemProperty -Path $RegPath - $NewValue = "{0};%SystemDrive%\WK\7-Zip;%SystemDrive%\WK\python;%SystemDrive%\WK\wimlib" -f $RegKey.Path - Set-ItemProperty -Path $RegPath -Name "Path" -Value $NewValue -Force | Out-Null - - # Replace Notepad - $RegPath = "HKLM:\WinPE-SW\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" - $NewValue = 'wscript "X:\WK\NotepadPlusPlus\npp.vbs"' - New-Item -Path $RegPath -Force | Out-Null - New-ItemProperty -Path $RegPath -Name "Debugger" -Value $NewValue -Force | Out-Null + # Add tools to path + $RegPath = "HKLM:\WinPE-SYS\ControlSet001\Control\Session Manager\Environment" + $RegKey = Get-ItemProperty -Path $RegPath + $NewValue = "{0};%SystemDrive%\WK\7-Zip;%SystemDrive%\WK\python;%SystemDrive%\WK\wimlib" -f $RegKey.Path + Set-ItemProperty -Path $RegPath -Name "Path" -Value $NewValue -Force | Out-Null + + # Replace Notepad + $RegPath = "HKLM:\WinPE-SW\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" + $NewValue = 'wscript "X:\WK\NotepadPlusPlus\npp.vbs"' + New-Item -Path $RegPath -Force | Out-Null + New-ItemProperty -Path $RegPath -Name "Debugger" -Value $NewValue -Force | Out-Null # Run garbage collection to release potential stale handles ## Credit: https://jrich523.wordpress.com/2012/03/06/powershell-loading-and-unloading-registry-hives/ @@ -243,8 +386,8 @@ if ($MyInvocation.InvocationName -ne ".") { # Unload registry hives Start-Sleep -Seconds 2 - Start-Process $Reg -ArgumentList @("unload", "HKLM\WinPE-SW") -NoNewWindow -Wait - Start-Process $Reg -ArgumentList @("unload", "HKLM\WinPE-SYS") -NoNewWindow -Wait + Start-Process -FilePath $Reg -ArgumentList @("unload", "HKLM\WinPE-SW") -NoNewWindow -Wait + Start-Process -FilePath $Reg -ArgumentList @("unload", "HKLM\WinPE-SYS") -NoNewWindow -Wait # Unmount image Write-Host "Dismounting image..." @@ -253,7 +396,7 @@ if ($MyInvocation.InvocationName -ne ".") { # Create ISO $ArgumentList = @("/iso", $PEFiles, "$Root\wk-winpe-$Date-$Arch.iso") $Cmd = "{0}\MakeWinPEMedia.cmd" -f $Env:WinPERoot - Start-Process $Cmd -ArgumentList $ArgumentList -NoNewWindow -Wait + Start-Process -FilePath $Cmd -ArgumentList $ArgumentList -NoNewWindow -Wait } ## Done ## From 7048696367a5b193e7ef2956f5dfd8fc592501f4 Mon Sep 17 00:00:00 2001 From: Alan Mason <1923621+2Shirt@users.noreply.github.com> Date: Tue, 28 Nov 2017 01:16:40 -0800 Subject: [PATCH 2/4] Added the rest of the tools --- .bin/Scripts/build_pe.ps1 | 251 +++++++++++++++++++++++++++++++++----- Scripts/menu.py | 1 - 2 files changed, 223 insertions(+), 29 deletions(-) diff --git a/.bin/Scripts/build_pe.ps1 b/.bin/Scripts/build_pe.ps1 index abcf3537..09471a00 100644 --- a/.bin/Scripts/build_pe.ps1 +++ b/.bin/Scripts/build_pe.ps1 @@ -15,7 +15,7 @@ $Date = Get-Date -UFormat "%Y-%m-%d" $Host.UI.RawUI.BackgroundColor = "Black" $Host.UI.RawUI.ForegroundColor = "White" # $ProgressPreference = "silentlyContinue" -$SplitWindow = @() +$HostSystem32 = "{0}\System32" -f $Env:SystemRoot $WinPEPackages = @( "WinPE-EnhancedStorage.cab", "en-us\WinPE-EnhancedStorage_en-us.cab", @@ -143,7 +143,7 @@ function WKPause ($Message = "Press Enter to continue... ") { # Answer by: https://stackoverflow.com/users/696808/bacon-bits if ($MyInvocation.InvocationName -ne ".") { Clear-Host - Write-Host "Wizard Kit: Windows PE Build Tool`n" + Write-Host "Wizard Kit: Windows PE Build Tool`n`n`n`n`n" ## Prep ## try { @@ -165,31 +165,77 @@ if ($MyInvocation.InvocationName -ne ".") { DownloadFile -Path $Path -Name "7z-installer.msi" -Url "http://www.7-zip.org/a/7z1701.msi" DownloadFile -Path $Path -Name "7z-extra.7z" -Url "http://www.7-zip.org/a/7z1701-extra.7z" + # Blue Screen View + $Url = "http://www.nirsoft.net/utils/bluescreenview-x64.zip" + DownloadFile -Path $Path -Name "bluescreenview64.zip" -Url $Url + $Url = "http://www.nirsoft.net/utils/bluescreenview.zip" + DownloadFile -Path $Path -Name "bluescreenview32.zip" -Url $Url + # ConEmu $Url = "https://github.com/Maximus5/ConEmu/releases/download/v17.11.09/ConEmuPack.171109.7z" DownloadFile -Path $Path -Name "ConEmuPack.7z" -Url $Url + # Fast Copy + $Url = "http://ftp.vector.co.jp/69/28/2323/FastCopy332_x64.zip" + DownloadFile -Path $Path -Name "fastcopy64.zip" -Url $Url + $Url = "http://ftp.vector.co.jp/69/28/2323/FastCopy332.zip" + DownloadFile -Path $Path -Name "fastcopy32.zip" -Url $Url + + # HWiNFO + $Url = "http://app.oldfoss.com:81/download/HWiNFO/hw64_560.zip" + DownloadFile -Path $Path -Name "hwinfo64.zip" -Url $Url + $Url = "http://app.oldfoss.com:81/download/HWiNFO/hw32_560.zip" + DownloadFile -Path $Path -Name "hwinfo32.zip" -Url $Url + # Notepad++ $Url = "https://notepad-plus-plus.org/repository/7.x/7.5.2/npp.7.5.2.bin.minimalist.x64.7z" - DownloadFile -Path $Path -Name "nppamd64.7z" -Url $Url + DownloadFile -Path $Path -Name "npp_amd64.7z" -Url $Url $Url = "https://notepad-plus-plus.org/repository/7.x/7.5.2/npp.7.5.2.bin.minimalist.7z" - DownloadFile -Path $Path -Name "nppx86.7z" -Url $Url + DownloadFile -Path $Path -Name "npp_x86.7z" -Url $Url + # NT Password Editor + $Url = "http://cdslow.org.ru/files/ntpwedit/ntpwed07.zip" + DownloadFile -Path $Path -Name "ntpwed.zip" -Url $Url + + # Prime95 + $Url = "http://www.mersenne.org/ftp_root/gimps/p95v294b5.win64.zip" + DownloadFile -Path $Path -Name "prime95_64.zip" -Url $Url + $Url = "http://www.mersenne.org/ftp_root/gimps/p95v294b5.win32.zip" + DownloadFile -Path $Path -Name "prime95_32.zip" -Url $Url + + # ProduKey + $Url = "http://www.nirsoft.net/utils/produkey-x64.zip" + DownloadFile -Path $Path -Name "produkey64.zip" -Url $Url + $Url = "http://www.nirsoft.net/utils/produkey.zip" + DownloadFile -Path $Path -Name "produkey32.zip" -Url $Url + # Python - $Url = "https://www.python.org/ftp/python/3.6.3/python-3.6.3-embed-win32.zip" - DownloadFile -Path $Path -Name "python32.zip" -Url $Url $Url = "https://www.python.org/ftp/python/3.6.3/python-3.6.3-embed-amd64.zip" DownloadFile -Path $Path -Name "python64.zip" -Url $Url + $Url = "https://www.python.org/ftp/python/3.6.3/python-3.6.3-embed-win32.zip" + DownloadFile -Path $Path -Name "python32.zip" -Url $Url # Python: psutil + $RegEx = "href=.*-cp36-cp36m-win_amd64.whl" + $Url = FindDynamicUrl $DownloadPage $RegEx + DownloadFile -Path $Path -Name "psutil64.whl" -Url $Url $DownloadPage = "https://pypi.python.org/pypi/psutil" $RegEx = "href=.*-cp36-cp36m-win32.whl" $Url = FindDynamicUrl $DownloadPage $RegEx DownloadFile -Path $Path -Name "psutil32.whl" -Url $Url - $RegEx = "href=.*-cp36-cp36m-win_amd64.whl" - $Url = FindDynamicUrl $DownloadPage $RegEx - DownloadFile -Path $Path -Name "psutil64.whl" -Url $Url - + + # Q-Dir + $Url = "https://www.softwareok.com/Download/Q-Dir_Portable_x64.zip" + DownloadFile -Path $Path -Name "qdir64.zip" -Url $Url + $Url = "https://www.softwareok.com/Download/Q-Dir_Portable.zip" + DownloadFile -Path $Path -Name "qdir32.zip" -Url $Url + + # TestDisk / PhotoRec + $Url = "https://www.cgsecurity.org/testdisk-7.1-WIP.win64.zip" + DownloadFile -Path $Path -Name "testdisk64.zip" -Url $Url + $Url = "https://www.cgsecurity.org/testdisk-7.1-WIP.win.zip" + DownloadFile -Path $Path -Name "testdisk32.zip" -Url $Url + ## Bail ## # If errors were encountered during downloads if ($DownloadErrors -gt 0) { @@ -201,7 +247,7 @@ if ($MyInvocation.InvocationName -ne ".") { Write-Host "Extracting: 7-Zip" try { $ArgumentList = @("/a", "$Temp\7z-installer.msi", "TARGETDIR=$Temp\7zi", "/qn") - Start-Process -FilePath "$System32\msiexec.exe" -ArgumentList $ArgumentList -Wait + Start-Process -FilePath "$HostSystem32\msiexec.exe" -ArgumentList $ArgumentList -Wait $SevenZip = "$Temp\7zi\Files\7-Zip\7z.exe" $ArgumentList = @( "e", "$Temp\7z-extra.7z", "-o$Root\WK\amd64\7-Zip", @@ -220,25 +266,23 @@ if ($MyInvocation.InvocationName -ne ".") { Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" } - # Notepad++ - Write-Host "Extracting: Notepad++" + # Blue Screen View + Write-Host "Extracting: BlueScreenView" try { $ArgumentList = @( - "x", "$Temp\nppamd64.7z", "-o$Root\WK\amd64\NotepadPlusPlus", + "x", "$Temp\bluescreenview64.zip", "-o$Root\WK\amd64\BlueScreenView", "-aoa", "-bso0", "-bse0", "-bsp0") Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait $ArgumentList = @( - "x", "$Temp\nppx86.7z", "-o$Root\WK\x86\NotepadPlusPlus", + "x", "$Temp\bluescreenview32.zip", "-o$Root\WK\x86\BlueScreenView", "-aoa", "-bso0", "-bse0", "-bsp0") Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait - Remove-Item "$Temp\npp*.7z" - Move-Item "$Root\WK\amd64\NotepadPlusPlus\notepad++.exe" "$Root\WK\amd64\NotepadPlusPlus\notepadplusplus.exe" - Move-Item "$Root\WK\x86\NotepadPlusPlus\notepad++.exe" "$Root\WK\x86\NotepadPlusPlus\notepadplusplus.exe" + Remove-Item "$Temp\bluescreenview*" } catch { Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" } - + # ConEmu Write-Host "Extracting: ConEmu" try { @@ -256,47 +300,198 @@ if ($MyInvocation.InvocationName -ne ".") { Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait Remove-Item "$Root\WK\x86\ConEmu\ConEmu64.exe" Remove-Item "$Root\WK\x86\ConEmu\ConEmu64.map" - Remove-Item "$Temp\ConEmuPack.7z" + Remove-Item "$Temp\ConEmuPack*" } catch { Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" } - # Python - Write-Host "Extracting: Python" + # Fast Copy + Write-Host "Extracting: FastCopy" + try { + $ArgumentList = @( + "x", "$Temp\fastcopy64.zip", "-o$Root\WK\amd64\FastCopy", + "-aoa", "-bso0", "-bse0", "-bsp0", + "-x!setup.exe", "-x!*.dll") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + $ArgumentList = @( + "e", "$Temp\fastcopy32.zip", "-o$Root\WK\x86\FastCopy", + "-aoa", "-bso0", "-bse0", "-bsp0", + "-x!setup.exe", "-x!*.dll") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + Remove-Item "$Temp\fastcopy*" + } + catch { + Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" + } + + # HWiNFO + Write-Host "Extracting: HWiNFO" + try { + $ArgumentList = @( + "e", "$Temp\hwinfo64.zip", "-o$Root\WK\amd64\HWiNFO", + "-aoa", "-bso0", "-bse0", "-bsp0", "HWiNFO64.exe") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + $ArgumentList = @( + "e", "$Temp\hwinfo32.zip", "-o$Root\WK\x86\HWiNFO", + "-aoa", "-bso0", "-bse0", "-bsp0", "HWiNFO32.exe") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + Remove-Item "$Temp\hwinfo*" + Move-Item "$Root\WK\amd64\HWiNFO\HWiNFO64.exe" "$Root\WK\amd64\HWiNFO\HWiNFO.exe" + Move-Item "$Root\WK\x86\HWiNFO\HWiNFO32.exe" "$Root\WK\x86\HWiNFO\HWiNFO.exe" + } + catch { + Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" + } + + # Notepad++ + Write-Host "Extracting: Notepad++" + try { + $ArgumentList = @( + "x", "$Temp\npp_amd64.7z", "-o$Root\WK\amd64\NotepadPlusPlus", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + $ArgumentList = @( + "x", "$Temp\npp_x86.7z", "-o$Root\WK\x86\NotepadPlusPlus", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + Remove-Item "$Temp\npp*" + Move-Item "$Root\WK\amd64\NotepadPlusPlus\notepad++.exe" "$Root\WK\amd64\NotepadPlusPlus\notepadplusplus.exe" + Move-Item "$Root\WK\x86\NotepadPlusPlus\notepad++.exe" "$Root\WK\x86\NotepadPlusPlus\notepadplusplus.exe" + } + catch { + Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" + } + + # NT Password Editor + Write-Host "Extracting: NT Password Editor" + try { + $ArgumentList = @( + "e", "$Temp\ntpwed.zip", ('-o"{0}\WK\amd64\NT Password Editor"' -f $Root), + "-aoa", "-bso0", "-bse0", "-bsp0", + "ntpwedit64.exe", "*.txt") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + Move-Item "$Root\WK\amd64\NT Password Editor\ntpwedit64.exe" "$Root\WK\amd64\NT Password Editor\ntpwedit.exe" + $ArgumentList = @( + "e", "$Temp\ntpwed.zip", ('-o"{0}\WK\x86\NT Password Editor"' -f $Root), + "-aoa", "-bso0", "-bse0", "-bsp0", + "ntpwedit.exe", "*.txt") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + Remove-Item "$Temp\ntpwed*" + } + catch { + Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" + } + + # PhotoRec / TestDisk + Write-Host "Extracting: PhotoRec / TestDisk" + try { + $ArgumentList = @( + "x", "$Temp\testdisk64.zip", "-o$Root\WK\amd64\TestDisk", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + Move-Item "$Root\WK\amd64\TestDisk\testdisk-7.1-WIP\*" "$Root\WK\amd64\TestDisk" -Force + Remove-Item "$Root\WK\amd64\TestDisk\testdisk-7.1-WIP" -Recurse -Force + $ArgumentList = @( + "x", "$Temp\testdisk32.zip", "-o$Root\WK\x86\TestDisk", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + Move-Item "$Root\WK\x86\TestDisk\testdisk-7.1-WIP\*" "$Root\WK\x86\TestDisk" -Force + Remove-Item "$Root\WK\x86\TestDisk\testdisk-7.1-WIP" -Recurse -Force + Remove-Item "$Temp\testdisk*" + } + catch { + Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" + } + + # Prime95 + Write-Host "Extracting: Prime95" + try { + $ArgumentList = @( + "x", "$Temp\prime95_64.zip", "-o$Root\WK\amd64\Prime95", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + $ArgumentList = @( + "x", "$Temp\prime95_32.zip", "-o$Root\WK\x86\Prime95", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + Remove-Item "$Temp\prime95*" + } + catch { + Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" + } + + # ProduKey + try { + $ArgumentList = @( + "x", "$Temp\produkey64.zip", "-o$Root\WK\amd64\ProduKey", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + $ArgumentList = @( + "x", "$Temp\produkey32.zip", "-o$Root\WK\x86\ProduKey", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + Remove-Item "$Temp\produkey*" + } + catch { + Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" + } + + # Python (x64) + Write-Host "Extracting: Python (x64)" try { $ArgumentList = @( "x", "$Temp\python64.zip", "-o$Root\WK\amd64\python", "-aoa", "-bso0", "-bse0", "-bsp0") Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait $ArgumentList = @( - "x", "$Temp\python32.zip", "-o$Root\WK\x86\python", + "x", "$Temp\psutil64.whl", "-o$Root\WK\amd64\python", "-aoa", "-bso0", "-bse0", "-bsp0") Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait - Remove-Item "$Temp\python*.zip" + } catch { Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" } - # Python: psutil - Write-Host "Extracting: Python" + # Python (x32) + Write-Host "Extracting: Python (x32)" try { $ArgumentList = @( - "x", "$Temp\psutil64.whl", "-o$Root\WK\amd64\python", + "x", "$Temp\python32.zip", "-o$Root\WK\x86\python", "-aoa", "-bso0", "-bse0", "-bsp0") Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait $ArgumentList = @( "x", "$Temp\psutil32.whl", "-o$Root\WK\x86\python", "-aoa", "-bso0", "-bse0", "-bsp0") Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait - Remove-Item "$Temp\*.whl" + } catch { Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" } + Remove-Item "$Temp\python*" + Remove-Item "$Temp\*.whl" } + # Q-Dir + Write-Host "Extracting: Q-Dir" + try { + $ArgumentList = @( + "e", "$Temp\qdir64.zip", "-o$Root\WK\amd64\Q-Dir", + "-aoa", "-bso0", "-bse0", "-bsp0") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + $ArgumentList = @( + "e", "$Temp\qdir32.zip", "-o$Root\WK\x86\Q-Dir", + "-aoa", "-bso0", "-bse0", "-bsp0", + "Q-Dir.*") + Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait + Remove-Item "$Temp\qdir*" + } + catch { + Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red" + } + ## Build ## foreach ($Arch in @("amd64", "x86")) { $Drivers = "$Root\Drivers\%arch" diff --git a/Scripts/menu.py b/Scripts/menu.py index 952ec9a4..7a72f729 100644 --- a/Scripts/menu.py +++ b/Scripts/menu.py @@ -199,7 +199,6 @@ def menu_windows_setup(): def menu_tools(): tools = [ {'Name': 'Blue Screen View', 'Folder': 'BlueScreenView', 'File': 'BlueScreenView.exe'}, - {'Name': 'CPU-Z', 'Folder': 'CPU-Z', 'File': 'cpuz.exe'}, {'Name': 'Fast Copy', 'Folder': 'FastCopy', 'File': 'FastCopy.exe', 'Args': ['/log', '/logfile=X:\WK\Info\FastCopy.log', '/cmd=noexist_only', '/utf8', '/skip_empty_dir', '/linkdest', '/open_window', '/balloon=FALSE', r'/exclude=$RECYCLE.BIN;$Recycle.Bin;.AppleDB;.AppleDesktop;.AppleDouble;.com.apple.timemachine.supported;.dbfseventsd;.DocumentRevisions-V100*;.DS_Store;.fseventsd;.PKInstallSandboxManager;.Spotlight*;.SymAV*;.symSchedScanLockxz;.TemporaryItems;.Trash*;.vol;.VolumeIcon.icns;desktop.ini;Desktop?DB;Desktop?DF;hiberfil.sys;lost+found;Network?Trash?Folder;pagefile.sys;Recycled;RECYCLER;System?Volume?Information;Temporary?Items;Thumbs.db']}, {'Name': 'HWiNFO', 'Folder': 'HWiNFO', 'File': 'HWiNFO.exe'}, {'Name': 'NT Password Editor', 'Folder': 'NT Password Editor', 'File': 'ntpwedit.exe'}, From 7ad26a6182f9a3a37ea0d611700d731a97988139 Mon Sep 17 00:00:00 2001 From: Alan Mason <1923621+2Shirt@users.noreply.github.com> Date: Tue, 28 Nov 2017 01:55:55 -0800 Subject: [PATCH 3/4] Fix Q-Dir extraction --- .bin/Scripts/build_pe.ps1 | 7 +++---- .gitignore | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.bin/Scripts/build_pe.ps1 b/.bin/Scripts/build_pe.ps1 index 09471a00..253e7c3a 100644 --- a/.bin/Scripts/build_pe.ps1 +++ b/.bin/Scripts/build_pe.ps1 @@ -478,13 +478,12 @@ if ($MyInvocation.InvocationName -ne ".") { Write-Host "Extracting: Q-Dir" try { $ArgumentList = @( - "e", "$Temp\qdir64.zip", "-o$Root\WK\amd64\Q-Dir", + "x", "$Temp\qdir64.zip", "-o$Root\WK\amd64", "-aoa", "-bso0", "-bse0", "-bsp0") Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait $ArgumentList = @( - "e", "$Temp\qdir32.zip", "-o$Root\WK\x86\Q-Dir", - "-aoa", "-bso0", "-bse0", "-bsp0", - "Q-Dir.*") + "x", "$Temp\qdir32.zip", "-o$Root\WK\x86", + "-aoa", "-bso0", "-bse0", "-bsp0") Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait Remove-Item "$Temp\qdir*" } diff --git a/.gitignore b/.gitignore index 661aa0d4..ed8a9f58 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ Logs Mount PEFiles Scripts/__pycache__ +WK/amd64/ +WK/x86/ From bc33a7fcb398b584304f5c9c66fb0047bf0010a7 Mon Sep 17 00:00:00 2001 From: Alan Mason <1923621+2Shirt@users.noreply.github.com> Date: Tue, 28 Nov 2017 01:56:27 -0800 Subject: [PATCH 4/4] Disable notepad replacement for now --- .bin/Scripts/build_pe.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.bin/Scripts/build_pe.ps1 b/.bin/Scripts/build_pe.ps1 index 253e7c3a..41683f3e 100644 --- a/.bin/Scripts/build_pe.ps1 +++ b/.bin/Scripts/build_pe.ps1 @@ -568,10 +568,11 @@ if ($MyInvocation.InvocationName -ne ".") { Set-ItemProperty -Path $RegPath -Name "Path" -Value $NewValue -Force | Out-Null # Replace Notepad - $RegPath = "HKLM:\WinPE-SW\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" - $NewValue = 'wscript "X:\WK\NotepadPlusPlus\npp.vbs"' - New-Item -Path $RegPath -Force | Out-Null - New-ItemProperty -Path $RegPath -Name "Debugger" -Value $NewValue -Force | Out-Null + ## Currently broken ## + # $RegPath = "HKLM:\WinPE-SW\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" + # $NewValue = 'wscript "X:\WK\NotepadPlusPlus\npp.vbs"' + # New-Item -Path $RegPath -Force | Out-Null + # New-ItemProperty -Path $RegPath -Name "Debugger" -Value $NewValue -Force | Out-Null # Run garbage collection to release potential stale handles ## Credit: https://jrich523.wordpress.com/2012/03/06/powershell-loading-and-unloading-registry-hives/