當前位置: 首頁>>代碼示例>>Python>>正文


Python ntlm.compute_lmhash方法代碼示例

本文整理匯總了Python中impacket.ntlm.compute_lmhash方法的典型用法代碼示例。如果您正苦於以下問題:Python ntlm.compute_lmhash方法的具體用法?Python ntlm.compute_lmhash怎麽用?Python ntlm.compute_lmhash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在impacket.ntlm的用法示例。


在下文中一共展示了ntlm.compute_lmhash方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: tree_connect

# 需要導入模塊: from impacket import ntlm [as 別名]
# 或者: from impacket.ntlm import compute_lmhash [as 別名]
def tree_connect(self, path, password = '', service = SERVICE_ANY):
        LOG.warning("[MS-CIFS] This is an original Core Protocol command.This command has been deprecated.Client Implementations SHOULD use SMB_COM_TREE_CONNECT_ANDX")

        # return 0x800
        if password:
            # Password is only encrypted if the server passed us an "encryption" during protocol dialect
            if self._dialects_parameters['ChallengeLength'] > 0:
                # this code is untested
                password = self.get_ntlmv1_response(ntlm.compute_lmhash(password))

        if not unicode_support:
            if unicode_convert:
                path = str(path)
            else:
                raise Exception('SMB: Can\t conver path from unicode!')

        smb = NewSMBPacket()
        treeConnect = SMBCommand(SMB.SMB_COM_TREE_CONNECT)
        treeConnect['Parameters'] = SMBTreeConnect_Parameters()
        treeConnect['Data']       = SMBTreeConnect_Data()
        treeConnect['Data']['Path'] = path.upper()
        treeConnect['Data']['Password'] = password
        treeConnect['Data']['Service'] = service
        smb.addCommand(treeConnect)
        self.sendSMB(smb)

        while 1:
            smb = self.recvSMB()
            if smb.isValidAnswer(SMB.SMB_COM_TREE_CONNECT):
                # XXX Here we are ignoring the rest of the response
                return smb['Tid']
            return smb['Tid'] 
開發者ID:joxeankoret,項目名稱:CVE-2017-7494,代碼行數:34,代碼來源:smb.py

示例2: __init__

# 需要導入模塊: from impacket import ntlm [as 別名]
# 或者: from impacket.ntlm import compute_lmhash [as 別名]
def __init__(self, logger, share_name, share_path='/tmp/.ar3', share_comment = '', username= '', password='', listen_address='0.0.0.0', listen_port=445, verbose=False):
        self.running = True
        self._smb2support = False
        self._share_path = share_path

        try:
            threading.Thread.__init__(self)

            # If suggested share_path not exist, create
            if not os.path.exists(share_path):
                os.makedirs(share_path)

            # Setup SMB Server
            self.server = smbserver.SimpleSMBServer(listen_address, int(listen_port))
            self.server.addShare(share_name, share_path, share_comment)
            if verbose:
                self.server.setLogFile('')
            self.server.setSMB2Support(self._smb2support)
            self.server.setSMBChallenge('')

            if username:
                if password:
                    lmhash = compute_lmhash(password)
                    nthash = compute_nthash(password)
                self.server.addCredential(username, 0, lmhash, nthash)

        except Exception as e:
            errno, message = e.args
            if errno == 98 and message == 'Address already in use':
                logger.fail('Error starting SMB server on port 445: the port is already in use')
            else:
                logger.fail('Error starting SMB server on port 445: {}'.format(message))
                exit(1) 
開發者ID:m8r0wn,項目名稱:ActiveReign,代碼行數:35,代碼來源:smb.py


注:本文中的impacket.ntlm.compute_lmhash方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。