本文整理汇总了Python中smb.SMBConnection.SMBConnection.echo方法的典型用法代码示例。如果您正苦于以下问题:Python SMBConnection.echo方法的具体用法?Python SMBConnection.echo怎么用?Python SMBConnection.echo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类smb.SMBConnection.SMBConnection
的用法示例。
在下文中一共展示了SMBConnection.echo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RuntimeError
# 需要导入模块: from smb.SMBConnection import SMBConnection [as 别名]
# 或者: from smb.SMBConnection.SMBConnection import echo [as 别名]
raise RuntimeError('Cannot connect to host ' + target + '; looking up NetBIOS IP failed')
target_ip = ips[0]
if target_nb_name is None:
print('Looking up NetBIOS name from target IP: ' + target_ip)
nb_names = nb.queryIPForName(target_ip)
print('Got NB names: ' + str(nb_names))
if nb_names is None or len(nb_names) < 1:
raise RuntimeError('Cannot connect to host ' + target + '; looking up NetBIOS name failed')
target_nb_name = nb_names[0]
nb.close()
client_machine_name = socket.gethostbyaddr(socket.gethostname())[0]
# client_machine_name = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(15))
# print('Generated client machine name: ' + client_machine_name + '\n')
domain = input('Enter domain [none]: ')
username = input('Enter username: ')
password = getpass.getpass('Enter password: ')
conn = SMBConnection(username, password, client_machine_name, target_nb_name, domain=domain,
use_ntlm_v2 = True, sign_options=SMBConnection.SIGN_WHEN_SUPPORTED)
if not conn.connect(target_ip):
raise RuntimeError('Could not connect to host ' + target + '; establishing connection failed')
if conn.echo('blah') != 'blah':
raise RuntimeError('Connection test (echo) failed')
conn.close()