Tutorial ReCaptcha - Website beveiliging

Gestart doorJeffreyy15 reacties99 weergaven

16 berichten · pagina 1 van 2

Jeffreyy

Lid · Topicstarter

Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Tutorial ReCaptcha
Aangezien ik de laatste tijd weinig websites zie, die gebruik maken van een captcha, en dat toch nog best belangrijk is. Maak ik deze tutorial.
Deze tutorial gaat over het installeren en gebruiken van "ReCaptcha", dit is een class, die verchillende woorden, cijfers en lettertypes gebruikt, en tot nu toe nog niet gekraakt is.

Het begin
We beginnen met het aanvragen van een public, en secret code, dit kan je hier doen.
Let op: Je moet een google account hebben!
Deze codes worden automatisch gegenereerd, en je zult dus niet hoeven wachten.
Laat dit tabblad open staan, de codes (keys) heb je zometeen nodig!

De API
We kunnen nu nog helemaal niks, omdat we de API nog niet hebben.
Klik hier om deze te downloaden.

We pakken het bestand uit op bureaublad, en verwijderen alle bestanden, behalve recaptchalib.php.
Dit is de API namelijk.

Installeren
Eigenlijk stelt het helemaal niks voor maarja.
Upload recaptchalib.php naar je host.
Ga naar het bestand waar je de captcha wilt gebruiken.

Zet dit boven aan je pagina:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/require_once"]require_once[/URL] [COLOR= #DD0000]recaptchalib.php[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$publickey[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]JOUW PUBLIC KEY HIER[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$privatekey[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]JOUW PRIVATE KEY HIER[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] null[COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$resp[/COLOR] [COLOR= #007700]=[/COLOR] null[COLOR= #007700];[/COLOR]
?>


Zo, we hebben aangegeven dat we reCaptcha gaan gebruiken.
Nu ga je naar het formulier op de pagina, en maak je plaats voor de Captca,
op de plek waar je hem wilt, zet je de volgende code:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] recaptcha_get_html[COLOR= #007700]([/COLOR][COLOR= #0000BB]$publickey[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$error[/COLOR][COLOR= #007700]);[/COLOR]
?>


Dit zal de Captcha weergeven.

Controleren
Nu gaan we controleren of hij juist ingevuld is.
Dit doen we alsvolgd.
(Ik heb er even een standaartformuliertje van gemaakt)

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/require_once"]require_once[/URL] [COLOR= #DD0000]recaptchalib.php[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$publickey[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]JOUW PUBLIC KEY HIER[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$privatekey[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]JOUW PRIVATE KEY HIER[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] null[COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$resp[/COLOR] [COLOR= #007700]=[/COLOR] null[COLOR= #007700];[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]"POST"[/COLOR][COLOR= #007700]) {[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]voornaam[/COLOR][COLOR= #007700]]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]achternaam[/COLOR][COLOR= #007700]])) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Er is geen voor- en/of achternaam ingevuld.[/COLOR][COLOR= #007700];
    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [COLOR= #FF8000]// Hier controleren we de captcha, d.m.v. de API[/COLOR]
        [COLOR= #0000BB]$resp[/COLOR] [COLOR= #007700]=[/COLOR] recaptcha_check_answer[COLOR= #007700]([/COLOR][COLOR= #0000BB]$privatekey[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"REMOTE_ADDR"[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"recaptcha_challenge_field"[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"recaptcha_response_field"[/COLOR][COLOR= #007700]]);[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$resp[/COLOR][COLOR= #007700]->[/COLOR]is_valid[COLOR= #007700]) {[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt de captcha goed ingevuld![/COLOR][COLOR= #007700];
        }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Helaas, captcha verkeerd ingevuld![/COLOR][COLOR= #007700];
        }
    }
}[/COLOR]
?>
<form method="post" action="">
<table border="0">
    <tr>
        <td>Voornaam:</td>
        <td><input type="text" name="voornaam" /></td>
    </tr>
    <tr>
        <td>Achternaam:</td>
        <td><input type="text" name="achternaam" /></td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] recaptcha_get_html[COLOR= #007700]([/COLOR][COLOR= #0000BB]$publickey[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$error[/COLOR][COLOR= #007700]);[/COLOR] ?></td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td><input type="submit" value="Verzend" name="x" />/td>
    </tr>
</table>
</form>


Voor vragen kun je me altijd een PB sturen, of reageren.
Donaties altijd welkom.
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Is het niet nicer om een tut te maken hoe je zelf een captcha maakt?
Dat werkt denk wat makkelijker yummie
0
Jeffreyy

Lid · Topicstarter

Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Klopt, maar dit makkelijker, en die je zelf maakt zijn meestal makkelijker te kraken, want dan vergeet je wel eens iets, en deze is niet te kraken (Volgens ReCaptcha dan)
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Jponsen schreef:
Klopt, maar dit makkelijker, en die je zelf maakt zijn meestal makkelijker te kraken, want dan vergeet je wel eens iets, en deze is niet te kraken (Volgens ReCaptcha dan)
Das idd waar yummie
Kben erachter gekomen dat als je een img maakt met alleen letters dat uit te lezen is
Maar met strepen niet yummie (random strepen)
0
Jeffreyy

Lid · Topicstarter

Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Soms wel, sommige scripts gaan echt ver, het beste is dan om met kleuren, lettertypes, groote, en met een spikkelende achtergrond te werken, en natuurlijks de letters op een random plaats in de afbeelding zetten, dan maak je ze het aardig moeilijk, maar om dat allemaal doen, kies ik toch echt liever voor ReCaptcha, want zodra hun weten of er iets te omzeilen is, passen ze het aan.
0
Berichten
4.213
Reputatie
0
Punten
0,02
Lid sinds
Laatst gezien
die api link werkt niet meer!

toevoeging op 15 september 2011, 19:24:16:
hij staat op mijn site maar als ik aanmeld zonder code intevullen/foute code staat er
foute code!
en eronder uw bent aangemeld
en dan ben ik gewoon aangemeld
0
Berichten
3.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je moet wel instellen dat je alleen inlogt bij if($resp->is_valid) he!

Trouwens, een eigen maken is minder handig dan deze want deze is erop gemaakt om voor veel mensen goed te werken, door mensen die er veel verstand van hebben. Het is erg moeilijk om de grens tussen leesbaarheid van mensen en van computers goed in te stellen yummie
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Tja, en nu via wordpress! smileVerder goeie tutorial.
0
Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hmm, hij geeft heletijd aan dat de captcha verkeerd is ingevuld.

Ik heb dit:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]])) 
                {[/COLOR]
                    [COLOR= #0000BB]$naam[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]];[/COLOR] 
                    [COLOR= #0000BB]$email[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]];[/COLOR] 
                    [COLOR= #0000BB]$onderwerp[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]onderwerp[/COLOR][COLOR= #007700]];[/COLOR] 
                    [COLOR= #0000BB]$bericht[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]);[/COLOR]
                    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]onderwerp[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]))
                    {[/COLOR]
                        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"U heeft een van de velden niet ingevult!"[/COLOR][COLOR= #007700];    
                    }[/COLOR] [URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bericht[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]10[/COLOR][COLOR= #007700])) {[/COLOR]
                        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Uw bericht is tekort! er moeten minimaal 10karakters in!"[/COLOR][COLOR= #007700];
                    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                        [COLOR= #FF8000]// Hier controleren we de captcha, d.m.v. de API[/COLOR]
                        [COLOR= #0000BB]$resp[/COLOR] [COLOR= #007700]=[/COLOR] recaptcha_check_answer[COLOR= #007700]([/COLOR][COLOR= #0000BB]$privatekey[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"REMOTE_ADDR"[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"recaptcha_challenge_field"[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"recaptcha_response_field"[/COLOR][COLOR= #007700]]);[/COLOR]
                        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$resp[/COLOR][COLOR= #007700]->[/COLOR]is_valid[COLOR= #007700]) {[/COLOR]
                            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt de captcha goed ingevuld![/COLOR][COLOR= #007700];
                        }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Helaas, captcha verkeerd ingevuld![/COLOR][COLOR= #007700];
                        }
                    }[/COLOR]
?>
0
Jeffreyy

Lid · Topicstarter

Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Post het formulier wat ingevuld moet worden eens, daar wordt heel vaak een fout mee gemaakt.
0
Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Spoiler tonen
<form action="contact" method="POST">
                        <tr>
                            <th>Naam: </th>
                            <td><input class="field" type="text" name="naam" /></td>
                        </tr>
                        <tr>
                            <th>Email: </th>
                            <td><input class="field" type="email" name="email" /></td>
                        </tr>
                        <tr>
                            <th>Onderwerp: </th>
                            <td><input class="field" type="text" name="email" /></td>
                        </tr>
                            <td colspan="2">
                                <textarea name="bericht"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                            [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] recaptcha_get_html[COLOR= #007700]([/COLOR][COLOR= #0000BB]$publickey[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$error[/COLOR][COLOR= #007700]);[/COLOR] ?>
                            </td>
                        </tr>
                        <tr>
                               <td colspan="2"><input class="field" type="submit" name="submit" value="Verzend" /></td>
                        </tr>
                    </form>
0
Jeffreyy

Lid · Topicstarter

Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Waar open je je table?
Want het
0
Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Moet dat dat maakt toch niet uit??
Naja ik probeer het wel. Staat er trouwens 1regel boven,

toevoeging op 18 december 2011, 17:33:27:
Hij doet het thnks
0
Jeffreyy

Lid · Topicstarter

Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Die even omwisselen, dan krijg je ongeveer dit:

<form action="contact" method="POST">
<table border="0">
                        <tr>
                            <th>Naam: </th>
                            <td><input class="field" type="text" name="naam" /></td>
                        </tr>
                        <tr>
                            <th>Email: </th>
                            <td><input class="field" type="email" name="email" /></td>
                        </tr>
                        <tr>
                            <th>Onderwerp: </th>
                            <td><input class="field" type="text" name="email" /></td>
                        </tr>
                            <td colspan="2">
                                <textarea name="bericht"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                            [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] recaptcha_get_html[COLOR= #007700]([/COLOR][COLOR= #0000BB]$publickey[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$error[/COLOR][COLOR= #007700]);[/COLOR] ?>
                            </td>
                        </tr>
                        <tr>
                               <td colspan="2"><input class="field" type="submit" name="submit" value="Verzend" /></td>
                        </tr>
                      </table>
                    </form>
0
Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hij doet het echt top!!
Miss ook ff in de tut zetten dat je daar op moet lettenwink
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren