Zijn jullie er klaar voor???
Afbeelding niet beschikbaarDe bron kon niet worden geladen (cdn.head-fi.org).Bron openen ↗Fijn! Daar gaan we dan!
Dit script is dus
super lek, zon lek waarvoor je je loodgieter moet bellen.
[COLOR= #0000BB]<?php
$category[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]category[/COLOR][COLOR= #007700]]);[/COLOR]
?>
Serieus?
Gebruik geen htmlentities als je iets insert in de table, dit doe je enkel bij de output. Je wilt je db-data zo puur mogelijk houden. Tevens ook lek tegen SQL injection.
We kruipen nu wat dieper in die stinkhole die je gereleased hebt...
Wat grappig!
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]// Check om te kijken of het lid bestaat[/COLOR]
[COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT COUNT(*) num FROM users WHERE username = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]// De gebruiker aanmaken[/COLOR]
[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$db[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO user (username, password, date) VALUES($username, $password, $date)"[/COLOR][COLOR= #007700]);[/COLOR]
Afbeelding niet beschikbaarDe bron kon niet worden geladen (cdn.alltheragefaces.com).Bron openen ↗Om te kijken of het lid bestaat beveilig je jezelf wel tegen SQL injection, maar bij het aanmaken niet. Beetje flauw.
Oh maar! In login.php gebruik je dit keer niet mysql_real_escape_string maar dat gedrocht van strip_tags in plaats.
[COLOR= #0000BB]<?php
$user[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$user[/COLOR][COLOR= #007700]);[/COLOR]
?>
Even verder gaan... logout.php is waarschijnlijk het beste deel van het script (grotendeels omdat er maar 7 lijnen code zijn en dat je daarom weinig fout kunt doen). Maar het bevat nog steeds fouten. Misschien is het beter om te kijken of het lid wel eerst is ingelogd alvorens je het lid uitlogt. Kleine tip.
En in new_post.php behandel je dan wel weer SQL injection.
[COLOR= #0000BB]<?php
$title[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$db[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$title[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$body[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$db[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$body[/COLOR][COLOR= #007700]);[/COLOR]
?>
Er is bijna licht aan het einde van de tunnel...
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] mysqli_fetch_array[COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]))
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td><h4>"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]"</h4></td>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td><h4>"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]date[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]"</h4></td>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</tr>"[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</table>"[/COLOR][COLOR= #007700];[/COLOR]
?>
Hmmm... hier zou je dan htmlentities() moeten gebruiken en niet bij het registreren want....
Quote:
Gebruik geen htmlentities als je iets insert in de table, dit doe je enkel bij de output. Je wilt je db-data zo puur mogelijk houden.
Verder heb ik nog een foutje gevonden:
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700]->[/COLOR]body[COLOR= #007700]);[/COLOR] ?>
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<br>Posted on <i>"[/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$test[/COLOR][COLOR= #007700]->[/COLOR]posted[COLOR= #007700]).[/COLOR][COLOR= #DD0000]"</i>"[/COLOR][COLOR= #007700];[/COLOR] ?>
Moet die $test niet $row zijn? Komt er van als je error reporting uit zet.
Kortom: uber lek en slecht script. Iedere file van de admin heeft wel 1 of meer lekken. Je bent ook super incosistent. De ene pagina beveilig je wel voor XSS en SQL injection, de andere niet.
Afbeelding niet beschikbaarDe bron kon niet worden geladen (assets.diylol.com).Bron openen ↗ PS: HAAL JE VARIABLEN BUITEN QUOTES!!!!!!!!!