TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-02-2008, 01:52 PM   #1 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default Anatomy of this bug

Hi
Anyone know some info about this array bug, for example:

http://site.com/index.php?id[]=123

By putting those [] it will send an array and not a var.
So in some sites it says, that the value can't be mixed, etc, etc

I wanted to replicate this bug on my server by doing this:

PHP Code:
<?
error_reporting
(E_ALL);


echo 
htmlentities($_GET['id']);



?>
then I access it: http://localhost/testbug.php?id[]=asd
and nothing :S

Why htmlentities?? not sure, but I've seen a site where I did same and it showed:

Warning: htmlentities() expects parameter 1 to be string, array given in /home/enciclo/public_html/control/funciones-sec.php on line 17

So why my code is not buggy??
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Old 03-02-2008, 01:53 PM   #2 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default

Well what version of PHP where they using?
__________________
"What everyone seems to forget is that while knowledge certainly is something - it's the implementation of knowledge that brings power" - Andres Galindo.
TlcAndres is offline  
Reply With Quote
Old 03-02-2008, 02:01 PM   #3 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default

PHP 5.2.4 (cli) (built: Oct 16 2007 09:13:35)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Old 03-02-2008, 02:03 PM   #4 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

Silly question but do you have display_errors turned off? It should definately throw an error as it only takes a string.

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
The Following User Says Thank You to Alan @ CIT For This Useful Post:
freenity (03-02-2008)
Old 03-02-2008, 02:32 PM   #5 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

PHP Code:
ini_set('display_errors'1);
error_reportingE_ALL E_NOTICE ); 
But since when do you filter out HTML entities (like <i>myString</i>) in an ID? Simply filter it with is_numeric($var); or addslashes($var);
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
The Following User Says Thank You to ReSpawN For This Useful Post:
freenity (03-02-2008)
Old 03-02-2008, 03:43 PM   #6 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default

Quote:
Originally Posted by Alan @ CIT View Post
Silly question but do you have display_errors turned off? It should definately throw an error as it only takes a string.

Alan
silly but right XD
now it works


It's id parameter just for an example...

Thanks XD
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Old 03-02-2008, 03:46 PM   #7 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default

btw anyone knows how to insert vars into that array. I write:

http://localhost/testbug.php?id[]=2

and with var_dump($_GET) it shows me:

array(1) { ["id"]=> array(1) { [0]=> string(1) "2" } }

How do I "insert" values to the id array? :)
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Old 03-02-2008, 05:30 PM   #8 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

Well, since you want to insert it one at a time I suggest you simply use the array_push(); command.

PHP Code:
$myArray = array();
    if (
$_GET['id']) {
        
array_push($myArray$_GET['id']);
    } 
Otherwise, you can also do it in an foreach loop.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 03-02-2008, 07:58 PM   #9 (permalink)
The Contributor
 
DeMo's Avatar
 
Join Date: Jan 2008
Location: Brazil
Posts: 77
Thanks: 14
DeMo is on a distinguished road
Default

I think he wants to know if it's possible to pass more than one value for the array via the URL.
Send a message via ICQ to DeMo Send a message via MSN to DeMo Send a message via Skype™ to DeMo
DeMo is offline  
Reply With Quote
Old 03-02-2008, 08:54 PM   #10 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

Something like the following would work:

The Url:
Code:
your_script.php?id[]=15&id[]=20&id[]=30
Would create an array that looked something like:
Code:
// $_GET['id']

Array
(
    [0] => 15
    [1] => 20
    [2] => 30
)
You could then just access it like a normal array:
PHP Code:
echo $_GET['id'][1];
// Would echo '20' using the url above 
Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
The Following User Says Thank You to Alan @ CIT For This Useful Post:
freenity (03-02-2008)
Old 03-02-2008, 09:05 PM   #11 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default

yes, exactly what I wanted :)
thanks.

Quote:
Originally Posted by Alan @ CIT View Post
Something like the following would work:

The Url:
Code:
your_script.php?id[]=15&id[]=20&id[]=30
Would create an array that looked something like:
Code:
// $_GET['id']

Array
(
    [0] => 15
    [1] => 20
    [2] => 30
)
You could then just access it like a normal array:
PHP Code:
echo $_GET['id'][1];
// Would echo '20' using the url above 
Alan
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 06:54 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design