I've read some documentations about Alternate Data Streams
and I'm thinking about using them in my own projects. However there is so much unknown knowledge and open questions that I still have before I decide to use them. That's why I made this question list:
- How do you enum Streams without the Sysinternals tool
streams
? - Does a stream affect the "Host" File's MD5 Value?
- What happens if I copy/cut the "Host" File to another (NTFS) Path? Do the streams copy/cut themselves too?
- What happens if I copy/cut the "Host" File to another Path that is NOT NTFS?
- Is it possible to have another Stream in an existing stream?
- Since you will have an actual filehandle for each stream, is it possible to change a stream's attributes?
- Can I use the
LoadLibrary
API to load a DLL from a stream? - Is it possible to execute (e.g.
ShellExecute
) a stream? - What are the advantages/benefits/disadvantages using
Alternate Data Streams
? - What do I have to be cautious about if I use
Alternate Data Streams
?
I'm looking forward to your answers/infos/summarys. The preferable language is Delphi but any other language will do too, as long as it uses the WinAPI
.
Many of your questions are covered here: http://flexhex.com/docs/articles/alternate-streams.phtml
Enumeration: Use
NtQueryInformationFile
, see link. Beginning with Windows Vista, you can also enumerate streams on the commandline usingdir /r
.Checksums: As you usually open only the unnamed data stream when you access a file by name, only the contents of this stream are used when calculating checksums.
Copying to NTFS: Windows Explorer and the copy commandline utility copy all streams.
Copying to other FS: The alternate data streams are lost.
Nested streams: No, a file simply consists of a list of streams, they cannot be nested.
Attributes: Some attributes are file-based, some (encrypted, compressed, sparse) are stream-based.
LoadLibrary
seems to work on alternate data streams.ShellExecute
on an ADS failed withERROR_FILE_NOT_FOUND
(2) on my computer.Note that is is theoretically possible to run an ADS from the commandline:
type calc.exe > dummy.txt:calc
wmic process call create "dummy.txt:calc"
ADS are useful to store some non-critical information associated with a file. For example, executable files downloaded from the internet will have an ADS which causes Explorer to display a warning before the file is executed.
See link. In particular, don't use them for critical data.