Hello all,
I have just released a new library for Ruby:
Turing is implementation of Captcha (Completely Automated Public Turing-Test
to Tell Computers and Humans Apart) that is both easy to use and easy to
customize/extend.
It makes use of the excellent Ruby/GD2 gem released by Robert Leslie.
At this time there are three levels of abstraction you can use:
* Turing::Image - Simple obfuscated image generator with plugin design.
ti = Turing::Image.new(:width => 280, :height => 115)
ti.generate(File.join(Dir.getwd, 'a.jpg'), "randomword")
* Turing::Challenge: Captcha challenge generator and verifier.
tc = Turing::Challenge.new(:store => 'store', :outdir => '.')
c = tc.generate_challenge
system("xv", c.file)
puts "Enter solution:"
r = $stdin.gets.chomp
if tc.valid_answer?(c.id, r)
puts "That's right."
else
puts "I don't think so."
end
* Turing::CGIHandler: Simple Turing::Challenge wrapper designed to run as CGI.
tcgi_config = {
:imagepath => "/imgs",
:outdir => '/home/wejn/ap/htdocs/imgs',
:store => '/home/wejn/ap/data/turing.pstore',
:redirect_to => 'http://localhost:8000/secured/',
}
tcgi_config[:on_success] = proc do
out = {}
out[:headers] = {
"cookie" => CGI::Cookie.new({
'name' => 'turing_passed',
'value' => 'true',
'path' => '/',
'expires' => Time.now + 3600*24,
}),
"dude" => "you_rock!",
}
out
end
Turing::CGIHandler.new(tcgi_config).handle
You can find (r)doc, gem and samples via the site mentioned above.
Rg,
Michal S.
PS: This is my cry for help: I'm looking for volunteer to help me
perform end-user (and performance) test of Apache2 drop-in replacement
for mod_auth that prevents (among other things) dictionary/bruteforce
attacks against credentials. If it sounds like fun, please check out
details: http://wejn.org/ta-rt.html
···
--
# Michal Safranek, email:
a=(("a".."z").to_a+["@","."]);p(("%b"%[0x645bbb83a6a496]
).scan(/...../).map{|x|a[Integer("0b"+x)]}.join.reverse)