Skip to content

Instantly share code, notes, and snippets.

@picatz
Created April 16, 2017 17:46
Show Gist options
  • Save picatz/c034ca7164fe3b4808613381d3579a3c to your computer and use it in GitHub Desktop.
Save picatz/c034ca7164fe3b4808613381d3579a3c 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