Home > Backend Development > PHP Tutorial > php mongodb injection_PHP tutorial

php mongodb injection_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-14 10:09:42
Original
873 people have browsed it


The following will introduce the methods and principles of php+mongodb injection

One of the posts said: login.php?username=admin&passwd[$ne]=1 may be injected. When I first read it, I felt quite puzzled. How could this have an injection vulnerability? Finally, from this The reason was found in this post http://hi.baidu.com/hi_heige/item/ce93ce926dede4f428164747. Because PHP can directly submit arrays, which means that the arrays containing the "$ne" index are submitted, I made a demo:


[php]
$passwd=$_GET["passwd"];
var_dump($passwd);

$passwd=$_GET["passwd"];
var_dump($passwd);
The test results are:

array(1) { ["$ne"]=> string(1) "1" }


In this case


[php]
$collection->find(array(
"username" => "admin",
"passwd" => array("$ne" => 1)
));

$collection->find(array(
"username" => "admin",
"passwd" => array("$ne" => 1)
));
It becomes:


[php]

$collection->find(array( "username" => "admin", "passwd" => array("$ne" => 1) )); $collection->find(array (
"username" => "admin",
"passwd" => array("$ne" => 1)
));


If you change the link to this (username=[$ne]=1&passwd[$ne]=1), then all user information will be obtained

The way to solve this bug is to force the parameters into string type after obtaining the parameters:

[php]
$collection->find(array(
"username" => (string)$_GET['username'],
"passwd" => (string)$_GET['passwd']
));

$collection->find(array(
"username" => (string)$_GET['username'],
"passwd" => (string)$_GET['passwd']
)); This is the same as executing the following mysql statement, both of which are injected with


[php]

mysql_query("SELECT * FROM collection
WHERE username="admin",
AND passwd!=1

mysql_query("SELECT * FROM collection
WHERE username="admin",
AND passwd!=1
I made a demo to test it, and it really works.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477615.htmlTechArticleThe following will introduce the method and principle of php+mongodb injection. One of the posts said: login.php?username= It is possible to inject adminpasswd[$ne]=1. When I first saw it, I felt quite puzzled. This...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template