本文整理汇总了Python中smb.SMBConnection.SMBConnection方法的典型用法代码示例。如果您正苦于以下问题:Python SMBConnection.SMBConnection方法的具体用法?Python SMBConnection.SMBConnection怎么用?Python SMBConnection.SMBConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类smb.SMBConnection
的用法示例。
在下文中一共展示了SMBConnection.SMBConnection方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check
# 需要导入模块: from smb import SMBConnection [as 别名]
# 或者: from smb.SMBConnection import SMBConnection [as 别名]
def check(ip,port,timeout):
socket.setdefaulttimeout(timeout)
user_list = ['administrator']
hostname = ip2hostname(ip)
PASSWORD_DIC.insert(0,'anonymous')
if not hostname:return
for user in user_list:
for pass_ in PASSWORD_DIC:
try:
pass_ = str(pass_.replace('{user}', user))
conn = SMBConnection(user,pass_,'xunfeng',hostname)
if conn.connect(ip) == True:
if pass_ == 'anonymous':return u"存在匿名共享,请查看是否存在敏感文件。"
return u"存在弱口令,用户名:%s 密码:%s"%(user,pass_)
except Exception,e:
if "Errno 10061" in str(e) or "timed out" in str(e): return
示例2: resource
# 需要导入模块: from smb import SMBConnection [as 别名]
# 或者: from smb.SMBConnection import SMBConnection [as 别名]
def resource(self):
kwargs = dict(
username=smb_user,
password=smb_passwd,
my_name=self.my_name,
remote_name=self.hostname,
is_direct_tcp=self.direct_tcp,
)
conn = SMBConnection(**kwargs)
# actually connect
if self.smb_port is not None:
assert conn.connect(self.host, port=self.smb_port)
else:
assert conn.connect(self.host)
return conn
示例3: usbfirstconnectremote
# 需要导入模块: from smb import SMBConnection [as 别名]
# 或者: from smb.SMBConnection import SMBConnection [as 别名]
def usbfirstconnectremote(usbserial,remotecompname,remoteuser, remotepassword):
array_dates = []
array_time = []
a = 0
data_folder="C$"
conn=SMBConnection(remoteuser, remotepassword, "hn", remotecompname,use_ntlm_v2 = True,domain='testdomain')
conn.connect(remotecompname,139)
with open('tempohn.tmp','wb') as devlogfile:
conn.retrieveFile(data_folder, '\Windows\inf\setupapi.dev.log', devlogfile)
print("CONECTADO")
print("USBSERIAL:", usbserial)
devlogfile = open("tempohn.tmp", 'r')
for line in devlogfile:
if re.search(usbserial, line):
line=next(devlogfile)
# Split text strings to retrive date and time
for word in line.split():
if word.find(':')!=-1: # time
array_time.append(word)
#print(array_time)
else:
array_dates.append(word)
array_dates.remove('>>>')
array_dates.remove('Section')
array_dates.remove('start')
mindate = min(array_dates)
mintime = min(array_time)
devlogfile.close()
return (mindate, mintime)
# Class definition
示例4: connect
# 需要导入模块: from smb import SMBConnection [as 别名]
# 或者: from smb.SMBConnection import SMBConnection [as 别名]
def connect(hostname, domain, user, password, nb_name, port):
if not domain:
connection = SMBConnection(user, password, 'Demisto', nb_name, is_direct_tcp=True)
else:
connection = SMBConnection(user, password, 'Demisto', nb_name, domain=domain, is_direct_tcp=True)
if not connection.connect(hostname, port):
return_error('Authentication failed, verify instance configuration parameters and try again.')
return connection
示例5: connect
# 需要导入模块: from smb import SMBConnection [as 别名]
# 或者: from smb.SMBConnection import SMBConnection [as 别名]
def connect(url):
# logger.info("Url: %s" % url)
global remote
server_name, server_ip, share_name, path, user, password, domain = parse_url(url)
#Da problemas asumir que la sesión está abierta. Si se abrió pero ha caducado, dará error. Mejor conectar siempre
"""
if not remote or not remote.sock or not server_name == remote.remote_name:
remote = SMBConnection(user, password, domain, server_name)
remote.connect(server_ip, 139)
"""
remote = SMBConnection(user, password, domain, server_name)
remote.connect(ip=server_ip, timeout=20)
return remote, share_name, path
示例6: connect
# 需要导入模块: from smb import SMBConnection [as 别名]
# 或者: from smb.SMBConnection import SMBConnection [as 别名]
def connect(url):
#logger.info("Url: %s" % url)
global remote
server_name, server_ip, share_name, path, user, password, domain = parse_url(url)
if not remote or not remote.sock or not server_name == remote.remote_name:
remote = SMBConnection(user, password, domain, server_name)
remote.connect(server_ip, 139)
return remote, share_name, path
示例7: smb_connect
# 需要导入模块: from smb import SMBConnection [as 别名]
# 或者: from smb.SMBConnection import SMBConnection [as 别名]
def smb_connect(server, user, passwd, domain, timeout):
# Create SMB Connection using random client string
client = ''.join([choice(ascii_letters + digits) for x in range(7)])
con = SMBConnection(user, passwd, client, server, domain=domain, use_ntlm_v2=True, is_direct_tcp=True)
con.connect(server, 445, timeout=timeout)
return con
示例8: authenticate
# 需要导入模块: from smb import SMBConnection [as 别名]
# 或者: from smb.SMBConnection import SMBConnection [as 别名]
def authenticate(self):
from smb.SMBConnection import SMBConnection
# There will be some mechanism to capture userID, password, client_machine_name, server_name and server_ip
# client_machine_name can be an arbitary ASCII string
# server_name should match the remote machine name, or else the connection will be rejected
#userID = 'xatportantier'
userID = 'guest'
#password = 'SecurFMP_23'
password = ''
client_machine_name = 'fmp'
server_ip = '192.1.3.120'
server_name = 'Server72'
server_name = ''
from nmb.NetBIOS import NetBIOS
nb = NetBIOS(broadcast=True, listen_port=0)
#print('ip', nb.queryName(server_name, port=445))
#print('name', nb.queryIPForName(server_ip))
conn = SMBConnection(userID, password, client_machine_name, server_name, use_ntlm_v2=True, is_direct_tcp=False)
from pprint import pprint
for a in [ 'capabilities', 'domain', 'host_type', 'log', 'my_name', 'remote_name', 'security_mode', 'uid', 'username' ]:
print(a, getattr(conn, a))
#print('cap', conn.capabilities)
#print('domain', conn.domain)
print('auth', conn.connect(server_ip, 139))
#print(conn.isUsingSMB2)
#print(conn.echo('aaaaa'))
#conn.listShares()