Created
April 28, 2014 15:29
-
-
Save Ninjex/11375483 to your computer and use it in GitHub Desktop.
Hellbound Hackers Timed Challenge 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'mechanize' | |
require 'io/console' | |
def decrypt(str) | |
final = [] | |
for i in (0..str.length) | |
i.odd? ? final << str[i-2] : final << str[i] | |
end | |
final.delete_at(-2) if str.length.odd? | |
return final.join | |
end | |
print 'Username: ' | |
name = gets.chomp | |
print 'Password: ' | |
pass = STDIN.noecho(&:gets).chomp | |
client = Mechanize.new { |agent| agent.user_agent = 'Mechanize -- Ninjex' } | |
client.get('https://www.hellboundhackers.org/') do |page| | |
page.form_with(:action => '//www.hellboundhackers.org/') do |f| | |
f.user_name = name | |
f.user_pass = pass | |
end.click_button | |
end | |
client.get('https://www.hellboundhackers.org/challenges/timed/timed4/index.php') do |page| | |
data = page.search('td[2] div strong').to_s.split('<strong>')[7] | |
cipher = data.to_s.gsub('</strong>', '') | |
answer = decrypt(cipher) | |
page.form_with(:action => '/challenges/timed/timed4/index.php?check') {|f| f.ans = answer }.click_button | |
puts answer | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment