Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions impacket/smbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5409,7 +5409,7 @@ def NetrShareGetInfo(self, data):

answer['InfoStruct']['tag'] = 1
answer['InfoStruct']['ShareInfo1']['shi1_netname'] = s + '\x00'
answer['InfoStruct']['ShareInfo1']['shi1_type'] = share['share type']
answer['InfoStruct']['ShareInfo1']['shi1_type'] = int(share['share type'])
answer['InfoStruct']['ShareInfo1']['shi1_remark'] = share['comment'] + '\x00'
answer['ErrorCode'] = 0
else:
Expand Down Expand Up @@ -5449,7 +5449,7 @@ def NetrShareEnum(self, data):
for i in self._shares:
shareInfo = SHARE_INFO_1()
shareInfo['shi1_netname'] = i + '\x00'
shareInfo['shi1_type'] = self._shares[i]['share type']
shareInfo['shi1_type'] = int(self._shares[i]['share type'])
shareInfo['shi1_remark'] = self._shares[i]['comment'] + '\x00'
shareEnum['InfoStruct']['ShareInfo']['Level1']['Buffer'].append(shareInfo)

Expand Down
28 changes: 27 additions & 1 deletion tests/SMB_RPC/test_smbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
from impacket.smbconnection import SMBConnection, SessionError, compute_lmhash, compute_nthash
from impacket.nt_errors import STATUS_NOT_SUPPORTED
from impacket import smb3structs as smb2
from impacket.dcerpc.v5 import transport, srvs
from threading import Thread

import select
Expand Down Expand Up @@ -341,6 +342,7 @@ def test_smbserver_list_shares(self):
"""Test listing shares.
"""
server = self.get_smbserver()
server.addShare("printer", self.share_path, shareType="1")
self.start_smbserver(server)

client = self.get_smbclient()
Expand All @@ -353,7 +355,31 @@ def test_smbserver_list_shares(self):
client.login(self.username, self.password)
shares = client.listShares()
shares_names = [share['shi1_netname'][:-1] for share in shares]
assertCountEqual(self, [self.share_name.upper(), "IPC$"], shares_names)
assertCountEqual(self, [self.share_name.upper(), "PRINTER", "IPC$"], shares_names)

shares_by_name = {share['shi1_netname'][:-1]: share for share in shares}
self.assertEqual(srvs.STYPE_DISKTREE, shares_by_name[self.share_name.upper()]['shi1_type'])
self.assertEqual(srvs.STYPE_PRINTQ, shares_by_name["PRINTER"]['shi1_type'])
self.assertEqual(srvs.STYPE_IPC, shares_by_name["IPC$"]['shi1_type'])

client.close()

def test_smbserver_get_share_info_type(self):
"""Test getting a non-disk share type.
"""
server = self.get_smbserver()
server.addShare("printer", self.share_path, shareType="1")
self.start_smbserver(server)

client = self.get_smbclient()
client.login(self.username, self.password)
rpc_transport = transport.SMBTransport(self.address, self.address, filename=r'\srvsvc',
smb_connection=client)
dce = rpc_transport.get_dce_rpc()
dce.connect()
dce.bind(srvs.MSRPC_UUID_SRVS)
share = srvs.hNetrShareGetInfo(dce, "PRINTER\x00", 1)
self.assertEqual(srvs.STYPE_PRINTQ, share['InfoStruct']['ShareInfo1']['shi1_type'])

client.close()

Expand Down
Loading