Jump to content

Recommended Posts

I don't know how but a user managed to input "something" into my script which got through all my validation yet he still managed to get a number input which according to my logs says +99999999  (dont know how the + got through)!

 

 

I have this as a validation check:

 

$StrengthInputOriginal = mysql_real_escape_string($_POST['strength']);
If($StrengthInputOriginal == '' OR !(number_format($StrengthInputOriginal))){
$StrengthInputOriginal = 0;
}

 

The log of the user shows:

 

Trained agility input +9999999999999 for gain of 8896888888890

 

How could such a number get through i even check its not that high of a number be he still managed it =/

Link to comment
https://forums.phpfreaks.com/topic/129143-solved-form-input-hack/
Share on other sites

I'm assuming the database field is set as an int type. If that's the case you only need to verify that the input is an integer - no need for mysql_real_escape_string().

 

And, number_format() would have no effect in the manner in which you are using it. According to the manual its oly return values are "A formatted version of number." So, it doesn't return false if the value is not a properly formatted number.

Trained strength input +9999 for gain of 39.996  < he still got through!!

 

Even though my gain shows 39.996 on the log its giving him like 900000 + i don't get what the hell he is inputting but its get throughts every time!

 

How do i check its integer only.

<input type="text" size="16" name="strength" value="">

 

 

<?php
$StrengthInputOriginal = mysql_real_escape_string($_POST['strength']);
If($StrengthInputOriginal == '' OR !(is_int($StrengthInputOriginal)) OR strlen($StrengthInputOriginal)>2){
$StrengthInputOriginal = 0;
}
?>

 

This doesn't seem to accept any number i put in.. it just gives me 0 every time :S

number_format does not return TRUE/FALSE, it returns a number...

 

maybe you should try is_numeric()

 

Like I said is_numeric will accept the '+' sign.

 

Finds whether the given variable is numeric. Numeric strings consist of optional sign, any number of digits, optional decimal part and optional exponential part. Thus +0123.45e6 is a valid numeric value.

 

You should use the regex that DW provided.

Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in gymstat.php on line 23

 

My val:

 

<?php
$StrengthInputOriginal = mysql_real_escape_string($_POST['strength']);
If(!(preg_match('^\d+$', $StrengthInputOriginal))) {
$StrengthInputOriginal = 0;
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.