Veilig scripten vraag

Gestart doorFreestyle6 reacties6 weergaven

7 berichten · pagina 1 van 1

Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb het volgende script

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]functies.php[/COLOR][COLOR= #007700];[/COLOR]
top[COLOR= #007700]();[/COLOR]
menu[COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<title>Admin | Linkpartners</title>[/COLOR][COLOR= #007700];[/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]user[/COLOR][COLOR= #007700]]))
{[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rank[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]rang[/COLOR][COLOR= #007700]] >[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700]) 
    {[/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]
            [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]website[/COLOR][COLOR= #007700]]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]backlink[/COLOR][COLOR= #007700]]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]beschrijving[/COLOR][COLOR= #007700]]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]catogorie[/COLOR][COLOR= #007700]]))
            {[/COLOR]
                [COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]U bent vergeten een van de velden in te vullen![/COLOR][COLOR= #007700];
            }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO linkpartners (website, link, backlin, beschrijving, catogorie)
                            VALEUS(
                            "[/COLOR][COLOR= #007700].[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]website[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]",
                            "[/COLOR][COLOR= #007700].[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]",
                            "[/COLOR][COLOR= #007700].[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]backlink[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]",
                            "[/COLOR][COLOR= #007700].[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]beschrijving[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]",
                            "[/COLOR][COLOR= #007700].[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]catogorie[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]"
                            )"[/COLOR][COLOR= #007700]);[/COLOR]
                [COLOR= #0000BB]$voltooid[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]De linkpartners is succesvol toegeveogd![/COLOR][COLOR= #007700];
            }
    
    } 
}[/COLOR]
footer[COLOR= #007700]();[/COLOR]
?>


Is dat veilig?
zo nee, Hoe kan ik het veiliger maken?

btw, de config word in de functies.php ge include.

Alvast bedankt
0
Berichten
3.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
VALEUS=VALUES
toegeveogd=toegevoegd
en in je bericht staat de config word en daar moet een t achter. Verder is je script beveiligd tegen SQL injecties, miss niet tegen cross-site-scripting maar dan zou ik je sessie-handler moeten zien.

Voor de beveiliging in deze pagina is het goed smile
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kyron schreef:
VALEUS=VALUES
toegeveogd=toegevoegd
en in je bericht staat de config word en daar moet een t achter. Verder is je script beveiligd tegen SQL injecties, miss niet tegen cross-site-scripting maar dan zou ik je sessie-handler moeten zien.

Voor de beveiliging in deze pagina is het goed smile

Heb je dan de login code nodig?
die wil ik best even plaatsen.

Bedankt voor die typ foutjesbloos (had ze net al wel ontdekt maar toch)
edit///
hij geeft deze fout:

Fatal error: Call to undefined function real_escape_string() in /home/marijn/domains/vanmarijn.nl/public_html/v2/admin_panel/linkpartners.php on line 21


Er is dus iets miss met de real_escpae

Gaat om deze regel:

[COLOR= #0000BB]<?php[/COLOR]                            [COLOR= #DD0000]".real_escape_string($_POST[[/COLOR]website[COLOR= #DD0000]])."[/COLOR][COLOR= #007700],[/COLOR]
?>
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
je moet ook mysql_real_escape_string gebruiken
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sjoerd schreef:
je moet ook mysql_real_escape_string gebruiken

Had ik al verandert (vergeten neer te zetten)
maar dan doet hij het nog steeds niet.

Dit is de code die ik nu helemaal heb:
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]functies.php[/COLOR][COLOR= #007700];[/COLOR]
top[COLOR= #007700]();[/COLOR]
menu[COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<title>Admin | Linkpartners</title>[/COLOR][COLOR= #007700];[/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]user[/COLOR][COLOR= #007700]]))
{[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rank[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]rang[/COLOR][COLOR= #007700]] >[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700]) 
    {[/COLOR]
        [COLOR= #0000BB]$datum[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"d M Y H:i"[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$show[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]0[/COLOR][COLOR= #007700];[/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]
            [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]website[/COLOR][COLOR= #007700]]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]backlink[/COLOR][COLOR= #007700]]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]beschrijving[/COLOR][COLOR= #007700]]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]catogorie[/COLOR][COLOR= #007700]]))
            {[/COLOR]
                [COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]U bent vergeten een van de velden in te vullen![/COLOR][COLOR= #007700];
            }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO linkpartners (website,link,backlink,beschrijving,catogorie,datum,show)
                            VALUES(
                            "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]website[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]",
                            "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]",
                            "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]backlink[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]",
                            "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]beschrijving[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]",
                            "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]catogorie[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]",
                            "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$datum[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]",
                            "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$show[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"
                            )"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Er is een fout op getreden;[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
                [COLOR= #0000BB]$voltooid[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]De linkpartners is succesvol toegevoegd![/COLOR][COLOR= #007700];
            }
        }[/COLOR]
?>
        <div class="bodytext" style="padding:12px;" align="justify">
            <strong>Linkpartners</strong><br />
            <br />
            Voeg linkpartners toe, accepteer linkpartners, verwijder linkpartners, pas linkpartners aan!
        </div>
        <div class="panel" align="justify">
            <span class="orangetitle">Linkpartners toevoegen</span>
            <span class="bodytext"><br />    
                <form action="linkpartners.php" method="POST">
                <table>
                    <tr>
                        <td>Website naam:</td><td><input type="text" name="website" /></td>
                    </tr>
                    <tr>
                        <td>Website url:</td><td><input type="text" name="link" /></td>
                    </tr>
                    <tr>
                        <td>Back link (waar komt onze website link te staan)</td><td><input type="text" name="backlink" /></td>
                    </tr>
                    <tr>
                        <td>Beschrijving: </td><td><input type="text" name="beschrijving" /></td>
                    </tr>
                    <tr>
                        <td>Catogorie:</td><td><select name="catogorie" >
                                                <option value="geld verdienen">Geld verdienen</option>
                                                <option value="webshop">Webshop</option>
                                                <option value="spel">spel</option>
                                                <option value="radio">radio</option>
                                                <option value="blog">Blog</option>
                                                <option value="forum">Forum/Community</option>
                                                <option value="overige">Overige</option
                                                </select></td>
                    </tr>
                    <tr>
                        <td><input type="submit" name="submit" value="Voeg toe!" /></td><td><input type="reset" value="Reset velden" /></td>
                    </tr>
                </table>
                </form>
            </span>
        </div>
            
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$error[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$voltooid[/COLOR][COLOR= #007700];
    } 
}[/COLOR]
footer[COLOR= #007700]();[/COLOR]
?>
error:

Er is een fout op getreden;You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near show) VALUES( sedio, test, test, Kwali at line 1
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
zet show in de query tussen ` s, dus `show`
0
Freestyle

Lid · Topicstarter

Berichten
7.681
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
het werkt nu. Bedankt!
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