通过xmlns使用Python进行检查

问题描述 投票:0回答:1

我使用urllib登录网站,但我得到一个验证页面。我不明白我必须发送给服务器以克服障碍的答案。我想我知道我必须发送POST,但是通过发送所有内容我没有得到理想的结果。我应该发送一些特别的东西吗?东西?

如果有人可以帮助我,我将非常感激。谢谢。

这是我登录后得到的巨大答案...

<html>
 <head>
  <title>Working...</title> </head>
   <body> 
    <form method="POST" name="hiddenform" action="https://site.domain.com:443/"> 
     <input type="hidden" name="wa" value="wsignin1.0" /> 
      <input type="hidden" name="wresult" 
       value="&lt;t:RequestSecurityTokenResponse  xmlns:t=&quot; 
       http://schemas.xmlsoap.org/ws/2005/02/trust&quot;>
       &lt;  t:Lifetime>&lt; 
       wsu:Created xmlns:wsu=&quot; 
       http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd&quot;
       >2020-04-04T19:44:03.524Z&lt; 
       /wsu:Created>&lt;  wsu:Expires xmlns:wsu=&quot; 
       http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd&quot;
       >2020-04-04T20:44:03.524Z&lt;    
       /wsu:Expires>&lt;/t:Lifetime>&lt;  wsp:AppliesTo        xmlns:wsp=&quot; 
       http://schemas.xmlsoap.org/ws/2004/09/policy&quot; 
       >&lt;  wsa:EndpointReference xmlns:wsa=&quot;  http://www.w3.org/2005/08/addressing&quot; 
       >&lt;  wsa:Address>https://site.domain.com&lt;  /wsa:Address>&lt;  /wsa:EndpointReference>&lt;  /wsp:AppliesTo>&lt; 
       t:RequestedSecurityToken>&lt;  saml:Assertion MajorVersion=&quot; 
       1&quot;   MinorVersion=&quot;  1&quot;   AssertionID=&quot; 
       _a0230c49-7fed-4469-bf9e-702b63ee7477&quot;   Issuer=&quot;  http://site2.domain.comadfs/services/trust&quot;  
       IssueInstant=&quot;  2020-04-04T19:44:03.524Z&quot;  
       xmlns:saml=&quot;  urn:oasis:names:tc:SAML:1.0:assertion&quot; 
       >&lt;  saml:Conditions NotBefore=&quot;  2020-04-04T19:44:03.524Z&quot;   NotOnOrAfter=&quot; 
       2020-04-04T20:44:03.524Z&quot; 
       >&lt;  saml:AudienceRestrictionCondition>&lt;  saml:Audience>https://site.domain.com&lt;  /saml:Audience>&lt; 
       /saml:AudienceRestrictionCondition>&lt;  /saml:Conditions>&lt; 
       saml:AttributeStatement>&lt;  saml:Subject>&lt; 
       saml:SubjectConfirmation>&lt; 
       saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer&lt; 
       /saml:ConfirmationMethod>&lt;  /saml:SubjectConfirmation>&lt; 
       /saml:Subject>&lt;  saml:Attribute AttributeName=&quot; 
       implicitupn&quot;   AttributeNamespace=&quot; 
       http://schemas.xmlsoap.org/ws/2005/05/identity/claims&quot; 
       >&lt;  saml:AttributeValue>[email protected]&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  accountthrottled&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/ws/2017/04/identity/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue b:type=&quot;  tn:boolean&quot;   xmlns:tn=&quot;  http://www.w3.org/2001/XMLSchema&quot;  
       xmlns:b=&quot;  http://www.w3.org/2001/XMLSchema-instance&quot; 
       >false&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute AttributeName=&quot;  familiarlocation&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/ws/2017/04/identity/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue b:type=&quot;  tn:boolean&quot;   xmlns:tn=&quot;  http://www.w3.org/2001/XMLSchema&quot;  
       xmlns:b=&quot;  http://www.w3.org/2001/XMLSchema-instance&quot; 
       >true&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute AttributeName=&quot;  authnmethodsproviders&quot;  
       AttributeNamespace=&quot;  http://schemas.microsoft.com/claims&quot; 
       >&lt;  saml:AttributeValue>FormsAuthentication&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  anchorclaimtype&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/ws/2014/01/identity/claims&quot; 
       >&lt;  saml:AttributeValue>http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname&lt;
       /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  upn&quot;   AttributeNamespace=&quot; 
       http://schemas.xmlsoap.org/ws/2005/05/identity/claims&quot; 
       >&lt;  saml:AttributeValue>[email protected]&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  primarygroupsid&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/ws/2008/06/identity/claims&quot; 
       >&lt;  saml:AttributeValue>S-1-5-21-4287071985-2918672672-1443967343-513&lt;
       /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  primarysid&quot;   AttributeNamespace=&quot; 
       http://schemas.microsoft.com/ws/2008/06/identity/claims&quot; 
       >&lt;  saml:AttributeValue>S-1-5-21-4287071985-2918672672-1443967343-48981&lt;
       /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  name&quot;   AttributeNamespace=&quot; 
       http://schemas.xmlsoap.org/ws/2005/05/identity/claims&quot; 
       >&lt;  saml:AttributeValue>Username1&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute AttributeName=&quot; 
       windowsaccountname&quot;   AttributeNamespace=&quot; 
       http://schemas.microsoft.com/ws/2008/06/identity/claims&quot; 
       >
&lt;  saml:AttributeValue>Username1&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute AttributeName=&quot; 
       authnmethodsreferences&quot;   AttributeNamespace=&quot; 
       http://schemas.microsoft.com/claims&quot; 
       >&lt;  saml:AttributeValue>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport&lt;
       /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  groupsid&quot;   AttributeNamespace=&quot; 
       http://schemas.microsoft.com/ws/2008/06/identity/claims&quot; 
       >&lt;  saml:AttributeValue>S-1-5-21-4287071985-2918672672-1443967343-513&lt;
       /saml:AttributeValue>&lt;  saml:AttributeValue>S-1-1-0&lt; 
       /saml:AttributeValue>&lt;  saml:AttributeValue>S-1-5-32-545&lt; 
       /saml:AttributeValue>&lt;  saml:AttributeValue>S-1-5-2&lt; 
       /saml:AttributeValue>&lt;  saml:AttributeValue>S-1-5-11&lt; 
       /saml:AttributeValue>&lt;  saml:AttributeValue>S-1-5-15&lt; 
       /saml:AttributeValue>&lt; 
       saml:AttributeValue>S-1-5-21-4287071985-2918672672-1443967343-13989&lt;
       /saml:AttributeValue>&lt; 
       saml:AttributeValue>S-1-5-21-4287071985-2918672672-1443967343-38388&lt;
       /saml:AttributeValue>&lt; 
       saml:AttributeValue>S-1-5-21-4287071985-2918672672-1443967343-22934&lt;
       /saml:AttributeValue>&lt; 
       saml:AttributeValue>S-1-5-21-4287071985-2918672672-1443967343-11501&lt;
       /saml:AttributeValue>&lt;  saml:AttributeValue>S-1-18-2&lt; 
       /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  x-ms-client-user-agent&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/2012/01/requestcontext/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue>Mozilla/5.0 (X11;   Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99
       Safari/537.36&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt; 
       saml:Attribute AttributeName=&quot; 
       x-ms-endpoint-absolute-path&quot;   AttributeNamespace=&quot; 
       http://schemas.microsoft.com/2012/01/requestcontext/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue>/adfs/ls/&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute AttributeName=&quot; 
       insidecorporatenetwork&quot;   AttributeNamespace=&quot; 
       http://schemas.microsoft.com/ws/2012/01&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue b:type=&quot;  tn:boolean&quot;   xmlns:tn=&quot;  http://www.w3.org/2001/XMLSchema&quot;  
       xmlns:b=&quot;  http://www.w3.org/2001/XMLSchema-instance&quot; 
       >false&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute AttributeName=&quot;  x-ms-proxy&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/2012/01/requestcontext/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue>WAPDMZMR01&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute AttributeName=&quot; 
       client-request-id&quot;   AttributeNamespace=&quot; 
       http://schemas.microsoft.com/2012/01/requestcontext/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue>605e2c74-b033-4ca8-81c4-0380010000ba&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  relyingpartytrustid&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/2012/01/requestcontext/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue>https://site.domain.com&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  x-ms-client-ip&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/2012/01/requestcontext/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue>10.244.3.252&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt;  saml:Attribute
       AttributeName=&quot;  x-ms-forwarded-client-ip&quot;  
       AttributeNamespace=&quot; 
       http://schemas.microsoft.com/2012/01/requestcontext/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue>172.16.8.2&lt;  /saml:AttributeValue>&lt;  saml:AttributeValue>85.203.20.10&lt;  /saml:AttributeValue>&lt; 
       /saml:Attribute>&lt;  saml:Attribute AttributeName=&quot; 
       userip&quot;   AttributeNamespace=&quot; 
       http://schemas.microsoft.com/2014/09/requestcontext/claims&quot;  
       a:OriginalIssuer=&quot;  CLIENT CONTEXT&quot;   xmlns:a=&quot; 
       http://schemas.xmlsoap.org/ws/2009/09/identity/claims&quot; 
       >&lt;  saml:AttributeValue>85.203.20.10&lt;  /saml:AttributeValue>&lt;  /saml:Attribute>&lt; 
       /saml:AttributeStatement>&lt;  saml:AuthenticationStatement
       AuthenticationMethod=&quot; 
       urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport&quot;
       AuthenticationInstant=&quot;  2020-04-04T19:44:03.430Z&quot; 
       >&lt;  saml:Subject>&lt;  saml:SubjectConfirmation>&lt;  saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer&lt; 
       /saml:ConfirmationMethod>&lt;  /saml:SubjectConfirmation>&lt; 
       /saml:Subject>&lt;  /saml:AuthenticationStatement>&lt;  ds:Signature
       xmlns:ds=&quot;  http://www.w3.org/2000/09/xmldsig#&quot; 
       >&lt;  ds:SignedInfo>&lt;  ds:CanonicalizationMethod Algorithm=&quot;  http://www.w3.org/2001/10/xml-exc-c14n#&quot;   />&lt; 
       ds:SignatureMethod Algorithm=&quot; 
       http://www.w3.org/2001/04/xmldsig-more#rsa-sha256&quot;   />&lt; 
       ds:Reference URI=&quot; 
       #_a0230c49-7fed-4469-bf9e-702b63ee7477&quot; 
       >&lt;  ds:Transforms>&lt;  ds:Transform Algorithm=&quot;  http://www.w3.org/2000/09/xmldsig#enveloped-signature&quot;   />&lt; 
       ds:Transform Algorithm=&quot; 
       http://www.w3.org/2001/10/xml-exc-c14n#&quot;   />&lt; 
       /ds:Transforms>&lt;  ds:DigestMethod Algorithm=&quot; 
       http://www.w3.org/2001/04/xmlenc#sha256&quot;   />&lt; 
       ds:DigestValue>b1c+9bvSmPpFNvScSNJJpTbJ6LwIyo1RCvDVKY8QeuI=&lt; 
       /ds:DigestValue>&lt;  /ds:Reference>&lt;  /ds:SignedInfo>&lt; 
       ds:SignatureValue>LA1dNOW7en/qQ5Z90WZTZ0Asb+BHubYP2MwDdGYh0AjsJMl+YIzC66h8hQfASOThETLlkwCkyOF1bvghWzOB6ZO/GgCgsGaEf8/Ed38zJVis2oFyAJz5Jj9XJ3tHRrpbFQdNEO8NHC8e8QgSiMep1j96rnT7BNiNqpkbCLsC/BB9B/c2RS6tYXRZhKVneXQtZAMjywgd+OH0IiUbbpiBbK2+/X16UhyHUTWzs6CJI7Pv9SQY6rv+PIdAp0iZugOmmufyEuHgHcqjMW9w64HBONSRIwqJ7/blEKGGto1Urp4vxzpMjr7428AZikr4rG/09ublQZ+WEjhwgEZlh/BDUw==&lt;
       /ds:SignatureValue>&lt;  KeyInfo xmlns=&quot; 
       http://www.w3.org/2000/09/xmldsig#&quot; 
       >&lt;  X509Data>&lt;  X509Certificate>MIICzjCCAbagAwIBAgIQI9D9o/iPMbpLE+TnZuC+ITANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDExhBREZTIFNpZ25pbmcgLSBmcy5hdG0uaXQwHhcNMTkxMTE5MjMwOTQ5WhcNMjAxMTE4MjMwOTQ5WjAjMSEwHwYDVQQDExhBREZTIFNpZ25pbmcgLSBmcy5hdG0uaXQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCkFFIK/Cn7t3E5VQ2jII/aH+2oEuK43MgtZp7hOcu431R3aUkXbevBVoOs5t6dOs2She9JL48RwcFeb6T1eiMT3HoYYfXERma4gy0SPQmGed1qtEApVo+Stxt4/V1B125tlpn9/xfpBasHyP/qCQIPSFxfgwRRYTN+cUtN9Wxjuw4m+dIySdk9c9POFvoC9vgB5tTSugWz2x02Cfi+hkDhWnPOaHFPE3V0vUZ3DGpJfiBGQizhnbZqaizjO6yQdWtkisoNX89GEmh6VTexSzlW9GCtDHLOqSjbkfEm8hU8H6kYsicot4ama/9RNcNHBx/kODPilIESuSm0zpyNEfw1AgMBAAEwDQYJKoZIhvcNAQELBQADggEBAD3LajP8S7I0fzl8rYqcmmhwsh6LvCVgigclt2YkFLD6MCJueacBs5NUcMmsiGa5JiY/FC405Iw9S2GhzBjNejDsyZAtplV/IShT6OOAp3GAWTkNDQoGdejbsExeRkFMCMAlLy2Nq1mnB6YwEMo4bHodG+ghQihxgSWQuFePKMuyrlZwvz07PDL56MCjiNrN+i1SHd1XCSwxpB2hY8LYN3EGqezKdyBbyVhAKgXTILPinxf1yciyoazLAg/5bMG33jTf31ijBDmsqbBD9FlDvUGp30uRXkbEUz/YXJC+p3acBmaUL5jGdyrO8dNj6ENYwmHEjlnLAAuBdDr9ly1czJM=&lt;
       /X509Certificate>&lt;  /X509Data>&lt;  /KeyInfo>&lt; 
       /ds:Signature>&lt;  /saml:Assertion>&lt; 
       /t:RequestedSecurityToken>&lt; 
       t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion&lt; 
       /t:TokenType>&lt; 
       t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue&lt; 
       /t:RequestType>&lt; 
       t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey&lt;
       /t:KeyType>&lt;  /t:RequestSecurityTokenResponse>" /><input
       type="hidden" name="wctx" value="rm=0&amp;  id=passive&amp;  ru=%2f"
       /><noscript><p>Script is disabled. Click Submit to continue.</p>
       <input type="submit" value="Submit" /></noscript></form> <script
       language="javascript">window.setTimeout('document.forms[0].submit()',
       0);  </script></body></html>
python xml post input
1个回答
0
投票
<input type="hidden" name="wa" value="wsignin1.0" /> <input type="hidden" name="wresult" value="(encoded XML)" /> <input type="hidden" name="wctx" value="rm=0&amp; id=passive&amp; ru=%2f"/>

并且网站在页面加载后立即使用脚本发布该表单:

window.setTimeout('document.forms[0].submit()', 0); 

这意味着您需要执行相同的操作。

了解如何从响应HTML中检索表单字段及其值。

    了解如何使用Python进行表单发布。当然可以使用urllib进行此操作,但是可以使用更高级的库,例如requests it's much easier
  1. [添加这三个表单字段及其值,并向<form>的action属性中的URL发送POST请求。
  2. Web抓取库scrapy also offers a feature for doing this,这将使步骤#1和#2更容易。
  • (没有代码示例,您应该能够使用上述信息将其全部弄清。)
  • © www.soinside.com 2019 - 2024. All rights reserved.