Create a gist now

Instantly share code, notes, and snippets.

def write_file
begin
File.open("/test", "w+") do |f|
f.write("hello!\n")
f.close
end
puts "wrote test file"
rescue Errno::EACCES
puts "could not write test file"
end
end
puts "ok, set uid to nobody"
Process.euid = 65534
puts "going to try to write to / now..."
write_file
puts "restoring back to root"
Process.euid = 0
puts "now writing file"
write_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment