Skip to content

Instantly share code, notes, and snippets.

@rchowe
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save rchowe/196e3a81ced7110456ea to your computer and use it in GitHub Desktop.

Select an option

Save rchowe/196e3a81ced7110456ea to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
#
# Run the program, then type this in when it asks for your name:
#
# os.system('say hello')
#
import os
name = eval(input('Enter your name: '))
print('Hello, {}'.format(name))
@rchowe
Copy link
Copy Markdown
Author

rchowe commented Oct 9, 2014

It can also be done without the import os line in the source if the malicious code is written as:

__import__('os').system('say hello')

The reason this can do anything is that command sent to os.system are passed directly to the shell, which can read (cat), create (touch), and remove (rm) anything on the computer that you have access to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment