Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

i have a doubt about protection of Python Code. I'm not meaning just "Obfuscation", so, i've read a lot of topics about this subject, and i choose to put my application behind a web interface. So, it's done.

I execute my code trough a CGI script behind a Web interface, so, i don't need to send my .py file anymore.

But, i still have concern about protection.

Is there some well known manual where i can find information about Apache and how to protect my home directory against "undesirable downloads"?? So, my .py file (real code) is not acessed directly, but, it's there. So, how can i protect it in a efficient way, considering that i'm using a Apache2 server?

share|improve this question

1 Answer 1

If you want to be 99,9% sure that your python files can't be downloaded put them outside the document tree of the web-server and make sure that your scripts are secure (check links below):

Local File Inclusion Explained

Remote file Inclusion Explained

Don't forget to set correct file permissions for your scripts. You might also want to disable some database functions like LOAD_FILE(), which is typically used only by hackers.

share|improve this answer
    
Thanks a lot friend. But, i saw the most part of these articles are about PHP. Do you know something about sintax in Python to implement this kind of security level?? –  StarkBR Nov 7 '12 at 16:20
    
Same rule goes for every language: don't trust user-supplied data - if user-supplied data is not sufficiently sanitized, local and remote users might be able to execute sql queries, shell commands, read your files, etc. Make sure to check all your code that is using user-supplied data. –  FINESEC Nov 7 '12 at 18:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.