fix: correct COM hijacking ability to report success (#597)#600
Merged
fix: correct COM hijacking ability to report success (#597)#600
Conversation
The "COM hijacking via TreatAs" ability was reporting failure despite completing successfully. The root cause was that rundll32.exe returns a non-zero exit code which Caldera interprets as failure. Fix: use Start-Process to launch rundll32.exe asynchronously so its exit code does not affect the PowerShell pipeline, and emit an explicit success message via Write-Host. Also add a cleanup block to remove the registry keys created by the ability.
There was a problem hiding this comment.
Pull request overview
Fixes Caldera ability reporting for the “COM hijacking via TreatAs” persistence technique so it doesn’t incorrectly report failure when the underlying rundll32.exe -sta invocation returns a non-zero exit code, and adds cleanup for created registry keys.
Changes:
- Switches the
rundll32.exeinvocation toStart-Processto avoid propagatingrundll32’s exit code to the PowerShell pipeline. - Emits an explicit “completed successfully” message after launching the process.
- Adds a cleanup block to delete registry keys created by the ability.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+32
to
+33
| $null = Start-Process -FilePath "rundll32.exe" -ArgumentList '-sta "AtomicTest"' -PassThru -ErrorAction SilentlyContinue; | ||
| Write-Host "COM hijacking via TreatAs completed successfully" |
| technique: | ||
| attack_id: T1546.015 | ||
| name: 'Event Triggered Execution: Component Object Model Hijacking' | ||
| privilege: Elevated |
| reg add "HKEY_CURRENT_USER\SOFTWARE\Classes\AtomicTest.1.00\CLSID" /ve /T REG_SZ /d "{00000001-0000-0000-0000-0000FEEDACDC}" /f; | ||
| reg add "HKEY_CURRENT_USER\SOFTWARE\Classes\CLSID\{00000001-0000-0000-0000-0000FEEDACDC}" /f; | ||
| reg add "HKEY_CURRENT_USER\SOFTWARE\Classes\CLSID\{00000001-0000-0000-0000-0000FEEDACDC}" /ve /T REG_SZ /d "AtomicTest" /f; | ||
| reg add "HKEY_CURRENT_USER\SOFTWARE\Classes\CLSID\{00000001-0000-0000-0000-0000FEEDACDC}\InprocServer32" /ve /T REG_SZ /d "C:\WINDOWS\system32\scrobj.dll" /f; |
| reg add "HKEY_CURRENT_USER\SOFTWARE\Classes\CLSID\{00000001-0000-0000-0000-0000FEEDACDC}\VersionIndependentProgID" /ve /T REG_SZ /d "AtomicTest" /f; | ||
| reg add "HKEY_CURRENT_USER\SOFTWARE\Classes\CLSID\{97D47D56-3777-49FB-8E8F-90D7E30E1A1E}" /f; | ||
| reg add "HKEY_CURRENT_USER\SOFTWARE\Classes\CLSID\{97D47D56-3777-49FB-8E8F-90D7E30E1A1E}\TreatAs" /ve /T REG_SZ /d "{00000001-0000-0000-0000-0000FEEDACDC}" /f; | ||
| $null = Start-Process -FilePath "rundll32.exe" -ArgumentList '-sta "AtomicTest"' -PassThru -ErrorAction SilentlyContinue; |
- Remove privilege: Elevated since HKCU registry writes do not require elevation - Replace C:\WINDOWS\system32\scrobj.dll with $env:WINDIR\System32\scrobj.dll - Replace rundll32.exe with $env:WINDIR\System32\rundll32.exe - Check Start-Process return value before emitting unconditional success message
|
@deacon-mp I've opened a new pull request, #609, to work on those changes. Once the pull request is ready, I'll request review from you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rundll32.exe -sta "AtomicTest"returns a non-zero exit code, which Caldera interprets as a failed abilityrundll32.exeviaStart-Processso its exit code does not propagate to the PowerShell pipeline, and emit an explicit success message withWrite-HostTest plan