Eevee Jail - 5
#!/usr/bin/env ruby
ALLOWED_COMMANDS = ["ls"]
def sanitize_input(input)
forbidden_words = %w[flag eval system read exec irb puts dir]
forbidden_pattern = /\b(?:#{forbidden_words.join('|')})\b/
if input.match(/[&|<>$`]/) || input.match(forbidden_pattern)
return false
end
true
end
def execute_command(cmd)
if ALLOWED_COMMANDS.include?(cmd.split.first)
system(cmd)
else
puts "Command not allowed!"
end
end
puts "========================\n"
puts "= Eevee's Jail 5 =\n"
puts "========================\n"
while true
print "[+] > "
input = gets.chomp
unless sanitize_input(input)
puts "Invalid characters detected!"
next
end
if input.start_with?("ruby:")
begin
eval(input[5..])
rescue Exception => e
puts "Error: #{e.message}"
end
next
end
execute_command(input)
endLast updated