Skip to content

Instantly share code, notes, and snippets.

@Ninjex
Created April 28, 2014 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ninjex/11375483 to your computer and use it in GitHub Desktop.
Save Ninjex/11375483 to your computer and use it in GitHub Desktop.
Hellbound Hackers Timed Challenge 4
#!/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