Skip to content

Instantly share code, notes, and snippets.

@AndrewVos
Created September 24, 2014 22:02
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 AndrewVos/b99e866048ca319147fa to your computer and use it in GitHub Desktop.
Save AndrewVos/b99e866048ca319147fa to your computer and use it in GitHub Desktop.
bash-vulnerability
# ip addresses
servers = [
"1.1.1.1"
]
user = "ubuntu"
servers.each do |server|
puts server
system "scp -q -p test-for-vulnerability #{user}@#{server}:~"
vulnerable = `ssh #{user}@#{server} /home/#{user}/test-for-vulnerability`.include?("vulnerable")
if vulnerable
puts "VULNERABLE!"
system "ssh ubuntu@#{server} 'bash --version |head -n 1'"
system "ssh ubuntu@#{server} 'sudo apt-get update -y && sudo apt-get -y install bash'"
else
puts "NOT VULNERABLE!"
end
puts
end
#!/bin/bash
env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
@AndrewVos
Copy link
Author

Notes:

  • This will not work for servers where you login as root.
  • You'll need to ssh-add all your keys.

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