WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: therkilt on May 13, 2015, 09:25:30 AM

Title: How would I go about securly passing information between scripts?
Post by: therkilt on May 13, 2015, 09:25:30 AM
I would like to create a service which would be running with system privileges and I would like to be able to pass information from another script to the service in a secure manor meaning that information cannot easily come from another source for the service to act on, is this possible and if so can you give me an idea of where to start?  Thanks.
Title: Re: How would I go about securly passing information between scripts?
Post by: JTaylor on May 13, 2015, 09:39:27 AM
Not a lot to go on so hard to offer specifics but in general you could pass some sort of encrypted key along with the data for verification.  As long as you keep your key(s) secure that should do the job.   

Jim
Title: Re: How would I go about securly passing information between scripts?
Post by: td on May 13, 2015, 09:55:47 AM
If you need learn about passing information between scripts running in different processes then consider:

The 'secure' part depends to a great extent to how secure you want the information to be and how you decide to pass the information between script process.
Title: Re: How would I go about securly passing information between scripts?
Post by: snowsnowsnow on May 13, 2015, 02:13:41 PM
QuoteUsing Snow++'s shared memory UDFs...

Saw my name, had to comment...

I wish I could take credit, but I just found them somewhere in the Tech DB.  As far as I can tell, original author unknown.

Also, as much as I would have liked to have used those routines somewhere along the way, as far as I know, I never have.  The idea is cool (as it is under Unix), but the application just never seems to quite come up.

P.S.  I mention Unix here, because the same thing applies there.  Unix has had shared memory for decades now (since the early 80s), and I've always been fascinated by it, but have just never quite gotten around to actually using it in my day-to-day programming.

Title: Re: How would I go about securly passing information between scripts?
Post by: td on May 13, 2015, 09:19:20 PM
My apologies.  I recalled your advocating of the idea in the past and assumed you were the author. I should know better than to assume...
Title: Re: How would I go about securly passing information between scripts?
Post by: snowsnowsnow on May 14, 2015, 03:37:51 AM
Quote from: td on May 13, 2015, 09:19:20 PM
My apologies.  I recalled your advocating of the idea in the past and assumed you were the author. I should know better than to assume...

No problem.

I have certainly advocated for it - it seems a nice solution to the eternal "So, I've created this thing, but how do I make sure that it gets deleted if my program crashes/exits unexpectedly" question.  The fact that, in Windows, it just auto-magically disappears on the last close is nice.  I think I have advocated for it as a way of implementing the "How do I check to see if my script is already running" problem, although the other way (the "WinTitle" way) is easier (less code/overhead).  I suppose one might use the shared memory trick if for some reason you can't do the WinTitle trick.
Title: Re: How would I go about securly passing information between scripts?
Post by: td on May 14, 2015, 06:48:35 AM
We use memory mapped files in a couple of our extenders.  It has the advantage of efficiency in that it requires minimal code to implement and a relatively small amount of system resources when executing.
Title: Re: How would I go about securly passing information between scripts?
Post by: therkilt on May 15, 2015, 11:25:44 AM
Thanks for the suggestions.

I tried to implement the Shared memory routines which work great while running two scripts as different users however once I had one of the scripts running under the System account it seems to have partitioned memory space because the other script could not detect the shared memory and created a new memory space (which I verified by displaying the handle in both scripts).
Title: Re: How would I go about securly passing information between scripts?
Post by: td on May 15, 2015, 01:33:58 PM
 Your service and the user script are running in different sessions on newer versions of Windows so try  prepending "Global\" to the file name to create a cross session object in the kernel object space.