Created
November 6, 2013 23:42
-
-
Save lian/7346290 to your computer and use it in GitHub Desktop.
ruby-pop3-auth.rb
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
require 'socket' | |
serv = TCPServer.new("127.0.0.1", 110) | |
s = serv.accept | |
s.puts "+OK POP3 server ready" | |
while line = s.gets.strip | |
case line | |
when "CAPA" | |
s.puts("SASL PLAIN\n.") | |
when "AUTH PLAIN" | |
s.puts("+OK") | |
when /=$/ | |
p Hash[ [:username, :password].zip(line.unpack("m0")[0].split("\x00")[1..-1]) ] | |
s.close | |
exit | |
else | |
p [:unkown, line] | |
s.close | |
exit | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment