ASCII font patterns appear in Search engine keywords and can be pattern matched - suggest randomization

Created on 11 May 2011, about 14 years ago
Updated 11 September 2024, 10 months ago

Love the ASCII CAPTCHA and have been using it on my personal site for a while. Whilst looking at site analytics I noticed that I was getting keyword assignments from the ASCII art because of high occurrences of "d88p" and "y88b". I am using the "colossal" font which uses these strings frequently. To overcome this problem I added a string randomizer that replaces the '8' character, that is mainly used as a filler in this font, with a random character of roughly equal visual weight and shape.

I have attached a comparison image that show the original font with a randomize version below it. Here's the font specific code I used. It could be modified to work with other fonts. Just thought I would share it.

function randomize_eight($font) {
  if (is_array($font) && count($font)) {
    foreach ($font as $x => $f) {
      if (is_array($f) && count($f)) {
        foreach($f as $y => $l) {     
          $font[$x][$y] = preg_replace_callback('|8|', randomize_digit, $l);
        }
      }
    }
  }
  return $font;
}

function randomize_digit() {
  $source = '@895ESHM';
  $max = strlen($source) -1;
  return substr($source, rand(0,$max), 1);
}

// $font = randomize_eight(ASCII_art_captcha_font_colossal());

As a by-product this also strengthens the ASCII capture because the fonts are much harder to pattern match.

✨ Feature request
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States tinker

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024