Skip to content

Sqlmap cannot use socks5 proxy server with authentication #5409

@zlgxzswjy

Description

@zlgxzswjy

Describe the bug
Sqlmap cannot use socks5 proxy server with authentication

To Reproduce

  1. Run 'python3 sqlmap.py -u http://example.com --data="{"userName":"admin","password":"admin"}" --risk=3 --level=5 --batch --random-agent --threads=3 --proxy="socks5://x.x.x.x:1080" --proxy-cred="myuser:mypass" --debug'
  2. See error
[16:42:59] [INFO] testing connection to the target URL
Traceback (most recent call last):
  File "/root/sqlmap/lib/request/connect.py", line 622, in getPage
    conn = _urllib.request.urlopen(req)
  File "/usr/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.9/urllib/request.py", line 517, in open
    response = self._open(req, data)
  File "/usr/lib/python3.9/urllib/request.py", line 534, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 1375, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.9/urllib/request.py", line 1346, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/lib/python3.9/http/client.py", line 1255, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1301, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1250, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/root/sqlmap/lib/core/patch.py", line 63, in _send_output
    self.__send_output(*args, **kwargs)
  File "/usr/lib/python3.9/http/client.py", line 1010, in _send_output
    self.send(msg)
  File "/usr/lib/python3.9/http/client.py", line 950, in send
    self.connect()
  File "/usr/lib/python3.9/http/client.py", line 921, in connect
    self.sock = self._create_connection(
  File "/root/sqlmap/thirdparty/socks/socks.py", line 408, in create_connection
    sock.connect(address)
  File "/root/sqlmap/thirdparty/socks/socks.py", line 377, in connect
    self.__negotiatesocks5(destpair[0], destpair[1])
  File "/root/sqlmap/thirdparty/socks/socks.py", line 198, in __negotiatesocks5
    self.sendall(chr(0x01).encode() + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5])
TypeError: can't concat str to bytes
[16:42:59] [CRITICAL] unable to connect to the target URL or proxy. sqlmap is going to retry the request(s)
[16:42:59] [WARNING] if the problem persists please check that the provided target URL is reachable

If I configure the same SOCKS5 proxy server in proxychains and then start sqlmap through proxychains, everything is fine

It is also normal if I use a socks5 server without authentication

 File "/root/sqlmap/thirdparty/socks/socks.py", line 198, in __negotiatesocks5
    self.sendall(chr(0x01).encode() + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5])
TypeError: can't concat str to bytes

I noticed a type conversion error here

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Running environment:

  • sqlmap version [ < 1.7.4.11#dev]
  • Installation method [e.g. kali git clone]
  • Operating system: [e.g. kali ]
  • Python version [e.g. 3.11.2]

Target details:

  • DBMS [e.g. Microsoft SQL Server]
  • SQLi techniques found by sqlmap [e.g. error-based and boolean-based blind]
  • WAF/IPS [if any]
  • Relevant console output [if any]
  • Exception traceback [if any]

Additional context
Add any other context about the problem here.

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