Skip to content

Commit 490c319

Browse files
committed
Test windows artifacts
1 parent a2ce0e3 commit 490c319

File tree

4 files changed

+92
-38
lines changed

4 files changed

+92
-38
lines changed

Diff for: .github/workflows/verify.yml

+89-36
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ jobs:
370370
ruby:
371371
- 3.2.5
372372

373-
name: ${{ matrix.os }}
373+
name: ${{ matrix.os }} compilation
374374
steps:
375375
# https://github.com/actions/runner-images/issues/5143
376376
# https://github.com/actions/runner-images/issues/9701
@@ -451,41 +451,6 @@ jobs:
451451
rem and the ridk.cmd Ruby installer will forcibly kill the msys2 process before attempting to install ruby
452452
ruby bin/omnibus build metasploit-framework
453453
454-
# Currently hangs on Github actions - but passes locally, potential cause within the debug.log file:
455-
#
456-
# Info 1603.The file C:\Windows\system32\vcruntime140_1.dll is being held in use. Close that application and retry.
457-
#
458-
# - name: Test artifact
459-
# shell: pwsh
460-
# run: |
461-
# Set-PSDebug -Trace 1
462-
# echo "Testing artifact"
463-
464-
# Remove-Item c:\metasploit-framework -Recurse -ErrorAction Ignore
465-
466-
# dir metasploit-omnibus\pkg
467-
468-
# echo '' > debug.log
469-
# $artifact = (Get-ChildItem -Path "metasploit-omnibus/pkg/*.msi")[0].Name
470-
# $install_process = Start-Process msiexec.exe -ArgumentList "/i metasploit-omnibus\pkg\$artifact /quiet /qn /l*v debug.log" -NoNewWindow -PassThru
471-
# $log_process = Start-Process "powershell" "Get-Content -Path debug.log -Wait" -NoNewWindow -PassThru
472-
# $install_process.WaitForExit()
473-
# $log_process.Kill()
474-
# echo "finished install"
475-
476-
# c:\metasploit-framework\bin\msfconsole -qx 'setg variable test; version; exit'
477-
# c:\metasploit-framework\bin\msfvenom -p windows/meterpreter/reverse_tcp -f exe -o test.exe
478-
# c:\metasploit-framework\bin\msfd -h
479-
# c:\metasploit-framework\bin\msfrpc -h
480-
# c:\metasploit-framework\bin\msfrpcd -h
481-
# c:\metasploit-framework\bin\msfdb -h
482-
# c:\metasploit-framework\bin\msfbinscan -h
483-
# c:\metasploit-framework\bin\msfrop -h
484-
# c:\metasploit-framework\bin\msfelfscan -h
485-
# c:\metasploit-framework\bin\msfmachscan -h
486-
# c:\metasploit-framework\bin\msfpescan -h
487-
# c:\metasploit-framework\bin\msfupdate
488-
489454
- name: Upload artifact
490455
uses: actions/upload-artifact@v4
491456
with:
@@ -496,3 +461,91 @@ jobs:
496461
metasploit-omnibus/pkg/*.msi
497462
metasploit-omnibus/pkg/*.deb
498463
retention-days: 1
464+
465+
# Ensure we can install the Windows installer on a fresh environment without any pre-existing dependencies.
466+
# Additionally, running on the previous windows builder is not currently possible, as it currently hangs on
467+
# on Github actions - but passes locally. The potential cause is logged to the debug.log file:
468+
#
469+
# Info 1603.The file C:\Windows\system32\vcruntime140_1.dll is being held in use. Close that application and retry.
470+
#
471+
windows_testing:
472+
needs: windows
473+
runs-on: ${{ matrix.os }}
474+
timeout-minutes: 180
475+
476+
strategy:
477+
fail-fast: false
478+
matrix:
479+
os:
480+
- windows-2022
481+
482+
name: ${{ matrix.os }} testing
483+
steps:
484+
485+
- uses: actions/download-artifact@v4
486+
name: Download Windows arifacts
487+
id: download_windows_artifacts
488+
with:
489+
name: metasploit-windows-installers
490+
path: metasploit-omnibus
491+
492+
- name: Install artifact
493+
shell: pwsh
494+
run: |
495+
Set-PSDebug -Trace 1
496+
echo "Testing artifact"
497+
498+
echo '' > debug.log
499+
$artifact = (Get-ChildItem -Path "metasploit-omnibus/*.msi")[0].Name
500+
$install_process = Start-Process msiexec.exe -ArgumentList "/i metasploit-omnibus\$artifact /quiet /qn /l*v debug.log" -NoNewWindow -PassThru
501+
$install_process_handle = $install_process.Handle # cache proc.Handle - https://stackoverflow.com/questions/10262231/obtaining-exitcode-using-start-process-and-waitforexit-instead-of-wait
502+
$log_process = Start-Process "powershell" "Get-Content -Path debug.log -Wait" -NoNewWindow -PassThru
503+
$install_process.WaitForExit()
504+
$log_process.Kill()
505+
echo "finished install"
506+
Exit $install_process.ExitCode
507+
508+
- shell: pwsh
509+
run: |
510+
d:\metasploit-framework\bin\msfvenom -p windows/meterpreter/reverse_tcp -f exe -o test.exe
511+
Exit $LASTEXITCODE
512+
- shell: pwsh
513+
run: |
514+
d:\metasploit-framework\bin\msfd -h
515+
Exit $LASTEXITCODE
516+
- shell: pwsh
517+
run: |
518+
d:\metasploit-framework\bin\msfrpc -h
519+
Exit $LASTEXITCODE
520+
- shell: pwsh
521+
run: |
522+
d:\metasploit-framework\bin\msfrpcd -h
523+
Exit $LASTEXITCODE
524+
- shell: pwsh
525+
run: |
526+
d:\metasploit-framework\bin\msfdb -h
527+
Exit $LASTEXITCODE
528+
- shell: pwsh
529+
run: |
530+
d:\metasploit-framework\bin\msfbinscan -h
531+
Exit $LASTEXITCODE
532+
- shell: pwsh
533+
run: |
534+
d:\metasploit-framework\bin\msfrop -h
535+
Exit $LASTEXITCODE
536+
- shell: pwsh
537+
run: |
538+
d:\metasploit-framework\bin\msfelfscan -h
539+
Exit $LASTEXITCODE
540+
- shell: pwsh
541+
run: |
542+
d:\metasploit-framework\bin\msfmachscan -h
543+
Exit $LASTEXITCODE
544+
- shell: pwsh
545+
run: |
546+
d:\metasploit-framework\bin\msfpescan -h
547+
Exit $LASTEXITCODE
548+
- shell: pwsh
549+
run: |
550+
d:\metasploit-framework\bin\msfconsole -qx 'setg variable test; version; exit'
551+
Exit $LASTEXITCODE

Diff for: config/templates/metasploit-framework-wrappers-windows/msfdb.bat.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ set PATH=%BIN%;%PATH%
1616

1717
ruby %FRAMEWORK%\msfdb %*
1818

19-
endlocal
19+
exit /b %ERRORLEVEL%

Diff for: config/templates/metasploit-framework-wrappers-windows/msfupdate.ps1.erb

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ $p = Start-Process -FilePath "msiexec" -ArgumentList $arguments -Wait -PassThru
1717
if($p.ExitCode -ne 0)
1818
{
1919
Write-Output "Metasploit update failed, error code: $($p.ExitCode)"
20+
Exit $p.ExitCode
2021
} else {
2122
Write-Output "Update Complete"
2223
}

Diff for: config/templates/metasploit-framework-wrappers-windows/msfwrapper.bat.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ if exist %FRAMEWORK%\%CMD% (
2121
ruby %BIN%\%CMD% %*
2222
)
2323

24-
endlocal
24+
exit /b %ERRORLEVEL%

0 commit comments

Comments
 (0)