当前位置: 首页>>代码示例>>Python>>正文


Python smb.SPNEGO_NegTokenInit方法代码示例

本文整理汇总了Python中impacket.smb.SPNEGO_NegTokenInit方法的典型用法代码示例。如果您正苦于以下问题:Python smb.SPNEGO_NegTokenInit方法的具体用法?Python smb.SPNEGO_NegTokenInit怎么用?Python smb.SPNEGO_NegTokenInit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在impacket.smb的用法示例。


在下文中一共展示了smb.SPNEGO_NegTokenInit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_negTokenInit

# 需要导入模块: from impacket import smb [as 别名]
# 或者: from impacket.smb import SPNEGO_NegTokenInit [as 别名]
def test_negTokenInit(self):
        token = smb.SPNEGO_NegTokenInit()
        token.fromString(self.negTokenInit)
        self.assertTrue(self.negTokenInit, token.getData()) 
开发者ID:joxeankoret,项目名称:CVE-2017-7494,代码行数:6,代码来源:test_spnego.py

示例2: test_negTokenInit2

# 需要导入模块: from impacket import smb [as 别名]
# 或者: from impacket.smb import SPNEGO_NegTokenInit [as 别名]
def test_negTokenInit2(self):
        token = smb.SPNEGO_NegTokenInit()
        token.fromString(self.negTokenInit2)
        self.assertTrue(self.negTokenInit2, token.getData()) 
开发者ID:joxeankoret,项目名称:CVE-2017-7494,代码行数:6,代码来源:test_spnego.py

示例3: request_SMBv23

# 需要导入模块: from impacket import smb [as 别名]
# 或者: from impacket.smb import SPNEGO_NegTokenInit [as 别名]
def request_SMBv23(host, port=445):

  # start client
  smb_client = smb3.SMB3(host, host, sess_port=port)
  
  # start: modified from login()
  # https://github.com/SecureAuthCorp/impacket/blob/master/impacket/smb3.py
  
  session_setup = smb3.SMB2SessionSetup()
  
  if smb_client.RequireMessageSigning is True:
    session_setup['SecurityMode'] = smb3.SMB2_NEGOTIATE_SIGNING_REQUIRED
  else:
    session_setup['SecurityMode'] = smb3.SMB2_NEGOTIATE_SIGNING_ENABLED
  
  session_setup['Flags'] = 0
  
  ## NTLMSSP
  blob = smb3.SPNEGO_NegTokenInit()
  blob['MechTypes'] = [smb3.TypesMech['NTLMSSP - Microsoft NTLM Security Support Provider']]
  
  auth = ntlm.getNTLMSSPType1(smb_client._Connection['ClientName'], '',
            smb_client._Connection['RequireSigning'])
  blob['MechToken'] = auth.getData()

  session_setup['SecurityBufferLength'] = len(blob)
  session_setup['Buffer']               = blob.getData()
  
  packet = smb_client.SMB_PACKET()
  packet['Command'] = smb3.SMB2_SESSION_SETUP
  packet['Data']    = session_setup
  
  packet_id = smb_client.sendSMB(packet)
  
  smb_response = smb_client.recvSMB(packet_id)

  if smb_client._Connection['Dialect'] == smb3.SMB2_DIALECT_311:
      smb_client.__UpdatePreAuthHash(smb_response.rawData)
  
  ## NTLM challenge
  if smb_response.isValidAnswer(smb3.STATUS_MORE_PROCESSING_REQUIRED):
    session_setup_response = smb3.SMB2SessionSetup_Response(smb_response['Data'])
    resp_token = smb3.SPNEGO_NegTokenResp(session_setup_response['Buffer'])

    return resp_token['ResponseToken']

  else:
    return None 
开发者ID:b17zr,项目名称:ntlm_challenger,代码行数:50,代码来源:ntlm_challenger.py


注:本文中的impacket.smb.SPNEGO_NegTokenInit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。