python - Simple explanation of security issues related to input() vs raw_input() -


i reading python 2.7 tutorial , they're going on raw_input(), , mentions that:

the input() function try convert things enter if python code, has security problems should avoid it.

i tried googling explanations this, still bit unclear me; what's simple explanation of alleged inherent security issues input() vs raw_input() ?

the input() function in python 2.x evaluates things before returning.

so example can take @ -

>>> input("enter : ") enter : exit() 

this cause program exit (as evaluate exit()).

another example -

>>> input("enter else :") enter else :__import__("os").listdir('.') ['.gtkrc-1.2-gnome2', ...] 

this list out contents of current directory , can use functions such os.chdir() , os.remove() , os.removedirs() , os.rmdir()


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -