Skip to content

Instantly share code, notes, and snippets.

@chriselgee
Last active April 15, 2024 09:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriselgee/bf41951d0b51d0ef9d2504a36921cd13 to your computer and use it in GitHub Desktop.
Save chriselgee/bf41951d0b51d0ef9d2504a36921cd13 to your computer and use it in GitHub Desktop.
Finding and reading alternate data streams (ADS) with PowerShell on an NTFS partition

To find all streams within file.txt: Get-Item .\file.txt -Stream *

PSPath        : Microsoft.PowerShell.Core\FileSystem::C:\file.txt::$DATA
PSParentPath  : Microsoft.PowerShell.Core\FileSystem::C:\
PSChildName   : file.txt::$DATA
PSDrive       : C
PSProvider    : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : False
FileName      : C:\file.txt
Stream        : :$DATA
Length        : 176

PSPath        : Microsoft.PowerShell.Core\FileSystem::C:\file.txt:Zone.Identifier
PSParentPath  : Microsoft.PowerShell.Core\FileSystem::C:\
PSChildName   : file.txt:Zone.Identifier
PSDrive       : C
PSProvider    : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : False
FileName      : C:\file.txt
Stream        : Zone.Identifier
Length        : 104

We can then view that second stream: Get-Content .\file.txt:Zone.Identifier

[ZoneTransfer]
ZoneId=3
ReferrerUrl=http://10.10.1.15:8000/
HostUrl=http://10.10.1.15:8000/file.txt

Delete the stream with: Remove-Item .\file.txt -Stream Zone.Identifier

Add other streams with: Set-Content .\file.txt:Dank.Memes -Value "All your base"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment