Created
February 3, 2022 18:07
-
-
Save diyinfosec/78a714edfd6965cf404844cae8786278 to your computer and use it in GitHub Desktop.
Testing the number of possible Alternate Data Streams for a file in NTFS.
This file contains 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
#- Iterate over the maximum size of Attribute ID | |
for($i=1; $i -lt 65536; $i++) | |
{ | |
#- This file must already exist. Additional hardlinks will be created for this file. | |
$original_file_name="file.txt"; | |
#- Testing the upper limit for ADS creation, breaking off once there is an non-terminating error [Set-Content : Could not open the alternate data stream ‘<stream_name>’ of the file] | |
#- Non-terminating errors are not handled using try/catch. To force a non-terminating error to be caught we use "-ErrorAction Stop" | |
try | |
{ | |
#- Creating ADS for a file | |
Set-Content -Path 'myfile.txt' -Stream $i -Value 'test'; | |
} | |
catch | |
{ | |
Write-Error ""; | |
Write-Output "Error occured when trying to create ADS number $i"; | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment