Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save shekkbuilder/878982b6ccd535dfd80b09dd01eab746 to your computer and use it in GitHub Desktop.

Select an option

Save shekkbuilder/878982b6ccd535dfd80b09dd01eab746 to your computer and use it in GitHub Desktop.
Violent Ruby: Streaming REST API Unix Password Cracker
require 'json'
require 'sinatra'
require 'violent_ruby'
post '/crack_passwords' do
content_type :json
config = {
file: params['file'][:tempfile],
dictionary: params['dictionary'][:tempfile]
}
stream do |out|
ViolentRuby::UnixPasswordCracker.new(config).crack do |result|
out << result.to_json + "\n"
end
out << { completed: true }.to_json + "\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment