Benutzername    Passwort    Autologin    
  Passwort vergessen       Registrieren  
beeForum Foren-übersicht » globetrottel
Neues Thema eröffnen   Dieses Thema ist gesperrt, du kannst keine Beiträge editieren oder beantworten. Hervorhebung entfernen


Projekt SpamBot 2.0, feat. CAPTCHA-Breaker
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen  
Autor Nachricht
pseudocode





Titel: Projekt SpamBot 2.0, feat. CAPTCHA-Breaker
Verfasst am: Sa, 30 Jun 2007, 20:14
Beitrag
Antworten mit Zitat

Projekt SpamBot 2.0
jetzt mit CAPTCHA-Breaker


"Projekt SpamBot 2.0" besteht prinzipiell aus denselben Skripten wie das ursprünglich Projekt. Die einzige Erweiterung ist die Fähigkeit des Bots, das Standard-CAPTCHA von phpBB2) zu knacken. Das ist nicht wirklich etwas neues, hier z.B. werden die meisten, häufig verwendeten CAPTCHA analysiert und viele davon können automatisch gelöst werden.
Was eine kleine Neuheit darstellt, ist die Tatsache, dass mein Skript 100% der CAPTCHA lösen kann, sofern es sich dabei um den Standard handelt, der mit phpBB2 vorinstalliert ist. Neu ist meines Wissens auch der Umstand, dass die Funktionsweise des Lösungsskriptes beschrieben wird. Mehr dazu weiter unten in dieser Nachricht, zuvor kurz die Zahlen und Fakten des erneuten Einsatzes von "Projekt SpamBot".

Spider: Da MSN Search eine so dankbare Angriffsfläche für das spidern von URLs bietet, wurde dieses Mal auch wieder hier nach phpBB-URLs gesucht.
Etwa 50.000 Adressen wurden anhand von ca. 180 Suchbegriffen gefunden. Diese Adressen wurden zusätzlich erweitert und die Pfade "phpBB", "forum" und ähnliche, um auf Foren erreichen zu können, die z.B. hinter einer Portalseite liegen. Zusammen mit den früheren URL-Listen kamen insgesamt fast 500.000 URLs (491.187) zusammen, die auf die phpBB-Software untersucht wurden.
Das Ergebnis: 42.680 phpBB-Foren wurden als potentielle "Angriffsziele" gefunden.

Wie gehabt wurde der "Registerbot" eingesetzt, dieses Mal unter Verwendung der automatischen CAPTCHA-Lösung (s.u.), auch der "Confirmbot" (zur automatischen Bestätigung der per E-Mail verschickten Aktivierungslinks) blieb unverändert.
Insgesamt erhielt ich nach Durchlauf aller Skripte 14.247 gültige Zugangsdaten für phpBB-Foren! (Abgezogen werden müssen natürlich noch die Foren, die mit Admin-Aktivierung arbeiten und die falschen Accounts garnicht erst freischalten, dabei dürfte es sich vermutlich aber um eine Minderheit handeln, die Zahlen werden auf jeden Fall nicht nachgehalten.)
Nicht erfolgreich war das Projekt bei 5.516 URLs, die restlichen URLs (immerhin die Hälfte aller untersuchten Seiten) waren nicht erreichbar oder keine Standard-Seiten, so dass keine Registrierung abgeschickt werden konnte. Das Verhältnis von erfolgreichen zu erfolglosen Registrierungen hat sich gegenüber den ursprünglichen Skripten durch die Einbeziehung der automatisch CAPTCHA-Lösung also deutlich verbessert (damals lag das Verhältnis ungefähr bei 1:1, jetzt bei fast 3:1).

Mit diesen Daten wurde der "Postbot" losgeschickt und in insgesamt über 2.000 Foren automatische Nachrichten gepostet. Der Inhalt der Nachricht wurde dieses Mal leicht verändert, um die Glaubwürdigkeit der Nachricht zu erhöhen, da beim letzten Durchlauf viele Forenbetreiber den Text für eine weitere geschickte Masche hielten, doch wieder nur "echten" Spam zu verbreiten und die Benutzer auf eine dubiose Seite zu locken.


Noch ein paar Worte zum "Humanizer":
Auch der "Humanizer" konnte (in der Standard-Version) von "Projekt SpamBot" auf einfachste Weise geknackt werden. Der "Humanizer" baut in die Registrierungsseite die Frage ein "Are you human?". Wird (per Radiobutton) nicht mit "ja" geantwortet, ist die Registrierung nicht möglich.
Natürlich steht im Quellcode nicht einfach etwas wie "human=yes" sondern ein MD5-Code, der sich bei jeder Registrierung ändert, etwa in der Art:

Code:
<input type="radio" name="dd41255da6911f91947c56658af6d1e1" value="dd41255da6911f91947c56658af6d1e1"  />

Da sonst aber kein Variablennamen im Quellcode vorkommt, der immer exakt 32 Zeichen hat, muss nur nach einem Radionbutton gesucht werden, der einen solchen Namen aufweist. Der folgende Code ist auszulesen und als Variable wie auch als Wert mit der Registrierung zu übergeben. Damit ist der "Humanizer" wirkungslos.
(Allerdings nur die Standard-Version, es gibt mittlerweile bessere Versionen, die "richtige" Fragen stellen und eine Texteingabe als Antwort fordern.)






Das phpBB-Standard-CAPTCHA

Vorab gibt es eins festzuhalten: das Standard-CAPTCHA von phpBB ist unsicher. Es weist eklatante Mängel auf, und für findige Programmierer ist es ein Leichtes, das CAPTCHA zu knacken, der "Schutzwert" für ein phpBB-Forum, das das Standard-CAPTCHA verwendet, geht gegen Null.



Hier die Gründe, warum das CAPTCHA keinen Schutz bietet:
  1. Es wird immer derselbe Schriftsatz verwendet, zusätzlich ist die Anzahl der verschiedenen Zeichen beschränkt, da nur Grossbuchstaben und Zahlen auftauchen.
    Je geringer die Anzahl der verschiedenen Zeichen, desto leichter ist ein CAPTCHA zu knacken, da sich der Erkennungsalgorithmus nur auf die Analyse einiger weniger Zeichen beschränken muss. Die Verwendung verschiedener Schriftsätze sowie von Sonderzeichen und Kleinbuchstaben würde die Entschlüsselung des CAPTCHA um einiges erschweren. Auch könnten grafische Symbole eingesetzt werden, es gibt z.B. CAPTCHA, auf denen man die Anzahl der "Pfeile" zählen muss.

  2. Die Zeichen auf dem CAPTCHA werden nicht mit Verzerrung oder Rotation behandelt.
    Verzerrte oder rotierte Zeichen sind für einen Automatismus schwerer zu erkennen als die immer aufrecht stehenden Buchstaben des phpBB-CAPTCHA. Es gibt einfache Methoden, das komplette CAPTCHA mit einer wellenförmigen Verzerrung zu belegen oder die einzelnen Zeichen (jeweils anders) rotieren zu lassen, leider werden diese Methoden hier nicht angewendet.

  3. Die Zeichen überlappen sich nicht und werden nicht durch "Nonsens-Zeichen" gestört.
    Dies ist der Hauptmakel im phpBB-CAPTCHA: dadurch, dass sich die Zeichen nicht überlappen, können die einzelnen Buchstaben und Zahlen sehr einfach voneinander getrennt und dann einzeln analysiert werden. Es gibt keinerlei "Störer" auf dem CAPTCHA, z.B. keine geometrischen Formen, die die Zeichen überlagern oder Linien, die sie schneiden.
    Der leichte vertikale Versatz der einzelnen Buchstaben trägt nicht zur Sicherheit des CAPTCHA bei, da man die vereinzelten Zeichen sehr einfach oben und unten beschneiden kann, so dass der Versatz überhaupt nicht zum Tragen kommt.

  4. Die Anzahl der Zeichen ist immer gleich. Ebenso variiert die Grösse der Zeichen nicht.
    Die Anzahl der Zeichen im Standard-CAPTCHA von phpBB ist auf "6" eingestellt, was die Lösung zusätzlich vereinfacht, da exakt bekannt ist, nach wievielen Zeichen man suchen muss. Findet der Algorithmus eine abweichende Anzahl von Zeichen, kann der Versuch einfach wiederholt werden, indem ein neues Bild (mit denselben Zeichen) angefordert wird.
    Auch hier offenbart sich eine extreme Schwäche des CAPTCHA-Systems von phpBB: es kann beliebig oft dasselbe CAPTCHA-Bild erneut angefordert werden. Die Zeichen auf dem Bild bleiben dieselben, aber die Position und das "grafische Rauschen" verändert sich. Vermutet also das "Lösungsprogramm" bei einem Zeichen, dass es sich dabei um zwei handelt, weil z.B. zufällig eine sehr helle Linie das Zeichen durchschneidet und werden daher sieben Zeichen gefunden, kann das Bild einfach neu angefordert (und neu analysiert) werden. Durch dieses Verhalten von phpBB konnte die Lösungsquote des Algorithmus auf 100% gesteigert werden! Da die Anzahl der Registrierungsversuche zwar beschränkt ist, nicht aber die Anzahl der Versuche, die nur das CAPTCHA-Bild (statt der gesamten Registrierungsseite) lädt, kann hier solange probiert werden, bis das CAPTCHA gelöst ist.
    Auch die gleichbleibende Grösse der Zeichen ist ein Nachteil: wird ein Zeichen falsch beschnitten, kann das über die Grösse des resultierenden "Teilzeichens" sehr einfach festgestellt und ein neues CAPTCHA angefordert werden.

  5. Die Farben des CAPTCHA sind immer gleich verteilt, die Farbpalette ist sehr beschränkt.
    Die Zeichen auf dem Standard-CAPTCHA sind immer dunkel, der Hintergrund ist immer hell, was die Berechnung der Unterscheidung zwischen zu lösenden Zeichen und überflüssigem Hintergrund ("Rauschen") sehr vereinfacht. Ein buntes CAPTCHA mit wechselnden Farben (auch zwischen Zeichen und Hintergrund) hätte die Lösung sehr erschwert.




Der Algorithmus


Einlesen der Registrierungsseite und des CAPTCHA

Zunächst wird die Registrierungsseite des "Opfer-Forums" ausgelesen und die URL des CAPTCHA extrahiert. Diese URL hat das Muster:

Code:
FORUM_URL/profile.php?mode=confirm&id=CAPTCHA_ID

und kann (s.o.) beliebig oft aufgerufen werden. Erhält man nach dem 1. Aufruf z.B. dieses Bild:


kann das Bild bei erneutem Aufruf derselben URL schon so aussehen:


Sollte ein Zeichen nicht eindeutig identifiziert werden können, sind so beliebig viele Versuche möglich, das CAPTCHA in einer besser lesbaren Form zu erhalten.
Ist das Einlesen des Bildes in den Speicher erfolgt, kann die Analyse beginnen.

Analyse des CAPTCHA

Der Algorithmus geht jetzt das Bild Punkt für Punkt durch und errechnet die Helligkeit eines jeden Bildpunkts. Da das Standard-CAPTCHA von phpBB nur Grautöne verwendet, ist das (z.B. in PHP) ziemlich einfach zu bewerkstelligen:

Code:
$color = imagecolorat($im, $j, $i);
$blue = 0x0000ff & $color;
$green = 0x00ff00 & $color;
$green = $green >> 8;
$red =0xff0000 & $color;
$red = $red >> 16;

Die Addition der einzelnen Farbwerte ergibt die Helligkeit des jeweiligen Pixels. Da die Helligkeit der Zeichen im CAPTCHA nur durch die eingestreuten hellen Punkte variiert, muss lediglich festgestellt werden, ob der aktuelle Pixel zu einem Zeichen gehören kann. Ein paar wenige Tests haben ergeben, dass jeder Helligkeitswert unter 140 zu einem Zeichen gehören muss. Durch diese Konvertierung erhält man eine Punktmatrix für das CAPTCHA, die in etwa so aussieht:

Code:
...X.....XX..........XXXXXXXXX...................................
....XXXXX.XX..........XXX.XXX....................................
....X.XXXXX.X.......XXXX...XX....................................
.....X.XXX.X.X......X.X..XXX.....................................
......XXXX.X.......XXXX.XXX......................XXXXXX..XX......
......XX...X.X....XX.XXXXX.....................XXX...XXXXXXXX....
........XX.XXXXX..XXXXXXXX....................XX.X.X.XX.X.XXX....
........XX....X..XXXXXXX.....................XXXXXX..XXXXXXXXXX..
........X.X.XXX.X.X.XX..X....................XXXXXXXXXXX..X...XX.
.........X..XXXXXX.XXX........................X.X.X....XXX.XXXX..
.........XX.XXXX..X.XX.X....................XXXXX..X.....XXXX.X..
...........X.XX.X..XXXX.......................XX...X.....XXXXXX..
............XXX.X.X.XX......................X.XX.XX......X..XXXX.
............X..XXX.X.X..................................XX..X.XX.
..........X.X.X.XXXXXXX...................................XXXXXX.
..........XXX.XXXX.X.X.................................XXXXXXXX..
.........XXX.XX.X.XXXXXX..............................XXXXXXXX...
.........X.XXX.XX.XXXXXXX............................XX.X.X......
.......XX.XX...XXXX.XX.XXX...........................XXXXXXX.....
.......X.X..XXXX.XXXXXXXXX........................XXXX.X..XX.....
......XXXXXX..X...X.X...XXX......................XXX.XXX.X.......
.....X.X.XX..X.....X..XX.XXX....................XXX.X...X........
.....X.XXXX.XX.....X.XXXXXX....................XXXX.XXX..........
....XX.X...XX.......X.XXXX..X.................X.XX...XX..........
...XXXX.XXXX.........X.X.XXXX................X.XXX.XX............
...XXX.XXXX...........XXXXX.XX...............X.XX.XXX.X.XXX.XX.X.
..XX..X.XXX...........XX.XX..XX..............X.XX.XXX.XX..XXX.X..
............................................X.X.XXXXX..XXXXX.XX..
.............................................XXXXXXXX.XXXX.XXXX..
............................................XXXXXX..XX.XXXX.X..X.
............................................XXXXXXX.XX.XX.X...XX.

Hier nur exemplarisch an zwei Zeichen dargestellt, um den vertikalen Versatz zu zeigen, die oberen und unteren Leeräume wurden schon beschnitten.

Im nächsten Schritt werden die einzelnen Zeichen voneinander getrennt. Da sich die Zeichen nicht überlagern, ist das sehr einfach: der Algorithmus sucht lediglich nach einer Spalte, die nur Pixel enthält, die zu hell sind, um in einem Zeichen vorzukommen. Im obigen Beispiel sind mehrere dieser Spalten zwischen "X" und "2" zu sehen. Im Anschluss können die oberen und unteren "Leerräume" (Zeilen, die nur "zu helle" Pixel enthalten) entfernt werden, und als Ergebnis bleiben die einzelnen Zeichen übrig, die jetzt analysiert werden können. (Im Standard-CAPTCHA von phpBB sind das sechs Zeichen, mein Algorithmus sucht allerdings nicht nur nach dieser Anzahl sondern separiert alle Zeichen voneinander, da es auch leicht modifiziert phpBB-Foren gibt, die eine variable Anzahl von Zeichen auf dem CAPTCHA abbilden. Sollte eine helle Linie ein Zeichen durchschneiden und dieses irrtümlich als zwei Zeichen interpretiert werden, kann der Irrtum über die falsche Größe des Zeichen - z.B. ein abgeschnittenes Stück des Querbalkens eines "T" einfach festgestellt und ein neues CAPTCHA angefordert werden.)

Um die Trefferquote bei der Analyse der Zeichen zu verbessern, werden aus den Zeichen jetzt "Lücken" entfernt. Da sich die einzelnen Zeichen sich nicht überlappen und zwischen den Zeichen immer genügend Platz ist, kann angenommen werden, dass eine "Lücke" von einem oder zwei Punkten (im Beispiel durch "." markiert) ein Pixel ist, das zwar zum Zeichen gehört, aber aufgrund der Helligkeit nicht als solches erkannt wurde. Um das "Rauschen" auf den Zeichen also zu verringern, werden kleine Lücken durch den Algorithmus automatisch geschlossen:

Code:
.....XXXXXX..XX......   .....XXXXXXXXXX......
...XXX...XXXXXXXX....   ...XXX...XXXXXXXX....
..XX.X.X.XX.X.XXX....   ..XXXXXXXXXXXXXXX....
.XXXXXX..XXXXXXXXXX..   .XXXXXXXXXXXXXXXXXX..
.XXXXXXXXXXX..X...XX.   .XXXXXXXXXXXXXX...XX.
..X.X.X....XXX.XXXX..   ..XXXXX....XXXXXXXX..
XXXXX..X.....XXXX.X..   XXXXXXXX.....XXXXXX..
..XX...X.....XXXXXX..   ..XX...X.....XXXXXX..
X.XX.XX......X..XXXX.   XXXXXXX......XXXXXXX.
............XX..X.XX.   ............XXXXXXXX.
..............XXXXXX.   ..............XXXXXX.
...........XXXXXXXX..   ...........XXXXXXXX..
..........XXXXXXXX...   ..........XXXXXXXX...
.........XX.X.X......   .........XXXXXX......
.........XXXXXXX.....   .........XXXXXXX.....
......XXXX.X..XX.....   ......XXXXXXXXXX.....
.....XXX.XXX.X.......   .....XXXXXXXXX.......
....XXX.X...X........   ....XXXXX...X........
...XXXX.XXX..........   ...XXXXXXXX..........
..X.XX...XX..........   ..XXXX...XX..........
.X.XXX.XX............   .XXXXXXXX............
.X.XX.XXX.X.XXX.XX.X.   .XXXXXXXXXXXXXXXXXXX.
.X.XX.XXX.XX..XXX.X..   .XXXXXXXXXXXXXXXXXX..
X.X.XXXXX..XXXXX.XX..   XXXXXXXXXXXXXXXXXXX..
.XXXXXXXX.XXXX.XXXX..   .XXXXXXXXXXXXXXXXXX..
XXXXXX..XX.XXXX.X..X.   XXXXXXXXXXXXXXXXXXXX.
XXXXXXX.XX.XX.X...XX.   XXXXXXXXXXXXXXX...XX.

Links die "2" vor der "Behandlung", auf der rechten Seite das endgültige Zeichen, das jetzt analysiert werden kann. Auf diese Weise werden die durch das "Rauschen" auf dem CAPTCHA jeweils sehr unterschiedliche ausfallenden Zeichen einander angenähert und können mit besserer Treffsicherheit bestimmt werden.

In der "Trainingsphase" der CAPTCHA-Analyse wird das so erhaltene Raster zusammen mit der "Lösung" in einer Bibliothek abgespeichert, um später als Vergleich zu dienen, wenn der Algorithmus die Zeichen selbst bestimmen soll. Aufgrund der Einfachheit, derselbe Grösse, desselben Schriftsatzes, etc. etc. (s.o.) der Zeichen auf dem Standard-CAPTCHA von phpBB brauchte ich für die 35 möglichen Zeichen (Buchstaben A-Z, Zahlen 1-9) nur 56 Bibliothekseinträge, also noch nicht einmal zwei pro Zeichen! Diese Zahlen unterstreichen noch einmal, wie simpel das CAPTCHA ist und wie einfach es geknackt werden kann. (Hätte ich die Bibliothekseinträge vollständig von den restlichen "Lücken" bereinigt - wozu ich aber zu faul war - hätte ich wahrscheinlich noch weniger Einträge benötigt.)

Automatische CAPTCHA-Erkennung

Die automatisch zu erkennenden CAPTCHA werden auf dieselbe Weise ausgewertet wie die Zeichen während des "Trainings". Das Ergebnis ist wiederum ein Raster für jedes Zeichen im CAPTCHA, das dann einzeln mit der Bibliothek verglichen wird. Berechnet wird dabei die Anzahl der im Zeichen enthaltenden Pixel und die Anzahl der übereinstimmenden Pixel. Befindet sich also beim zu analysierenden Zeichen und beim Prüfzeichen aus der Bilbiothek an derselben Koordinate ein dunkler Pixel, wird ein Treffer gezählt. Durch die Einfachheit der verwendeten Zeichen reicht eine Trefferquote von 80% aus, um ein Zeichen eindeutig (und fehlerfrei) zu bestimmen. Die restliche Fehlertoleranz ist nötig (aber völlig ausreichend), um die restlichen "Lücken" im Zeichen auszugleichen.


Die hier vorgestellten Funktionen der CAPTCHA-Erkennung ist eine extrem einfache Methode, es gibt deutlich ausgefeiltere (und viel bessere) Algorithmen zur Texterkennung (insbesondere von CAPTCHA). Dieser Text dient lediglich der Aufklärung und wird hoffentlich zum Anlass genommen, in phpBB2 standardmässig ein besseres CAPTCHA einzubauen bzw. die bestehenden Installationen mit dem "Advanced Visual Confirmation"-MOD (oder ähnlichen Lösungen) auszustatten, um die Spam-Flut endlich einzudämmen. Reichlich Hinweise zur Absicherung von phpBB gegen automatische Anmeldungen und Postings habe ich hier bereits ausführlich gegeben (im Abschnitt unter "Abhilfe").
(So wie es bis jetzt aussieht, wird phpBB3 "von Haus aus" ein besseres CAPTCHA bekommen, da phpBB3 aber noch lange nicht bei allen Neuinstallationen verwendet wird, geschweige denn, dass sämtliche jetzt noch mit phpBB2 laufenden Foren mit einem Schlag konvertiert würden, wurde dieser Text trotzdem veröffentlicht.)


Zum Schluss möchte ich noch auf das Projekt "reCAPTCHA" verweisen. Eine sehr gelungene Kombination: um bei der Digitalisierung alter Bücher zu helfen, werden einzelne Worte, die von den OCR-Programmen nicht eindeutig identifiziert werden konnte, als CAPTCHA angeboten. Hilft gegen Spam und für die Erhaltung alter Texte!


MfG,
pseudocode


Zuletzt bearbeitet von pseudocode am Di, 03 Jul 2007, 13:29, insgesamt 2-mal bearbeitet. (11 Prozent)

Nach oben
Rang:
pseudocode





Titel: (Kein Titel)
Verfasst am: Sa, 30 Jun 2007, 20:31
Beitrag
Antworten mit Zitat

Projekt SpamBot 2.0
now with CAPTCHA-Breaker


"Projekt SpamBot 2.0" basically consists of the same scripts as the first projekt. The only enhancement is that the bot now has the ability to break phpBB's standard-CAPTCHA. Breaking a CAPTCHA is not really new, you can find lots of (broken) CAPTCHA here where the most used CAPTCHA are analysed and a lot of them also solved automatically.
What is new is the fact, that this script can solve 100% of phpBB's CAPTCHA as long as it's the standard version (which comes with every install). As far as I know the "solution" to phpBB's CAPTCHA also has not been published so far. You can read more about it further down, first here's a short introduction to the new version of "Projekt SpamBot".

Spider: As MSN Search offers a good "target" for harvesting phpBB-URLs, it was used again this time.
About 50.000 URLs were found using ca. 180 keywords. Those URLs were enhanced using the paths "phpBB", "forum" and other, to reach forums that "hide" behind a portal page or something of that kind. Combined with the URL-lists from "Projekt SpamBots" first run, almost 500.000 URLs (491.187) were gatherd that were checked for phpBB-software.
The result: 42.680 phpBB-forums where found as potential "targets".

Again, the "Registerbot" was used, this time enhanced with the automatic CAPTCHA-solution (see below). The "Confirmbot" (for automatic confirmation of the activation links) remained unchanged.
After the running of all scripts, 14.247 valid accounts for phpBB-forums were gathered! (We have to subtract the forums that use admin-activation and won't activate the fake accounts, but presumably those are just a handful.)
The projekt was not successful with 5.516 URLs, the other URLs (half of all checked sites) were not reachable or not a standard (phpBB-)page, so that no automatic registration could be posted. The relation of successful to unsuccessful registration went up dramatically by using the new CAPTCHA-solution (from 1:1 to 3:1 now).

Using this registration data the "Postbot" was sent out and postet a message to over 2.000 forums. The content of the message was changed slightly, to sound less like "real spam" that would be deleted right away.


Some words about the "Humanizer":
The "Humanizer" in its standard-version could, too, be broken by "Projekt SpamBot" very easily. The "Humanizer" will add the question "Are you human?" to the registration form. If the answer (using a radiobutton) is not "yes", the registration will be rejected.
Of course there's nothing like "human=yes" in the source code of the page but a MD5-Code, that will change with every registration. It looks like this:

Code:
<input type="radio" name="dd41255da6911f91947c56658af6d1e1" value="dd41255da6911f91947c56658af6d1e1"  />

As no other variable name in the source code has 32 characters, all there is to do is to search for a radiobutton with a name exactly this long. The following code has to be read and submitted with the registration as the variable name and the value. Doing that, the "Humanizer" ist obsolete.
(This is only true for the standard-version. There are now better versions that ask "real" questions and need a text input as an answer.)






The phpBB-standard-CAPTCHA

First this: phpBB's standard-CAPTCHA von phpBB is unsafe. It has severe deficits and it's way too easy for programmers to break the CAPTCHA. The "protection" it offers is almost not existent.



Here are the reasons, why the CAPTCHA offers no protection:
  1. It always uses the same font, the number of different characters is limited, as only capital letters and numbers are used.
    The smaller the number of possible characters the easier it is to break a CAPTCHA, as the algorihtm that recognizes the letters/numbers can concentrate on just a few characters. The use of different fonts and special characters would make it a lot harder to decode the CAPTCHA. Also graphical signs could be used, e.g. there's a CAPTCHA that shows arrows which the user has to count.

  2. The characters on the CAPTCHA are neither bent nor rotated.
    Bent or rotated characters are harder to recognize for an algorithm than the characters on the phpBB-CAPTCHA that are always upright. There are easy methods to bend the whole CAPTCHA (like a waveform) or rotate the characters (each in a different way), but unfortunately, those methods are not used here.

  3. The characters don't overlap and are not disturbed by "nonsense-characters".
    This is the main deficit of the phpBB-CAPTCHA: it is very easy to separate the characters from another (and analyze them separately) as they are not overlapping. There are no "nonsense-characters", e.g. geometrical forms the overlap the letters or lines that cut them.
    The vertical offset of the characters doesn't enhance the CAPTCHA as the characters (once separated) can be trimmed so the offset doesn't help at all.

  4. The number of characters is always the same. Also the size of the characters doesn't vary.
    The number of characters on phpBB's standard-CAPTCHA is set to "6". This simplifies the solution, because the algorithm knows exactly what to look for. If a differing number is found, the parsing of the CAPTCHA can be repeated by just loading a new CAPTCHA (containing the same characters).
    Another huge weakness of phpBB's CAPTCHA-system is visible here: the CAPTCHA-picture can be re-loaded endlessly while the characters on the picture stay the same, only the position and the "noise" vary. If the "solution algorithm" finds seven characters (e.g. because a very bright line cuts through a character), the picture can be re-loaded and re-analyzed. Because phpBB behaves like this, the solution-rate of the algorithm could be increased to 100%! The number of tries to register is limited, but not how often the CAPTCHA-picture is loaded, so the algorithm can reload the picture (instead of the whole page) until the CAPTCHA is solved.
    Also the constant size of the characters is a disadvantage: if the separation of the characters goes wrong, this can be determined just by checking the size of each character (and a new CAPTCHA can be loaded in that case).

  5. The colors of the CAPTCHA are always used in the same way and the palette is limited.
    The characters on the standard-CAPTCHA are always dark, the background is always light. This makes it easy to calculate the difference between a character and the obsolete background ("noise"). A colorful CAPTCHA with changing colors (especially between the characters and the background) would have made the solution a lot harder.




The algorithm


Reading the registration page and the CAPTCHA

First the registration page of the "victim" is read and the URL of the CAPTCHA is extracted. The URL looks like this:

Code:
FORUM_URL/profile.php?mode=confirm&id=CAPTCHA_ID

and can be loaded as often as needed (see above). If this picture is loaded the first time:


it could look something like this the second time:


If a character can't be identified, there are unlimited tries to get the CAPTCHA in a form that's easier to read/analyze.
As soon as the picture is loaded to memory, it can be analyzed.

Analyzing the CAPTCHA

The algorithm will now check the picture pixel by pixel and calculate the brightness of each pixel. As phpBB's standard-CAPTCHA just uses the greyscale, this is easy to do (e.g. in PHP):

Code:
$color = imagecolorat($im, $j, $i);
$blue = 0x0000ff & $color;
$green = 0x00ff00 & $color;
$green = $green >> 8;
$red =0xff0000 & $color;
$red = $red >> 16;

Adding the color values results in the brightness of the pixel. As the brightness of the characters in the CAPTCHA just varies by some "noise", it just has to be checked if the pixel could possibly belong to a character. A few simple tests showed that all pixels below a brightness of 140 have to belong to a character. Through this conversion we get a matrix that looks something like this:

Code:
...X.....XX..........XXXXXXXXX...................................
....XXXXX.XX..........XXX.XXX....................................
....X.XXXXX.X.......XXXX...XX....................................
.....X.XXX.X.X......X.X..XXX.....................................
......XXXX.X.......XXXX.XXX......................XXXXXX..XX......
......XX...X.X....XX.XXXXX.....................XXX...XXXXXXXX....
........XX.XXXXX..XXXXXXXX....................XX.X.X.XX.X.XXX....
........XX....X..XXXXXXX.....................XXXXXX..XXXXXXXXXX..
........X.X.XXX.X.X.XX..X....................XXXXXXXXXXX..X...XX.
.........X..XXXXXX.XXX........................X.X.X....XXX.XXXX..
.........XX.XXXX..X.XX.X....................XXXXX..X.....XXXX.X..
...........X.XX.X..XXXX.......................XX...X.....XXXXXX..
............XXX.X.X.XX......................X.XX.XX......X..XXXX.
............X..XXX.X.X..................................XX..X.XX.
..........X.X.X.XXXXXXX...................................XXXXXX.
..........XXX.XXXX.X.X.................................XXXXXXXX..
.........XXX.XX.X.XXXXXX..............................XXXXXXXX...
.........X.XXX.XX.XXXXXXX............................XX.X.X......
.......XX.XX...XXXX.XX.XXX...........................XXXXXXX.....
.......X.X..XXXX.XXXXXXXXX........................XXXX.X..XX.....
......XXXXXX..X...X.X...XXX......................XXX.XXX.X.......
.....X.X.XX..X.....X..XX.XXX....................XXX.X...X........
.....X.XXXX.XX.....X.XXXXXX....................XXXX.XXX..........
....XX.X...XX.......X.XXXX..X.................X.XX...XX..........
...XXXX.XXXX.........X.X.XXXX................X.XXX.XX............
...XXX.XXXX...........XXXXX.XX...............X.XX.XXX.X.XXX.XX.X.
..XX..X.XXX...........XX.XX..XX..............X.XX.XXX.XX..XXX.X..
............................................X.X.XXXXX..XXXXX.XX..
.............................................XXXXXXXX.XXXX.XXXX..
............................................XXXXXX..XX.XXXX.X..X.
............................................XXXXXXX.XX.XX.X...XX.

Just two characters are shown as an example to show the vertical offset. The blank space has already been cut.

In the next step the characters are separated. As the characters don't overlap, this is very easy: the algorithm will just look for a column in the picture with just pixels that are too light to be in a character. You can see several of those columns in the example above between "X" and "2". Afterwards the blank spaces above and below each character (lines that contain "too light" pixels) can be removed. The result are separated single characters that can be analyzed separately. (phpBB's standard-CAPTCHA contains six characters, but the algorithm will look for any number of characters as there are slighty modified phpBB-forums that have a varying number of characters on the CAPTCHA. If a light line cuts through a character and the algorithm will take those for two characters, the wrong "size" of the parts - e.g. a cut off part of the horizontal line of a "T" - show that something went wrong. A new CAPTCHA can be loaded in this case.)

To increase the "hit rate" of the algorithm, "gaps" in the characters are removed now. As the characters don't overlap and there's enough room between the characters, a "gap" of one or two pixels (marked with "." in the example) are in fact pixels that were not recognized as "character-pixels" because of their brightness. To reduce the "noise" on the characters, those little gaps are closed by the algorithm:

Code:
.....XXXXXX..XX......   .....XXXXXXXXXX......
...XXX...XXXXXXXX....   ...XXX...XXXXXXXX....
..XX.X.X.XX.X.XXX....   ..XXXXXXXXXXXXXXX....
.XXXXXX..XXXXXXXXXX..   .XXXXXXXXXXXXXXXXXX..
.XXXXXXXXXXX..X...XX.   .XXXXXXXXXXXXXX...XX.
..X.X.X....XXX.XXXX..   ..XXXXX....XXXXXXXX..
XXXXX..X.....XXXX.X..   XXXXXXXX.....XXXXXX..
..XX...X.....XXXXXX..   ..XX...X.....XXXXXX..
X.XX.XX......X..XXXX.   XXXXXXX......XXXXXXX.
............XX..X.XX.   ............XXXXXXXX.
..............XXXXXX.   ..............XXXXXX.
...........XXXXXXXX..   ...........XXXXXXXX..
..........XXXXXXXX...   ..........XXXXXXXX...
.........XX.X.X......   .........XXXXXX......
.........XXXXXXX.....   .........XXXXXXX.....
......XXXX.X..XX.....   ......XXXXXXXXXX.....
.....XXX.XXX.X.......   .....XXXXXXXXX.......
....XXX.X...X........   ....XXXXX...X........
...XXXX.XXX..........   ...XXXXXXXX..........
..X.XX...XX..........   ..XXXX...XX..........
.X.XXX.XX............   .XXXXXXXX............
.X.XX.XXX.X.XXX.XX.X.   .XXXXXXXXXXXXXXXXXXX.
.X.XX.XXX.XX..XXX.X..   .XXXXXXXXXXXXXXXXXX..
X.X.XXXXX..XXXXX.XX..   XXXXXXXXXXXXXXXXXXX..
.XXXXXXXX.XXXX.XXXX..   .XXXXXXXXXXXXXXXXXX..
XXXXXX..XX.XXXX.X..X.   XXXXXXXXXXXXXXXXXXXX.
XXXXXXX.XX.XX.X...XX.   XXXXXXXXXXXXXXX...XX.

On the left there's the "2" before the "treatment", on the right side the final character, ready to be analyzed. Using this method the "noise" on the characters is significantly reduced, different "versions" of the characters are approximated and the hit rate of the algorithm increased.

During the "training phase" of the CAPTCHA-analysis the resulting matrix will be saved in a library together with the "solution" to be used as a reference when the algorithm is "on its own". As the characters on phpBB's standard-CAPTCHA are so simple, use the same font, size, etc. etc. (see above), only 56 entries in the library were needed (not even two per character)! This number emphasizes how simple the CAPTCHA is and how easily it can be broken. (If we cleaned the characters in the library of *all* gaps, we probably could have reduced the number of characters in the library even more - but we were just too lazy to do that.)

Automatic CAPTCHA-recognition

Using the algorithm the CAPTCHA to be "solved" are analyzed the same way as during the "training". The result is a matrix for each character which are compared to the library one by one. This time the relation between the pixels contained in the character and the pixel in the library-character is calculated. If we find a dark pixel in the character that's to be analyzed and it corresponds to a dark pixel at the same coordinates in the library-character, we count a "hit". As the characters are so simple, a hit-rate of 80% is sufficient to clearly (and error-free) recognize the character. The remaining error-tolerance is necessary (but sufficient) to compensate the remaining "gaps" in the characters.


The method for CAPTCHA-recognition introduced here is a very simple one, there are way more sophisticated (and better) algorithms for character recognition (especially in CAPTCHA). This text is just for illustration and will hopefully be taken as a reason to enhance phpBB2 with a better CAPTCHA and modify existing installations with the "Advanced Visual Confirmation"-MOD (or similar solutions) to ban the spam-flood once and for all. A lot of hints how to secure phpBB against automatic registrations and postings were already posted here (in chapter "First Aid").
(It seems the phpBB3 will get a better CAPTCHA right from the start, but as phpBB3 is not yet used for all new installations and especially as not all phpBB2-forums will upgrade all at once, this text was published anyway.)


To conclude this we'd like to point out the projekt "reCAPTCHA". A very well done combination: to help with the digitalization of old books, single words the the OCR-software couldn't recognize clearly, are offered as CAPTCHA. Helps against spam and for the conservation of old texts!


regards,
pseudocode


Zuletzt bearbeitet von pseudocode am Di, 03 Jul 2007, 16:00, insgesamt einmal bearbeitet. (1 Prozent)

Nach oben
Rang:
teddyD





Titel: Danke nochmal!
Verfasst am: Mo, 02 Jul 2007, 08:49
Beitrag
Antworten mit Zitat

Hi pseudocode,

nochmals ein dickes Danke für Deine tolle Arbeit!

Ich habe gestern ein paar Minuten investiert, um mein Forum ein wenig sicherer zu gestalten. Was soll ich sagen: Seit dem Moment KEINE Spambot-Anmeldungen mehr!! Very Happy (zum Vergleich: vorher waren es ca. 30-50 pro Tag!)

Mal sehen, wie lange es anhält... aber Du hast ja soviele Tipps gegeben... dann rüste ich halt nach. Smile

Danke!

Gruß,
Teddy D.

Nach oben
Rang:
pseudocode





Titel: Re: Danke nochmal!
Verfasst am: So, 08 Jul 2007, 09:32
Beitrag
Antworten mit Zitat

teddyD gab folgendes von sich:
nochmals ein dickes Danke für Deine tolle Arbeit!

Freut mich, wenn ich helfen konnte, dann war die Arbeit nicht umsonst Smile

teddyD gab folgendes von sich:
Mal sehen, wie lange es anhält... aber Du hast ja soviele Tipps gegeben... dann rüste ich halt nach. Smile

Die Bots rüsten natürlich leider auch nach, aber ich denke, irgendwann ist für die Bot-Schreiber die Kosten-Nutzen-Relation nicht mehr ausreichend, so dass man (für den Moment) mit den von mir genannten Änderungen recht sicher sein dürfte.

MfG,
pseudocode

Nach oben
Rang:
Beiträge der letzten Zeit anzeigen:   
Neues Thema eröffnen   Dieses Thema ist gesperrt, du kannst keine Beiträge editieren oder beantworten.    beeForum Foren-übersicht » globetrottel Seite 1 von 1
Gehe zu:  



ähnliche Beiträge
Thema Autor Forum Antworten Verfasst am
Keine neuen Beiträge Film: Das Lazarus-Projekt boris zelluloid 0 Di, 05 Mai 2020, 22:25 Letzten Beitrag anzeigen
Keine neuen Beiträge Projekt: Eigenbräu jrose le finesnäcker 20 So, 28 Mai 2017, 09:52 Letzten Beitrag anzeigen
Keine neuen Beiträge Film: Das Jerico Projekt boris zelluloid 0 Mo, 02 Jan 2017, 22:13 Letzten Beitrag anzeigen
Keine neuen Beiträge Algis Budrys - Projekt Luna boris kühnes mittelscharfer 0 Mi, 27 März 2013, 19:10 Letzten Beitrag anzeigen
Keine neuen Beiträge Pussycat Prolls feat. Fifty Sven jrose silikonimplantate 0 Do, 29 Jul 2010, 12:47 Letzten Beitrag anzeigen


Schreiben: nein. Antworten: nein. Bearbeiten: nein. Löschen: nein. Umfragen: nein.
phpBB © phpBB Group | impressum