Skip to content

SQLMap fails to use http basic auth credentials correctly #4320

Closed

Description

@mkauschi

Describe the bug
When I am running SQLMap against a DVWA instance with basic auth enabled, SQLMap fails due to unauthorized requests. [CRITICAL] not authorized, try to provide right HTTP authentication type and valid credentials (401)

I double checked the basic auth credentials and they are correct.

I tried to debug this issue by intercepting SQLMap`s requests and found that every request is sent twice, one with the basic auth credentials and one without. (see the screenshot)

To Reproduce

  1. Run 'sqlmap --auth-type="Basic" --auth-cred="htaccess:htaccess" --batch --time-sec=20 --output-dir=./output --level=2 --risk=3 --method=get --answer="keep=Y,skip=N,follow=N,select=q,detect=Y,extending=Y,sure=Y" --url="http://127.0.0.1:80/vulnerabilities/sqli/?id=1&Submit=Submit"'

Expected behavior
I would expect SQLMap to send requests with the basic auth credentials only. Furthermore, I would expect SQLMap not to close with a not authorized error.

Screenshots
Screenshot at 2020-08-31 13-44-26

Running environment:

  • sqlmap version 1.4.4#stable and 1.4.8#stable
  • Ubuntu package manager (apt) and Arch Linux package manager (pacman)
  • Ubuntu and Arch Linux
  • Python version 3.8.5

Target details:

  • DVWA with basic auth enabled

Activity

  1. mkauschi commented on Aug 31, 2020

    @mkauschi
    ContributorAuthor

    It seems like the issue was introduced between version >1.3.10#stable and version 1.4.4#stable. With version 1.3.10#stable the issue does not appear. Maybe this information helps.

  2. stamparm commented on Aug 31, 2020

    @stamparm
    Member

    1

    2

  3. mkauschi commented on Aug 31, 2020

    @mkauschi
    ContributorAuthor

    It seems like you are not having this issue with your test application. Do you see a possibility to debug this further? When I am scanning the same test application with version 1.3.10 I do not experience this issue. After updating SQLMap to version 1.4.4 or later the scan stops due to a HTTP 401 code.

  4. stamparm commented on Aug 31, 2020

    @stamparm
    Member

    This page of yours does not use Basic authentication

  5. mkauschi commented on Aug 31, 2020

    @mkauschi
    ContributorAuthor

    Okay, I will continue investigating the issue tomorrow and drop a message if I could figure out what the problem is/was. I am just wondering why version 1.3.10 works nicely and version 1.4.4 does not.

  6. stamparm commented on Aug 31, 2020

    @stamparm
    Member

    i believe that you've messed up something.

    just do the regular "Submit" inside the firefox, go to "Network" tab inside web developer tool, "Copy as curl" and inside the shell replace curl with sqlmap

  7. stamparm commented on Aug 31, 2020

    @stamparm
    Member

    "Cookies" are the key here. There is no Basic authorization

    This is your same page in my shell:

    3

  8. mkauschi commented on Sep 1, 2020

    @mkauschi
    ContributorAuthor

    Hi Miroslav,
    I have to reopen this bug report because I dug more into SQLMaps code and found the issue. It was introduced from version 1.3.5 to version 1.3.6. The issue is in the class lib/request/connect.py (see screenshot).

    Screenshot at 2020-09-01 11-17-19

    For some reason the Basic authentication header is of type bytes now. SQLMap iterates over every field in the header and deletes it first. Then it checks if the instance is of type str and adds it again. Because the Basic authentication header is of type byte it is skipped and therefore removed from the headers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions