本文整理汇总了Python中impacket.nmb.NetBIOSError方法的典型用法代码示例。如果您正苦于以下问题:Python nmb.NetBIOSError方法的具体用法?Python nmb.NetBIOSError怎么用?Python nmb.NetBIOSError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类impacket.nmb
的用法示例。
在下文中一共展示了nmb.NetBIOSError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: smbVersion
# 需要导入模块: from impacket import nmb [as 别名]
# 或者: from impacket.nmb import NetBIOSError [as 别名]
def smbVersion(rhost):
host = rhost
port=445
try:
smb = SMBConnection(host, host, sess_port=port)
except NetBIOSError:
return
except socket.error, v:
error_code = v[0]
if error_code == errno.ECONNREFUSED:
return
else:
return
示例2: _negotiateSession
# 需要导入模块: from impacket import nmb [as 别名]
# 或者: from impacket.nmb import NetBIOSError [as 别名]
def _negotiateSession(self, myName, remoteName, remoteHost, sess_port, timeout, extended_security=True, flags1=0,
flags2=0, data=None):
# Here we follow [MS-SMB2] negotiation handshake trying to understand what dialects
# (including SMB1) is supported on the other end.
if not myName:
myName = socket.gethostname()
i = string.find(myName, '.')
if i > -1:
myName = myName[:i]
tries = 0
smbp = smb.NewSMBPacket()
smbp['Flags1'] = flags1
# FLAGS2_UNICODE is required by some stacks to continue, regardless of subsequent support
smbp['Flags2'] = flags2 | smb.SMB.FLAGS2_UNICODE
resp = None
while tries < 2:
self._nmbSession = nmb.NetBIOSTCPSession(myName, remoteName, remoteHost, nmb.TYPE_SERVER, sess_port,
timeout)
negSession = smb.SMBCommand(smb.SMB.SMB_COM_NEGOTIATE)
if extended_security is True:
smbp['Flags2'] |= smb.SMB.FLAGS2_EXTENDED_SECURITY
negSession['Data'] = data
smbp.addCommand(negSession)
self._nmbSession.send_packet(str(smbp))
try:
resp = self._nmbSession.recv_packet(timeout)
break
except nmb.NetBIOSError:
# OSX Yosemite asks for more Flags. Let's give it a try and see what happens
smbp['Flags2'] |= smb.SMB.FLAGS2_NT_STATUS | smb.SMB.FLAGS2_LONG_NAMES | smb.SMB.FLAGS2_UNICODE
smbp['Data'] = []
tries += 1
if resp is None:
# No luck, quitting
raise
return resp.get_trailer()
示例3: negotiateSessionWildcard
# 需要导入模块: from impacket import nmb [as 别名]
# 或者: from impacket.nmb import NetBIOSError [as 别名]
def negotiateSessionWildcard(self, myName, remoteName, remoteHost, sess_port, timeout, extended_security=True, flags1=0,
flags2=0, data=None):
# Here we follow [MS-SMB2] negotiation handshake trying to understand what dialects
# (including SMB1) is supported on the other end.
if not myName:
myName = socket.gethostname()
i = myName.find('.')
if i > -1:
myName = myName[:i]
tries = 0
smbp = smb.NewSMBPacket()
smbp['Flags1'] = flags1
# FLAGS2_UNICODE is required by some stacks to continue, regardless of subsequent support
smbp['Flags2'] = flags2 | smb.SMB.FLAGS2_UNICODE
resp = None
while tries < 2:
self._nmbSession = nmb.NetBIOSTCPSession(myName, remoteName, remoteHost, nmb.TYPE_SERVER, sess_port,
timeout)
negSession = smb.SMBCommand(smb.SMB.SMB_COM_NEGOTIATE)
if extended_security is True:
smbp['Flags2'] |= smb.SMB.FLAGS2_EXTENDED_SECURITY
negSession['Data'] = data
smbp.addCommand(negSession)
self._nmbSession.send_packet(smbp.getData())
try:
resp = self._nmbSession.recv_packet(timeout)
break
except nmb.NetBIOSError:
# OSX Yosemite asks for more Flags. Let's give it a try and see what happens
smbp['Flags2'] |= smb.SMB.FLAGS2_NT_STATUS | smb.SMB.FLAGS2_LONG_NAMES | smb.SMB.FLAGS2_UNICODE
smbp['Data'] = []
tries += 1
if resp is None:
# No luck, quitting
raise Exception('No answer!')
return resp.get_trailer()