Skip to content

Instantly share code, notes, and snippets.

@amorphid
Last active December 20, 2016 16:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amorphid/db037f03246962959b6a034b2ca3ef1b to your computer and use it in GitHub Desktop.
Save amorphid/db037f03246962959b6a034b2ca3ef1b to your computer and use it in GitHub Desktop.
Leaky Script
#!/usr/bin/env ruby
# demo that command line environment variables are leaky
#
# 1. copy this gist into a file called leady_script.rb
# 2. make it executable => $ chmod +x leady_script.rb
# 3. run it w/ an environment variable => $ SECRET="My PIN code is 12345" ./leaky_script.rb
# 4. in another window, find pid for script => $ ps -ef | grep leaky_script
# 5. find environment variables:
# * On a mac => $ ps eww <pid>
# * On Linux => $ cat /proc/<pid>/environ
loop do
puts "Your $SECRET is safe with me!"
sleep 5
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment