mirror of
https://github.com/itm4n/PrivescCheck
synced 2026-06-08 14:54:28 +00:00
Handle paths starting with \\?\ to avoid 'illegal characters in path' exceptions (issue #82)
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
855849256
|
||||
858404805
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
- Split misc checks into multiple files.
|
||||
- Reorganize code of main file.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Handle DOS paths starting with "\\?\" in COM image file permission check to avoid "illegal characters in path" exceptions (issue #82).
|
||||
|
||||
## 2026-04-25
|
||||
|
||||
### Modified
|
||||
|
||||
@@ -509,6 +509,24 @@ function Get-ModifiableComClassEntryImagePath {
|
||||
|
||||
if ([String]::IsNullOrEmpty($CandidatePath)) { continue }
|
||||
|
||||
# If a path starts with "\\?\", it may cause an "Illegal characters in path"
|
||||
# exception when calling Get-Item. Normally, we would have to convert this
|
||||
# type of path properly, but we don't expect paths other than "\\?\C:\...",
|
||||
# so we can safely remove the prefix "\\?\" (and hope for the best ^^').
|
||||
#
|
||||
# Note that this behavior seems to only be triggered by a few EDRs. There is
|
||||
# no issue with this type of path on a standard Windows installation. For
|
||||
# instance, the following command works as intended on Windows 11 + Defender.
|
||||
#
|
||||
# PS C:> Get-Item -Path "\\?\C:\Windows"
|
||||
#
|
||||
# Directory: \\?\C:
|
||||
#
|
||||
# Mode LastWriteTime Length Name
|
||||
# ---- ------------- ------ ----
|
||||
# d----- 24/04/2026 19:15 Windows
|
||||
if ($CandidatePath.StartsWith("\\?\")) { $CandidatePath = $CandidatePath.Replace("\\?\", "") }
|
||||
|
||||
$ModifiablePaths = Get-ModifiablePath -Path $CandidatePath | Where-Object { $_ -and (-not [String]::IsNullOrEmpty($_.ModifiablePath)) }
|
||||
if ($null -eq $ModifiablePaths) { continue }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user