Hi,
Véél mensen hebben hun eigen website, op een one2xs host of bij een ander verkoper.
Maar meestal is het zo dat ze géén beveiliging hebben op hun site.
Indeling
+ Inleiding
+ De manieren
+ Vervolgens, welke scripts te gebruiken?
Inleiding
In deze tutorial leer ik iedereen hoe je een website netjes beveiligt.
Er bestaan misschien andere topics over het beveiligen van een website,
maar hier leer ik het jullie in stappen met verschillende methodes.
Het is simpel uitgelegt, voor gevorderden en semi-pros.
______________________________________________________________________________
De manieren
We hebben véél manieren om een website te beveiligen, je kan het beveiligen na dat je een probleem hebt gehad of voor dat je de probleem hebt gehad.
Het is natuurlijk handiger om je website voor dat je een probleem hebt, te beveiligen.
- Sql-injecties (manier voor dat je een probleem hebt)
De term SQL-injectie (Engels: SQL injection) wordt gebruikt voor een type kwetsbaarheid van computerapplicaties, meestal webapplicaties. SQL-injectie kan gebeuren als invoer van gebruikers op onvoldoende gecontroleerde wijze wordt verwerkt in een SQL-statement.
Hoe begin je er aan?
Je gebruikt het op de volgende manier:
*
Getest op de volgende onderdelen van een (bijvoorbeeld) contactformulier.Hoe beginnen we eraan?
We includen eerst een functie.php documentje.
*
In de functie.php zet je een simpel codegeneratortje, het volgende:
We maken een voorbereiding voor ons Sql-injectie
Onder de vorige functie.php zet je de voorbereiding neer:
Als laatste tintje zetten we dit daar weer onder, dit is de daadwerkelijke code:
- Javascriptinjections (manier voor dat je een probleem hebt)
Wat deze functie doet, alles omzetten in html.
Hiermee hoeft te vrezen voor javascriptinjection ()
Het veranderd alle waarden en keys, dus alles is veilig.
**
- Website beveiligen met htaccess (manier na dat je een probleem hebt gehad)
Dit ken je misschien al, of simpel niet. Maar het is wel veilig als je net een probleem hebt gehad met bijvoorbeeld een injectie in een login script / iets anders. Dan kan je een .htaccess bestand gebruiken.
Door het IP adres te bannen.
Dan zet je de volgende regel in je bestand:
Hierbij is 000.000.000.000 het IP adres.
Vervolgens welke script te gebruiken?
Dit waren scripts die wel bruikbaar zijn voor websites met systemen zoals een loginsysteem of een contactsysteem. Wanneer jij misschien een script hebt die ook werkt mag je die gerust in de topic posten.
Bedankt voor het lezen
Bedankt voor het lezen van dit kleine tutorial.
In deze tutorial zijn 3 bronnen gebruikt. Als er typfouten staan wat wel zékér kan, zeg het en maak er geen kritiek van e.d.
Met vriendelijke groeten,
Christopher
Véél mensen hebben hun eigen website, op een one2xs host of bij een ander verkoper.
Maar meestal is het zo dat ze géén beveiliging hebben op hun site.
Indeling
+ Inleiding
+ De manieren
+ Vervolgens, welke scripts te gebruiken?
Inleiding
In deze tutorial leer ik iedereen hoe je een website netjes beveiligt.
Er bestaan misschien andere topics over het beveiligen van een website,
maar hier leer ik het jullie in stappen met verschillende methodes.
Het is simpel uitgelegt, voor gevorderden en semi-pros.
______________________________________________________________________________
De manieren
We hebben véél manieren om een website te beveiligen, je kan het beveiligen na dat je een probleem hebt gehad of voor dat je de probleem hebt gehad.
Het is natuurlijk handiger om je website voor dat je een probleem hebt, te beveiligen.
- Sql-injecties (manier voor dat je een probleem hebt)
De term SQL-injectie (Engels: SQL injection) wordt gebruikt voor een type kwetsbaarheid van computerapplicaties, meestal webapplicaties. SQL-injectie kan gebeuren als invoer van gebruikers op onvoldoende gecontroleerde wijze wordt verwerkt in een SQL-statement.
Hoe begin je er aan?
Je gebruikt het op de volgende manier:
[COLOR= #0000BB]<?[/COLOR]
[COLOR= #007700]<[/COLOR]form method[COLOR= #007700]=[/COLOR][COLOR= #DD0000]"post"[/COLOR][COLOR= #007700]>
<[/COLOR]input type[COLOR= #007700]=[/COLOR][COLOR= #DD0000]text[/COLOR] name[COLOR= #007700]=[/COLOR][COLOR= #DD0000]voorbeeld0[/COLOR]/[COLOR= #007700]>
<[/COLOR]input type[COLOR= #007700]=[/COLOR][COLOR= #DD0000]text[/COLOR] name[COLOR= #007700]=[/COLOR][COLOR= #DD0000]<?=$int?>voorbeeld1[/COLOR]/[COLOR= #007700]>[/COLOR] [COLOR= #FF8000]// of[/COLOR]
[COLOR= #007700]<[/COLOR]input type[COLOR= #007700]=[/COLOR][COLOR= #DD0000]text[/COLOR] name[COLOR= #007700]=[/COLOR][COLOR= #DD0000]<?php echo $int; ?>voorbeeld1[/COLOR]/[COLOR= #007700]>
<[/COLOR]input type[COLOR= #007700]=[/COLOR][COLOR= #DD0000]text[/COLOR] name[COLOR= #007700]=[/COLOR][COLOR= #DD0000]<?=$char?>voorbeeld2[/COLOR]/[COLOR= #007700]>[/COLOR] [COLOR= #FF8000]// of[/COLOR]
[COLOR= #007700]<[/COLOR]input type[COLOR= #007700]=[/COLOR][COLOR= #DD0000]text[/COLOR] name[COLOR= #007700]=[/COLOR][COLOR= #DD0000]<?php echo $char; ?>voorbeeld2[/COLOR]/[COLOR= #007700]>
<[/COLOR]input type[COLOR= #007700]=[/COLOR][COLOR= #DD0000]text[/COLOR] name[COLOR= #007700]=[/COLOR][COLOR= #DD0000]<?=$skip?>voorbeeld3[/COLOR]/[COLOR= #007700]>[/COLOR] [COLOR= #FF8000]// of[/COLOR]
[COLOR= #007700]<[/COLOR]input type[COLOR= #007700]=[/COLOR][COLOR= #DD0000]text[/COLOR] name[COLOR= #007700]=[/COLOR][COLOR= #DD0000]<?php echo $skip; ?>voorbeeld3[/COLOR]/[COLOR= #007700]>
<[/COLOR]input type[COLOR= #007700]=[/COLOR][COLOR= #DD0000]text[/COLOR] name[COLOR= #007700]=[/COLOR][COLOR= #DD0000]<?=$float?>voorbeeld4[/COLOR]/[COLOR= #007700]>[/COLOR] [COLOR= #FF8000]// of[/COLOR]
[COLOR= #007700]<[/COLOR]input type[COLOR= #007700]=[/COLOR][COLOR= #DD0000]text[/COLOR] name[COLOR= #007700]=[/COLOR][COLOR= #DD0000]<?php echo $float; ?>voorbeeld4[/COLOR]/[COLOR= #007700]>
<[/COLOR]/form[COLOR= #007700]>[/COLOR]
?> *
Getest op de volgende onderdelen van een (bijvoorbeeld) contactformulier.
Spoiler tonen
Het is getest op:
-input -> text
-input -> radio
-input -> checkboxes
-sql-injectie
-input -> text
-input -> radio
-input -> checkboxes
-sql-injectie
We includen eerst een functie.php documentje.
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include_once"]include_once[/URL][COLOR= #DD0000]"functies.php"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// het bestand waar de functie in staat[/COLOR]
[COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700]=[/COLOR]prep_array[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]// de functie die t m doet[/COLOR]
?> *
In de functie.php zet je een simpel codegeneratortje, het volgende:
[COLOR= #0000BB]<?[/COLOR] [COLOR= #007700]function[/COLOR] random_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$length[/COLOR][COLOR= #007700]){[/COLOR]
[COLOR= #0000BB]$string[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"abcdefghijklmnopqrstuvw01234567890"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$characters[/COLOR][COLOR= #007700]=[/COLOR]str_split[COLOR= #007700]([/COLOR][COLOR= #0000BB]$string[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$random_string[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$random_string[/COLOR][COLOR= #007700])<[/COLOR][COLOR= #0000BB]$length[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/shuffle"]shuffle[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$characters[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$random_string[/COLOR][COLOR= #007700].=[/COLOR][COLOR= #0000BB]$characters[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]];
}[/COLOR]
[URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$random_string[/COLOR][COLOR= #007700];
}[/COLOR]
?> We maken een voorbereiding voor ons Sql-injectie
Onder de vorige functie.php zet je de voorbereiding neer:
[COLOR= #0000BB]<?[/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]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prep_array[/COLOR][COLOR= #007700]])){[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prep_array_old[/COLOR][COLOR= #007700]]=[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prep_array[/COLOR][COLOR= #007700]];}[/COLOR]
[COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prep_array[/COLOR][COLOR= #007700]]=[/COLOR][URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR]
[COLOR= #DD0000]"char"[/COLOR][COLOR= #007700]=>[/COLOR]random_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]4[/COLOR][COLOR= #007700]),[/COLOR]
[COLOR= #DD0000]"int"[/COLOR][COLOR= #007700]=>[/COLOR]random_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]4[/COLOR][COLOR= #007700]),[/COLOR]
[COLOR= #DD0000]"float"[/COLOR][COLOR= #007700]=>[/COLOR]random_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]4[/COLOR][COLOR= #007700]),[/COLOR]
[COLOR= #DD0000]"skip"[/COLOR][COLOR= #007700]=>[/COLOR]random_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]4[/COLOR][COLOR= #007700]));[/COLOR]
[COLOR= #0000BB]$char[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prep_array[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]char[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"|||"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$int[/COLOR] [COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prep_array[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]int[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"|||"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$skip[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prep_array[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]skip[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"|||"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$float[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prep_array[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]float[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"|||"[/COLOR][COLOR= #007700];[/COLOR]
?> Als laatste tintje zetten we dit daar weer onder, dit is de daadwerkelijke code:
[COLOR= #0000BB]<?[/COLOR]
[COLOR= #007700]function[/COLOR] pre_prep_array[COLOR= #007700]([/COLOR][COLOR= #0000BB]$array[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$type[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]char[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$original[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]destroy[/COLOR][COLOR= #007700]){[/COLOR]
[COLOR= #0000BB]$returnArray[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$array[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$key[/COLOR][COLOR= #007700]=>[/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/is_array"]is_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700])){[/COLOR][COLOR= #0000BB]$returnArray[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$key[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]"No 3d+ arrays allowed"[/COLOR][COLOR= #007700];}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$type[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #DD0000]"int"[/COLOR][COLOR= #007700]) {[/COLOR][COLOR= #0000BB]$returnArray[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$key[/COLOR][COLOR= #007700]] =[/COLOR] prep_num[COLOR= #007700]([/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700]);}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$type[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #DD0000]"char"[/COLOR][COLOR= #007700]) {[/COLOR][COLOR= #0000BB]$returnArray[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$key[/COLOR][COLOR= #007700]] =[/COLOR] prep_char[COLOR= #007700]([/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700]);}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$type[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #DD0000]"float"[/COLOR][COLOR= #007700]){[/COLOR] [COLOR= #0000BB]$returnArray[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$key[/COLOR][COLOR= #007700]]=[/COLOR]prep_float[COLOR= #007700]([/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700]);}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$type[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #DD0000]"skip"[/COLOR][COLOR= #007700]) {[/COLOR][COLOR= #0000BB]$returnArray[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$key[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$value[/COLOR][COLOR= #007700];}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$type[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #DD0000]"error"[/COLOR][COLOR= #007700]) {[/COLOR][COLOR= #0000BB]$returnArray[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$key[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]"Ongeldig!"[/COLOR][COLOR= #007700];}[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$original[/COLOR][COLOR= #007700]!=[/COLOR][COLOR= #DD0000]destroy[/COLOR][COLOR= #007700]){[/COLOR][COLOR= #0000BB]$returnArray[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$key[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"_old"[/COLOR][COLOR= #007700]]=[/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700];}
}[/COLOR][COLOR= #FF8000]//-- einde foreach[/COLOR]
[URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$returnArray[/COLOR][COLOR= #007700];
}[/COLOR][COLOR= #FF8000]//--einde pre_prep_array[/COLOR]
[COLOR= #007700]function[/COLOR] prep_array[COLOR= #007700]([/COLOR][COLOR= #0000BB]$array[/COLOR][COLOR= #007700]){[/COLOR]
[COLOR= #0000BB]$returnArray[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$array[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$key[/COLOR][COLOR= #007700]=>[/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700]){[/COLOR]
[COLOR= #0000BB]$controle[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/explode"]explode[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"|||"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$key[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$controle[/COLOR][COLOR= #007700])>[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$controle[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]]==[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prep_array_old[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]int[/COLOR][COLOR= #007700]]) {[/COLOR][COLOR= #0000BB]$type[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]int[/COLOR][COLOR= #007700];}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$controle[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]]==[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prep_array_old[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]char[/COLOR][COLOR= #007700]]){[/COLOR][COLOR= #0000BB]$type[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]char[/COLOR][COLOR= #007700];}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$controle[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]]==[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prep_array_old[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]float[/COLOR][COLOR= #007700]]){[/COLOR][COLOR= #0000BB]$type[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]float[/COLOR][COLOR= #007700];}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$controle[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]]==[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prep_array_old[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]skip[/COLOR][COLOR= #007700]]){[/COLOR][COLOR= #0000BB]$type[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]skip[/COLOR][COLOR= #007700];}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/in_array"]in_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$controle[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]prep_array_old[/COLOR][COLOR= #007700]])){[/COLOR][COLOR= #0000BB]$type[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]error[/COLOR][COLOR= #007700];}[/COLOR]
[COLOR= #FF8000]// error komt als er een SQLinjectie plaatsvind, of iemand de pagina vernieuwd[/COLOR]
[COLOR= #0000BB]$key[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$controle[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]];
}[/COLOR][COLOR= #FF8000]//einde count >1[/COLOR]
[URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR][COLOR= #0000BB]$type[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]char[/COLOR][COLOR= #007700];}[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/is_array"]is_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700])){[/COLOR]
[COLOR= #0000BB]$returnArray[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$key[/COLOR][COLOR= #007700]]=[/COLOR]pre_prep_array[COLOR= #007700]([/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$type[/COLOR][COLOR= #007700]);
}[/COLOR][COLOR= #FF8000]//--einde foreach in foreach[/COLOR]
[URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$value[/COLOR] [COLOR= #007700]=[/COLOR] pre_prep_array[COLOR= #007700]([/COLOR][URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700]),[/COLOR][COLOR= #0000BB]$type[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$value[/COLOR][COLOR= #007700]=[/COLOR] [URL="http://www.php.net/implode"]implode[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$returnArray[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$key[/COLOR][COLOR= #007700]]=[/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700];
}
}[/COLOR][COLOR= #FF8000]//-- einde foreach[/COLOR]
[URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$returnArray[/COLOR][COLOR= #007700];
}[/COLOR][COLOR= #FF8000]//-- einde functie prep_array[/COLOR]
?> - Javascriptinjections (manier voor dat je een probleem hebt)
Wat deze functie doet, alles omzetten in html.
Hiermee hoeft te vrezen voor javascriptinjection ()
Het veranderd alle waarden en keys, dus alles is veilig.
[COLOR= #0000BB]<?[/COLOR]
[COLOR= #007700]function[/COLOR] safety[COLOR= #007700]([/COLOR] [COLOR= #0000BB]$array[/COLOR] [COLOR= #007700])
{[/COLOR]
[COLOR= #0000BB]$array2[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR] [COLOR= #0000BB]$array[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$key[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]$value[/COLOR] [COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR] [URL="http://www.php.net/get_magic_quotes_gpc"]get_magic_quotes_gpc[/URL][COLOR= #007700]() )
{[/COLOR]
[COLOR= #0000BB]$key[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$key[/COLOR][COLOR= #007700]);
}[/COLOR]
[COLOR= #0000BB]$key[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/str_replace"]str_replace[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"\\0"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"\"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"\0"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]),[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$key[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$key[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$key[/COLOR][COLOR= #007700],[/COLOR]ENT_QUOTES[COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR] [URL="http://www.php.net/is_array"]is_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700]) )
{[/COLOR]
[COLOR= #0000BB]$value[/COLOR] [COLOR= #007700]=[/COLOR] safety[COLOR= #007700]([/COLOR] [COLOR= #0000BB]$value[/COLOR] [COLOR= #007700]);
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR] [URL="http://www.php.net/get_magic_quotes_gpc"]get_magic_quotes_gpc[/URL][COLOR= #007700]() )
{[/COLOR]
[COLOR= #0000BB]$value[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700]);
}[/COLOR]
[COLOR= #0000BB]$value[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/str_replace"]str_replace[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"\\0"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"\"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"\0"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]),[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$value[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$value[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700],[/COLOR]ENT_QUOTES[COLOR= #007700]);
}[/COLOR]
[COLOR= #0000BB]$array2[/COLOR][COLOR= #007700][[/COLOR] [COLOR= #0000BB]$key[/COLOR] [COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$value[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$array2[/COLOR][COLOR= #007700];
}[/COLOR]
[COLOR= #0000BB]$_POST[/COLOR] [COLOR= #007700]=[/COLOR] safety[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700]);[/COLOR]
?> **
- Website beveiligen met htaccess (manier na dat je een probleem hebt gehad)
Dit ken je misschien al, of simpel niet. Maar het is wel veilig als je net een probleem hebt gehad met bijvoorbeeld een injectie in een login script / iets anders. Dan kan je een .htaccess bestand gebruiken.
Door het IP adres te bannen.
Dan zet je de volgende regel in je bestand:
deny from 000.000.000.000 Hierbij is 000.000.000.000 het IP adres.
Vervolgens welke script te gebruiken?
Dit waren scripts die wel bruikbaar zijn voor websites met systemen zoals een loginsysteem of een contactsysteem. Wanneer jij misschien een script hebt die ook werkt mag je die gerust in de topic posten.
Bedankt voor het lezen
Bedankt voor het lezen van dit kleine tutorial.
In deze tutorial zijn 3 bronnen gebruikt. Als er typfouten staan wat wel zékér kan, zeg het en maak er geen kritiek van e.d.
Met vriendelijke groeten,
Christopher
Spoiler tonen
Bronnen van scripting:
* = Auteur: Martijn - 06 november 2008 - 17:04
** = Auteur: Dolfje - 25 september 2005 - 21:15
* = Auteur: Martijn - 06 november 2008 - 17:04
** = Auteur: Dolfje - 25 september 2005 - 21:15
Ga ik zeker gebruiken.