本文整理汇总了Python中impacket.dcerpc.v5.srvs.hNetrShareEnum方法的典型用法代码示例。如果您正苦于以下问题:Python srvs.hNetrShareEnum方法的具体用法?Python srvs.hNetrShareEnum怎么用?Python srvs.hNetrShareEnum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类impacket.dcerpc.v5.srvs
的用法示例。
在下文中一共展示了srvs.hNetrShareEnum方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_hNetrShareEnum
# 需要导入模块: from impacket.dcerpc.v5 import srvs [as 别名]
# 或者: from impacket.dcerpc.v5.srvs import hNetrShareEnum [as 别名]
def test_hNetrShareEnum(self):
dce, rpctransport = self.connect()
resp = srvs.hNetrShareEnum(dce, 0)
resp.dump()
resp = srvs.hNetrShareEnum(dce, 1)
resp.dump()
resp = srvs.hNetrShareEnum(dce, 2)
resp.dump()
resp = srvs.hNetrShareEnum(dce, 501)
resp.dump()
resp = srvs.hNetrShareEnum(dce, 502)
resp.dump()
resp = srvs.hNetrShareEnum(dce, 503)
resp.dump()
示例2: getShares
# 需要导入模块: from impacket.dcerpc.v5 import srvs [as 别名]
# 或者: from impacket.dcerpc.v5.srvs import hNetrShareEnum [as 别名]
def getShares(self):
# Setup up a DCE SMBTransport with the connection already in place
LOG.info("Requesting shares on %s....." % (self.connection.getRemoteHost()))
try:
self._rpctransport = transport.SMBTransport(self.connection.getRemoteHost(),
self.connection.getRemoteHost(),filename = r'\srvsvc',
smb_connection = self.connection)
dce_srvs = self._rpctransport.get_dce_rpc()
dce_srvs.connect()
dce_srvs.bind(srvs.MSRPC_UUID_SRVS)
resp = srvs.hNetrShareEnum(dce_srvs, 1)
return resp['InfoStruct']['ShareInfo']['Level1']
except:
LOG.critical("Error requesting shares on %s, aborting....." % (self.connection.getRemoteHost()))
raise
示例3: getShares
# 需要导入模块: from impacket.dcerpc.v5 import srvs [as 别名]
# 或者: from impacket.dcerpc.v5.srvs import hNetrShareEnum [as 别名]
def getShares(self):
# Setup up a DCE SMBTransport with the connection already in place
LOG.info("Requesting shares on %s....." % (self.connection.getRemoteHost()))
try:
self._rpctransport = transport.SMBTransport(self.connection.getRemoteHost(), self.connection.getRemoteHost(),filename = r'\srvsvc', smb_connection = self.connection)
dce_srvs = self._rpctransport.get_dce_rpc()
dce_srvs.connect()
dce_srvs.bind(srvs.MSRPC_UUID_SRVS)
resp = srvs.hNetrShareEnum(dce_srvs, 1)
return resp['InfoStruct']['ShareInfo']['Level1']
except:
LOG.critical("Error requesting shares on %s, aborting....." % (self.connection.getRemoteHost()))
raise
示例4: listShares
# 需要导入模块: from impacket.dcerpc.v5 import srvs [as 别名]
# 或者: from impacket.dcerpc.v5.srvs import hNetrShareEnum [as 别名]
def listShares(self):
"""
get a list of available shares at the connected target
:return: a list containing dict entries for each share, raises exception if error
"""
# Get the shares through RPC
from impacket.dcerpc.v5 import transport, srvs
rpctransport = transport.SMBTransport(self.getRemoteName(), self.getRemoteHost(), filename=r'\srvsvc',
smb_connection=self)
dce = rpctransport.get_dce_rpc()
dce.connect()
dce.bind(srvs.MSRPC_UUID_SRVS)
resp = srvs.hNetrShareEnum(dce, 1)
return resp['InfoStruct']['ShareInfo']['Level1']['Buffer']
示例5: try_copy_library
# 需要导入模块: from impacket.dcerpc.v5 import srvs [as 别名]
# 或者: from impacket.dcerpc.v5.srvs import hNetrShareEnum [as 别名]
def try_copy_library(self, lib_name):
rpctransport = transport.SMBTransport(self.smb.getRemoteName(), self.smb.getRemoteHost(),
filename=r'\srvsvc', smb_connection=self.smb)
dce = rpctransport.get_dce_rpc()
dce.connect()
dce.bind(srvs.MSRPC_UUID_SRVS)
resp = srvs.hNetrShareEnum(dce, 2)
l = []
ignore_shares = ["print$", "IPC$"]
for share in resp['InfoStruct']['ShareInfo']['Level2']['Buffer']:
share_name = share['shi2_netname'][:-1]
share_path = self.translate_smb_path(share['shi2_path'][:-1])
l.append([share_name, share_path])
# Randomize the list of shares instead of going from the first to the last
random.shuffle(l)
if len(self.customBinary) < 1:
real_file = self.get_real_library_name()
else:
real_file = self.customBinary
log("Using %s" % real_file)
for share in l:
log("Trying to copy library '%s' to share '%s'" % (lib_name, share))
if self.try_put(share, lib_name, real_file):
log("Done!")
return share[1]
return None
示例6: get_netshare
# 需要导入模块: from impacket.dcerpc.v5 import srvs [as 别名]
# 或者: from impacket.dcerpc.v5.srvs import hNetrShareEnum [as 别名]
def get_netshare(self):
resp = srvs.hNetrShareEnum(self._rpc_connection, 1)
results = list()
for share in resp['InfoStruct']['ShareInfo']['Level1']['Buffer']:
results.append(rpcobj.Share(share))
return results
示例7: findSuitableShare
# 需要导入模块: from impacket.dcerpc.v5 import srvs [as 别名]
# 或者: from impacket.dcerpc.v5.srvs import hNetrShareEnum [as 别名]
def findSuitableShare(self):
from impacket.dcerpc.v5 import transport, srvs
rpctransport = transport.SMBTransport(self.__smbClient.getRemoteName(), self.__smbClient.getRemoteHost(),
filename=r'\srvsvc', smb_connection=self.__smbClient)
dce = rpctransport.get_dce_rpc()
dce.connect()
dce.bind(srvs.MSRPC_UUID_SRVS)
resp = srvs.hNetrShareEnum(dce, 2)
for share in resp['InfoStruct']['ShareInfo']['Level2']['Buffer']:
if self.isShareWritable(share['shi2_netname'][:-1]):
sharePath = share['shi2_path'].split(':')[-1:][0][:-1]
return share['shi2_netname'][:-1], sharePath
raise Exception('No suitable share found, aborting!')