require 'net/http' print "Extract file -- http://tinyurl.com/" target = gets.chomp raise "No target found." if target == "" Net::HTTP.start("forwarding.tinyurl.com") do |http| resp = http.get("/redirect.php?num=#{target}") if resp.code == "302" then puts "Retrieving data..." resp['location'] =~ %r{http://(\w*)} bytes = $1.split(/(..)/) bytes.compact! byte_string = bytes.pack("H*"*bytes.length) puts "Creating file #{target}..." File.open(target, 'wb') do |f| f << byte_string end else raise "HTTP #{resp.code} received. Something is fux0red somewhere..." end puts "Done!" end