Page 1 of 1 1
Topic Options
#81740 - 2003-07-19 09:13 PM kix and i/o streams
Stevie Offline
Starting to like KiXtart
*****

Registered: 2002-01-09
Posts: 199
Has there been any previous suggestion (I've already looked and can't find any...which doesn't mean it doesn't exist) regarding kix and i/o streams.

Specifically, modifying kix so that it will accept either a file or a generic i/o stream. If it's able to accept a stream, then it would be trivial to provide custom encryption/obfuscation/protection for scripts.
_________________________
Stevie

Top
#81741 - 2003-07-19 09:43 PM Re: kix and i/o streams
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Yes, see for example Suggestion: Binary file operations
_________________________
There are two types of vessels, submarines and targets.

Top
#81742 - 2003-07-19 09:43 PM Re: kix and i/o streams
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Notepad and KiXtart can create and access NTFS streams. Notepad must do it from the commandline.

Create a file with notepad.exe called "test.txt". add some text and save.

Then use the line below to create a stream. Add some text and save.

Check your directory there will be only test.txt. Reopen the file and the stream with notepad to verify their existence.
code:
notepad test.txt:stream1.txt  

Now run this code with KiXtart.

KiXtart 4.02 can read streams.
code:
IF Open(3, "c:\data\scripts\test.txt:stream1.txt") = 0
$x = ReadLine(3)
WHILE @ERROR = 0
? "Line read: [" + $x + "]"
$x = ReadLine(3)
LOOP
ENDIF



[ 19. July 2003, 22:18: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#81743 - 2003-07-19 09:49 PM Re: kix and i/o streams
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Kixtart creating, writing, and reading an NTFS stream.

IF Open(3, "c:\data\scripts\test.txt:stream1.txt") = 0
$x = ReadLine(3)
WHILE @ERROR = 0
? "Line read: [" + $x + "]"
$x = ReadLine(3)
LOOP
ENDIF
$rc=close (3)
?
IF Open(5, "c:\data\scripts\test.txt:stream5.txt",5) = 0
WriteLine(5, "This is stream5"+@CRLF)
else
? "Failed to open stream"
ENDIF
$rc=close (5)
IF Open(3, "c:\data\scripts\test.txt:stream5.txt") = 0
$x = ReadLine(3)
WHILE @ERROR = 0
? "Line read: [" + $x + "]"
$x = ReadLine(3)
LOOP
ENDIF
$rc=close (3)


KiXtart is not required to have the ".txt" as part of the stream name, but if you want to verify the stream with notepad.exe you will have to include the ".txt".

[ 19. July 2003, 22:19: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#81744 - 2003-07-20 01:35 AM Re: kix and i/o streams
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
More info about using streams.

quote:
Note that files with single-character names cannot contain alternate streams because these file names are treated by Windows as drive letters. When a drive letter is specified with a relative path, a colon separates the drive letter from the path. When there is an ambiguity about whether a single-character name is a drive letter or a file name, Windows will assume a drive letter if the string following the colon is a valid path, and a file name otherwise. This will occur regardless of whether the drive letter or file name is valid.


_________________________
Home page: http://www.kixhelp.com/hb/

Top
#81745 - 2003-07-22 10:58 AM Re: kix and i/o streams
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Ok, for anyone else (like me) who saw this and got interested - NTFS streams are not the answer.

When Stevie is asking about reading from IO streams, what he is specifically referring to is what in the *nix world would be stdin. This is normally attached to keyboard input but can be attched to the output of another program where the operating system supports pipes.

NTFS streams are not IO streams as most people understand them They are simply named file sections. You cannot use them to communicate between processes, or "pipe" information.

Note, KiXtart can read piped input using GetS, but it is kludgy and there is no way to reconnect input back to the keyboard.

Some ways of achieving this:
  • Support for named pipes would be interesting, however these are not fully supported under Win9x.
  • Anonymous pipes are another option. These are supported by (later) versions of Win9x, but passing the handle may be tricky.
  • KiXtart could read the script from stdin, and when the stream terminates reconnect stdin to the keyboard.
  • The decrypting program could pass the script directly to KiXtart via COM automation.

Top
#81746 - 2003-07-23 08:21 PM Re: kix and i/o streams
Stevie Offline
Starting to like KiXtart
*****

Registered: 2002-01-09
Posts: 199
quote:
KiXtart could read the script from stdin, and when the stream terminates reconnect stdin to the keyboard.
That sounds most appealing to me. It's also the most straightforward.

Before I get all carried away, is this even something Ruud would consider adding?
_________________________
Stevie

Top
#81747 - 2003-07-23 08:47 PM Re: kix and i/o streams
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Forgive for being thick. what would be the application for:
quote:
KiXtart could read the script from stdin, and when the stream terminates reconnect stdin to the keyboard.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#81748 - 2003-07-23 10:55 PM Re: kix and i/o streams
Stevie Offline
Starting to like KiXtart
*****

Registered: 2002-01-09
Posts: 199
The bottom line on this is that it would allow you to send a script to kix32 without that script needing to be a file.

A possible usage of this would be to have an encrypted script file decrypted by some external process (kixcrypt perhaps??) and then sent directly to kix without having to create an unencrypted version of the file.

It would make script encryption/obfuscation even more secure.

Another possible use would be to dynamically create a script and spawn it via a second instance of kix without writing it out to a file first.
_________________________
Stevie

Top
Page 1 of 1 1


Moderator:  Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 514 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.209 seconds in which 0.036 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org