def Connect(server,port,username,password)
puts " try ... #{server}:#{port} - #{username}:#{password}"
Net::POP3.enable_ssl(OpenSSL::SSL::VERIFY_NONE) # enable SSL default port 995
auth = Net::POP3.start(server, port, username, password)
rescue SocketError, Timeout::Error, OpenSSL::SSL::SSLError,EOFError
puts "Connect Error: #{$!}"
rescue Errno::ECONNREFUSED, Errno::ECONNRESET
puts "Connect Error: #{$!}"
sleep 0.60
rescue Net::POPAuthenticationError
puts "Connect Error: #{$!}"
else
auth.finish
return username,password
end
quarta-feira, 22 de junho de 2011
Ruby code for POP3 auth
Simple Ruby code for pop3 auth (Use at your own risk)
Marcadores:
auth,
brute force,
login,
pop3,
ruby
terça-feira, 14 de junho de 2011
Simple Ruby Credit Card Validator
This code below is a ruby implementation of Luhn Algorithm to validate credit cards numbers.
#!/usr/bin/env ruby
def is_valid(number)
x = number.split("")
i = 0
a = Array.new()
while (i < x.size) do
a.push(x[i].to_i*2)
i = i + 1
a.push(x[i].to_i)
i = i + 1
end
if (a.join("").split("").inject(0){|sum,item| sum + item.to_i} % 10 == 0)
return true
else
return false
end
end
puts is_valid(ARGV[0])
Marcadores:
code,
credit card,
Luhn algorithm,
ruby,
validator
Assinar:
Postagens (Atom)