curl не может договориться об ntlm - PullRequest
0 голосов
/ 23 октября 2018

Мой вопрос в основном заключается в том, способен ли curl успешно согласовать аутентификацию ntlm.Если нет, есть ли другие альтернативы?У меня есть сервер интрасети, на котором я пытаюсь пройти аутентификацию, и мне кажется, что он не работает.Я рассмотрел трассировку Firebug и Chrome Dev Tools, и диалог кажется похожим, но с одним большим отличием.Ответ chrome и firefox имеет длинный блок Authorization: Negotiate во втором сообщении-запросе, отправленном на сервер, а в curl его нет.Chrome и Firefox могут успешно войти в систему, но скручивание не удается.Ниже приведена трассировка http для curl.

$ curl http://home.server.com/mice/search.aspx -d "LoggingOn=1&username=myuser&password=pass&OK=1" -v  --negotiate --ntlm -u myuser:pass
* About to connect() to home.server.com port 80 (#0)
*   Trying 10.208.82.148... connected
* Connected to home.server.com (10.208.82.148) port 80 (#0)
> POST /mice/search.aspx HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: home.server.com
> Accept: */*
> Content-Length: 60
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 401 Unauthorized
< Content-Type: text/html
< Server: Microsoft-IIS/7.5
< WWW-Authenticate: Negotiate
< WWW-Authenticate: NTLM
< X-Powered-By: ASP.NET
< Date: Tue, 23 Oct 2018 09:27:29 GMT
< Content-Length: 1293
<
* Ignoring the response-body
* Connection #0 to host home.server.com left intact
* Issue another request to this URL: 'http://home.server.com/mice/search.aspx'
* Re-using existing connection! (#0) with host home.server.com
* Connected to home.server.com (10.208.82.148) port 80 (#0)
> POST /mice/search.aspx HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: home.server.com
> Accept: */*
> Content-Length: 60
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 401 Unauthorized
< Content-Type: text/html
< Server: Microsoft-IIS/7.5
* gss_init_sec_context() failed: : Credentials cache file '/tmp/krb5cc_0' not foundWWW-Authenticate: Negotiate
< WWW-Authenticate: NTLM
< X-Powered-By: ASP.NET
< Date: Tue, 23 Oct 2018 09:27:29 GMT
< Content-Length: 1293
<
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>401 - Unauthorized: Access is denied due to invalid credentials.</title>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
 <div class="content-container"><fieldset>
  <h2>401 - Unauthorized: Access is denied due to invalid credentials.</h2>
  <h3>You do not have permission to view this directory or page using the credentials that you supplied.</h3>
 </fieldset></div>
</div>
</body>
</html>
* Connection #0 to host home.server.com left intact
* Closing connection #0

А ниже находится http-след firebug.

> POST /mice/search.aspx HTTP/1.1
> Host: home.server.com
> User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> Accept-Language: en-US,en;q=0.5
> Accept-Encoding: gzip, deflate
> Referer: http://home.server.com/mice/search.aspx
> Cookie: ASP.NET_SessionId=4a4aprrcn5pukk55yvfcdt55
> DNT: 1
> Connection: keep-alive
> Upgrade-Insecure-Requests: 1
> POST DATA:
> LoggingOn=1
> username=myuser
> password=pass
> OK=1

< HTTP/1.1 401 Unauthorized
< Content-Type: text/html
< Server: Microsoft-IIS/7.5
< WWW-Authenticate: Negotiate
< NTLM
< X-Powered-By: ASP.NET
< Date: Tue, 23 Oct 2018 08:36:57 GMT
< Content-Length: 1293


> POST /mice/search.aspx HTTP/1.1
> Host: home.server.com
> User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> Accept-Language: en-US,en;q=0.5
> Accept-Encoding: gzip, deflate
> Referer: http://home.server.com/mice/search.aspx
> Cookie: ASP.NET_SessionId=4a4aprrcn5pukk55yvfcdt55
> DNT: 1
> Connection: keep-alive
> Upgrade-Insecure-Requests: 1
> Authorization: Negotiate QUCoIIKCDCCCg << VERY LONG BLOCK >> hwhx
> 
> POST DATA:
> LoggingOn=1
> username=myuser
> password=pass
> OK=1

< HTTP/1.1 200 OK
< Cache-Control: private
< Content-Type: text/html; charset=utf-8
< Content-Encoding: gzip
< Expires: Tue, 23 Oct 2018 08:36:57 GMT
< Vary: Accept-Encoding
< Server: Microsoft-IIS/7.5
< X-AspNet-Version: 2.0.50727
< Persistent-Auth: false
< X-Powered-By: ASP.NET
< WWW-Authenticate: Negotiate oYG2MIGzoAMKAQChCwYJKoZIgvcSAQICooGeBIGbYIGYBgkqhkiG9xIBAgICAG+BiDCBhaADAgEFoQMCAQ+ieTB3oAMCARKicARu5ofget0in7K5jGdKYRrIzVFbI4XnaXJyXuL3suqdp4rOlewe21/rB23F4V99Nefx4JYbxsAh9dAx4PaInF11dFZRnTcZdqbUHVTW+SPdSDJKTNqhRAssYiJnmaDiyJUhHoxiHlliv9qYKSD+ptY=
< Date: Tue, 23 Oct 2018 08:36:59 GMT
< Content-Length: 1256
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...