How would I go about securly passing information between scripts?

Started by therkilt, May 13, 2015, 09:25:30 AM

Previous topic - Next topic

therkilt

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.

JTaylor

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

td

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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

snowsnowsnow

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.


td

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 one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

snowsnowsnow

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.

td

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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

therkilt

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).

td

 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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade