Im given control over the $vote variable (in the "challenge" function)
Is there any way to sql inject the query? (BTW I can see/read whatever the challenge function returns e.g. the sql errors.
I managed to inject the sql but was not able to find a way to nullify the $vote
+1" part so whatever I try to inject leads to a syntax error.)
function evil($vote)
{
#Comments not allowed ]:->
#Sorry.
$vote = str_replace('#', '', $vote);
$vote = str_replace('/', '', $vote);
$vote = str_replace('*', '', $vote);
$vote = str_replace('-', '', $vote);
return $vote;
}
function challenge($vote)
{
$vote = evil($vote);
$q = "UPDATE `sqlinjection2` SET `$vote`=`$vote`+1";
$r = mysql_query($q);
if(!$r)
return mysql_error();
return 'Thanks for vote!';
}