r/Hacking_Tutorials • u/Cyber_zulka • 5d ago
Question Part 2 is here — From Detecting NoSQLi to Bypassing Login With Operator Injection
If you saw my last post, you know I left you on a waitlist.
In Part 1, we talked about how to DETECT NoSQLi — how to tell when an app is passing your input straight into a MongoDB query.
This is Part 2: What you actually DO with it.
The target: A login form that sends JSON like this:
```json
{"username":"wiener","password":"peter"}
```
The mistake I kept making:
```json
{"username":{"$ne":"invalid"},"password":"peter"}
```
This does bypass the check, but it logs you in as wiener, not admin.
Why? $ne means "not equal to". So MongoDB just grabs the FIRST user that isn't "invalid" — and that's wiener.
The Part 2 payload that works:
```json
{"username":{"$regex":"admin.*"},"password":{"$ne":""}}
```
Here's what's happening:
- username with $regex: "admin.*" forces it to only look for users starting with admin
- password with $ne: "" means "password is not empty" — so you pass the password check without knowing the password
The lesson from Part 1 to Part 2:
Detecting it tells you the door is open. Operator injection is how you choose WHICH room you walk into.
If you only use $ne on the username, you get the first room. If you use $regex, you pick the admin room.
In Part 3, I'm going to show how to use this same idea to exfiltrate data when you can't login at all.
Drop a comment if you want me to tag you when Part 3 drops — and tell me, were you stuck on wiener too?
See full write up here