Cracking HTTP Authentication:

When people think of authentication, they think login pages. But some services tuck away a gatekeeper at the protocol level—HTTP Authentication. Whether it’s Basic, Digest, or Bearer, understanding how these mechanisms work helps pentesters bypass them, crack them, or abuse them.

Here’s everything you need, step-by-step.

HTTP Authentication is a way of protecting resources using headers rather than web forms.

  • Basic Auth:
    • Sends username:password Base64-encoded in headers.
    • Easily intercepted if not over HTTPS.
  • Digest Auth:
    • Hashes credentials before sending (MD5).
    • Still crackable offline with tools.
  • Bearer Tokens / API Keys:
    • Uses a token (usually in Authorization header) to access resources.
    • Can be stolen or reused.
nmap -p 80,443 --script http-auth <target>

This reveals:

  • Type of authentication (Basic, Digest, NTLM, etc.)
  • Realm (auth scope)
  • Whether credentials are required
gobuster dir -u http://<target> -w /usr/share/wordlists/dirb/common.txt -k
  • Helps find hidden endpoints that may be auth-protected.
  • Visiting the endpoint shows a popup asking for credentials.
  • Inspect the WWW-Authenticate response header to identify the method:
    • Basic realm="Secure Area"
    • Digest realm="API Access"
curl -I http://<target>

Check for:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="Restricted Area"
  • Visit the endpoint
  • Intercept the response
  • Check the headers and test brute-forcing via Burp Intruder

🛠 Using Hydra (Basic Auth)

hydra -L users.txt -P passwords.txt <target> http-get /protected_page

🛠 Using Hydra (Digest Auth)

hydra -L users.txt -P passwords.txt <target> http-get /protected_page digest
curl -u admin:admin http://<target>/protected

If you see something like this in a request:

Authorization: Basic YWRtaW46YWRtaW4=

Decode it:

echo YWRtaW46YWRtaW4= | base64 -d
# admin:admin

If you capture this header:

Authorization: Bearer eyJhbGciOi...

Try reusing it directly or JWT tampering:

  • Decode using jwt.io or jwt-tool
  • Modify alg or payload
  • Re-sign if secret is weak
jwt_tool <token> -C -d

Once you’re authenticated…

  • Access hidden endpoints
  • Download backups or configuration files
  • Use Bearer tokens to call unauthorized endpoints
  • Bypass role restrictions if token isn’t validated properly
  • Try credentials on:
    • SSH
    • SMB
    • RDP
    • Web login forms
  • If you can MITM traffic or read proxy logs, you might recover plaintext Basic credentials

HTTP Auth may seem like a roadblock, but it’s often just a speed bump. Whether you’re decoding weak Base64 credentials, brute-forcing your way in, or replaying bearer tokens, knowing how these headers work gives you a real edge.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top