Start process, hide arguments from ps

I have a Python script that interacts with the API. The script is launched from the PHP page. I wrote both scripts, so I can change the code anyway.

Python script requires username and password to interact with the API. My first wish is to pass them to Python as CLI arguments:

<?php
exec('python someScript.py AzureDiamond hunter2');
?>

However, everyone can see the credentials through ps:

$ ps | grep someScript
1000     23295  2.0  0.2 116852  9252 pts/0    S+   15:47   0:00 python someScript.py AzureDiamond hunter2

The alternatives I am considering is writing the data to a text file or sqlite database and then deleting it. Are there any better ideas? The limitation with the sqlite approach is that this needs to be done in a fairly portable way (phpFox plugin), and most budget web hosts do not support the module sqlite3.

+5
4

, PHP, Python script.

+1

- , . MyProxy - . MyProxy , , - , .

http://grid.ncsa.illinois.edu/myproxy/

+1

stdin python , , php:

<?php
$handle = popen("/bin/python /var/www/someScript.py", "w");
// write username and password to $handle (e.g. newline separated)
?>

, , ( /proc/nn/fd/ 0?), , , , .

+1

Looking at the problem from a different angle, you can solve it by hiding the simple characters passed to exec (). Do you consider using any cryptographic library to hide plaintext from the sender and decrypt it in the receiver? Just a thought.

0
source

All Articles