index.php

Gesponsorde koppelingen

PHP script bestanden

  1. Bcrypt.php
  2. encryption.js
  3. index.php
  4. index.php
  5. login.css
  6. maak_functies.php
  7. geldig_ip.php
  8. index.php
  9. index.php
  10. nl.php
  11. configuratie.php
  12. controle.php
  13. index2.php
  14. uitloggen.php
  15. database.sql

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<?php
/*
Auteur: Cas Buijs
Naam: index.php
Functie: Admin Login
Beschrijving:     Het script encrypt het ingevoerde wachtwoord,
                controleert de ingevoerde gegevens met de gegevens uit de database,
                geeft een foutmelding wanneer de gegevens onjuist zijn,
                encrypt een sessie voor de gebruiker wanneer de gegevens juist zijn.

*/

//Start Sessie

session_start();

//Configuratiebestanden includen
include('configuratie.php');
include('procedures/geldig_ip.php');
include('procedures/maak_functies.php');
include('talen/nl.php');

//Vooraf ingevulde sessie legen
if (isset($_SESSION['login']))
{

    unset($_SESSION['login']);
}


//Controleren of de gebruiker een geldig ip-adress gebruikt.
$ip = $_SERVER['REMOTE_ADDR'];
if (!get_valid_ip($ip))
{

    echo $sMelding[7];
}

else
{

    //Controleren of de sessie al bestaat
    if (!isset($_SESSION['pogingen']))
    {

        $_SESSION['pogingen'] = 0;
    }


    //Beveiliging brute-force
    if ($_SESSION['pogingen'] >= 10)
    {

        echo $sMelding[5];
    }

    else
    {

        //Controleren of iemand wil inloggen
        if (isset($_POST['login']))
        {

            

            //Controleren of er een gebruikersnaam is opgegeven
            if (!isset($_POST['gbnaam']) OR empty($_POST['gbnaam']))
            {

                echo $sMelding[1];
            }

            else
            {
                
            
                //Controleren of het wachtwoord veld wel door de javascript is geleegd
                if(!empty($_POST['gbpass']))
                {

                    echo $sMelding[12];
                }

                else
                {

                    //Controleren of er een geencrypt wachtwoord is meegestuurd
                    if (!isset($_POST['hash']) OR empty($_POST['hash']))
                    {

                        echo $sMelding[2];
                    }

                    else
                    {
                
                        //Controleren of er een challenge is meegestuurd
                        if (!isset($_POST['challenge']) OR empty($_POST['challenge']))
                        {

                            echo $sMelding[11];
                        }

                        else
                        {
                
                            //Controleren of er een response is meegestuurd
                            if (!isset($_POST['response']) OR empty($_POST['response'])) //Anti Manipulatie
                            {
                                echo $sMelding[11];
                            }

                            else
                            {

                                //Controleren op illegale tekens in de gebruikersnaam
                                if(!preg_match('/^[a-zA-Z0-9]+$/',$_POST['gbnaam'])) //Anti Manipulatie
                                {
                                    echo $sMelding[3];
                                }

                                else
                                {

                                    //Controleren op illegale tekens door manipulatie in het hash veld
                                    if(!preg_match('/^[a-zA-Z0-9]+$/',$_POST['hash'])) //Anti Manipulatie
                                    {
                                        echo $sMelding[3];
                                    }

                                    else
                                    {
                        
                                        //Controleren of de gegevens de vereiste lengte hebben
                                        if (strlen($_POST['gbnaam']) >= 15)
                                        {

                                            echo $sMelding[9];
                                        }

                                        else
                                        {
                            
                                            //Controleren of de waarde wel een sha512 hash waarde is
                                            if (strlen($_POST['hash']) != 128)
                                            {

                                                echo $sMelding[11];
                                            }

                                            else
                                            {
                                
                                                //Controleren of de waarde wel een sha512 hash waarde is
                                                if (strlen($_POST['response']) != 128)
                                                {

                                                    echo $sMelding[11];
                                                }

                                                else
                                                {

                                                    //Controleren of de challenge waarde overeen komt
                                                    if ($_SESSION['challenge'] != $_POST['challenge'])
                                                    {

                                                        echo $sMelding[11];
                                                    }

                                                    else
                                                    {
                                    
                                                        //Controleren of de response juist is
                                                        $deelteken = ':';
                                                        $responsecontrol = $_POST['hash'].$deelteken.$_SESSION['challenge'];
                                                        if (hash("sha512", $responsecontrol) != $_POST['response'])
                                                        {

                                                            echo $sMelding[11];
                                                        }

                                                        else
                                                        {
                                                        
                                                            //Wachtwoord Encryptie
                                                            $wachtwoord = maak_wachtwoord($_POST['hash']);
                                                            
                                                            //Verbinding maken met de database
                                                            $qGegeven = "SELECT naam,wachtwoord FROM login WHERE naam='".mysql_real_escape_string($_POST['gbnaam'])."' LIMIT 0,1";
                                                            $qGegevenquery = mysql_query($qGegeven);

                                                            //Controleren op fouten in de verbinding
                                                            if ($qGegevenquery === false)
                                                            {

                                                                echo $sMelding[4];
                                                            }

                                                            else
                                                            {

                                                                //Gegevens beschikbaar stellen
                                                                $gegevens = mysql_fetch_array($qGegevenquery);
    
                                                                //Wachtwoord verifieren
                                                                $verify = controleer_wachtwoord($_POST['hash'], $gegevens['wachtwoord']);

                                                                //Controleren of het ingevulde wachtwoord, ook het echte wachtwoord is
                                                                if ($verify == 1)
                                                                {


                                                                    echo $sMelding[6]; //Bevestigings bericht als de inlog gelukt is.
                                                                    header('Refresh: 2; url=home/index.php'); //Na 2 seconden wordt de gebruiker naar de volgende pagina doorgestuurd

                                                                    //Sessie encryptie wordt gemaakt

                                                                    $sessie = maak_sessie($_POST['gbnaam']);

                                                                    //Sessie maken om de gebruiker later te kunnen herkennen
                                                                    $_SESSION['login'] = $sessie;
                                                                    $_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];

                                                                    //Sessie in de database bijhouden
                                                                    $qSessie = "UPDATE login SET sessie='".mysql_real_escape_string($sessie)."', ip='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."', useragent='".mysql_real_escape_string($_SERVER['HTTP_USER_AGENT'])."' WHERE naam='".mysql_real_escape_string($_POST['gbnaam'])."'";
                                                                    $qSessiequery = mysql_query($qSessie);

                                                                    //Controleren of de sessie naar de database is geschreven
                                                                    if ($qSessiequery === false)
                                                                    {

                                                                        echo $sMelding[4];
                                                                    }

                                                                    else
                                                                    {

                                                                        //Foutieve inlog pogingen herstellen
                                                                        $_SESSION['pogingen'] = 0;

                                                                        sleep(1); //Anti Brute-Force
                                                                    }
                                                                }

                                                                else
                                                                {
                                                                    echo $sMelding[3]; //Melding van foute login
    
                                                                    //Aantal pogingen verhogen

                                                                    $_SESSION['pogingen'] = $_SESSION['pogingen'] + 1;
                                                                        
                                                                    sleep(1); //Anti Brute-force
                                                                        
                                                                }//Foutieve login
                                                            }//Foute sql query bij controle of de gebruiker bestaat    
                                                        }//Einde response controle
                                                    }//Einde challenge controle
                                                }//Response lengte controle
                                            }//Hash lengte controle
                                        }//Gebruikersnaam lengte controle
                                    }//Hash Pregmatch
                                }//Gebruikersnaam Pregmatch
                            }//Response ingevuld of niet
                        }//Challenge ingevuld of niet
                    }//Hash ingevuld of niet
                }//Wachtwoord veld geleegd of niet
            }//Gebruikersnaam ingevuld of niet
        }//Einde login script
    }//Einde Brute-Force beveiliging
}//Einde Geldig-IP controle
    
    
//Nieuwe challenge sessie maken

$_SESSION['challenge'] = maak_challenge();

?>

<script type="text/javascript" src="modules/encryption.js"></script>
<script type="text/javascript">
<!--
function antiPostBack()
{
document.getElementById( 'hash' ).value = hex_sha512( document.getElementById( 'gbpass' ).value );
document.getElementById( 'response' ).value = hex_sha512( hex_sha512( document.getElementById( 'gbpass' ).value ) + ":" + document.getElementById( 'challenge' ).value);
document.getElementById( 'gbpass' ).value = '';
return true;
}
//-->
</script>
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<link rel="icon" type="image/png" href="favicon.png" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style/login.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Login</h1>
<form method="post" onsubmit="return antiPostBack();">
<table id="table">
<tr>
<td>Gebruikersnaam: </td>
<td><input type="text" name="gbnaam"></td>
</tr>
<tr>
<td>Wachtwoord: </td>
<td><input type="password" id="gbpass"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="login" value="Login"></td>
</tr>
<tr>
<td></td>
<td><input type="hidden" name="challenge" id="challenge" value="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $_SESSION['challenge'];?>
"></td>
</tr>
<tr>
<td></td>
<td><input type="hidden" name="hash" id="hash" value=""></td>
</tr>
<tr>
<td></td>
<td><input type="hidden" name="response" id="response" value=""></td>
</tr>
</table>
</form>
</body>
</html>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.