Skip to content

Instantly share code, notes, and snippets.

@Yardboy
Created January 22, 2014 22:48
Show Gist options
  • Save Yardboy/8569010 to your computer and use it in GitHub Desktop.
Save Yardboy/8569010 to your computer and use it in GitHub Desktop.
CTF 2014 Level 0
#!/usr/bin/env ruby
# Our test cases will always use the same dictionary file (with SHA1
# 6b898d7c48630be05b72b3ae07c5be6617f90d8e). Running `test/harness`
# will automatically download this dictionary for you if you don't
# have it already.
path = ARGV.length > 0 ? ARGV[0] : '/usr/share/dict/words'
entries = File.read(path).split("\n")
contents = $stdin.read
checker = entries & contents.gsub(/[^ \n]+/).map(&:downcase)
output = contents.gsub(/[^ \n]+/) do |word|
#if entries.include?(word.downcase)
if checker.include?(word.downcase)
word
else
"<#{word}>"
end
end
print output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment