Page 1 of 1

Appending extra data to Files

Posted: Mon Feb 19, 2007 5:58 pm
by wayne-c
Code updated for 5.20+

Requires NTFS 5 File-System (Windows 2000 and later).

Code: Select all

;
;
; ---Important:
; This example requires NTFS 5 Filesystem (Windows 2000 and later)
;

;
; Create test file (12 bytes)
;
If CreateFile(1, "Test.txt")
  WriteString(1, "Hello World!", #PB_Ascii)
  CloseFile(1)
  Debug FileSize("Test.txt")
EndIf

;
; Append some extra information to the file
; The data is written to a "stream".
; You can have multiple streams with different names for every file.
; Just add the name of your stream after the colon.
;
If OpenFile(1, "Test.txt:ExtraData")
  WriteString(1, "Hello Extra Data!")
  CloseFile(1)
EndIf

;
; The file size is STILL 12 bytes, but the extra data is there...
;
Debug FileSize("Test.txt")

;
; ...so read the extra data from the file:
;
If ReadFile(1, "Test.txt:ExtraData")
  Debug ReadString(1, #PB_Ascii)
  CloseFile(1)
EndIf

;
; Remove the additional data from the file.
;
DeleteFile_("Test.txt:ExtraData")

Posted: Mon Feb 19, 2007 6:45 pm
by ricardo
Very interesting.

Where is this data stored?

Posted: Mon Feb 19, 2007 7:32 pm
by Henrik
ricardo wrote:Very interesting.

Where is this data stored?
Hidden Threat: Alternate Data Streams
http://www.windowsecurity.com/articles/ ... reams.html

Windows NTFS Alternate Data Streams
http://www.securityfocus.com/infocus/1822

Best regards
Henrik

Posted: Mon Feb 19, 2007 7:55 pm
by Num3
Darn... Now you know :oops:

Welcome to one of windows biggest black holes :twisted:

That's why i still use FAT32 in my data and OS partitions ;)

Posted: Mon Feb 19, 2007 8:05 pm
by Henrik
Num3 wrote: That's why i still use FAT32 in my data and OS partitions ;)
Me too :D

Well btw. you can use this littel commandline tool to list-ADS on your NTFS partitions.

http://www.heysoft.de/Frames/f_sw_la_en.htm

Best regrads
Henrik

Posted: Mon Feb 19, 2007 11:28 pm
by ricardo
Well, this could have some interesting uses, like use this feature to protect more your apps.

Posted: Tue Feb 20, 2007 2:19 am
by SFSxOI
Henrik wrote:
ricardo wrote:Very interesting.

Where is this data stored?
Hidden Threat: Alternate Data Streams
http://www.windowsecurity.com/articles/ ... reams.html

Windows NTFS Alternate Data Streams
http://www.securityfocus.com/infocus/1822

Best regards
Henrik
no threat for Vista

Posted: Tue Feb 20, 2007 3:43 pm
by Psychophanta
Num3 wrote:That's why i still use FAT32 in my data and OS partitions ;)
1UP :wink:
Same here.
hehe, I have had several bad experiences with NTFS 5.

Posted: Tue Feb 20, 2007 9:12 pm
by PB
> That's why i still use FAT32 in my data and OS partitions

So how do you handle files larger than 4 GB (ISOs, DVDs, etc)?
I'd find it very inconvenient to be limited to 4 GB file sizes, not
to mention the lack of security too.