fortra / impacket

Impacket is a collection of Python classes for working with network protocols.
https://www.coresecurity.com
Other
13.53k stars 3.58k forks source link

impacket-smbclient fails to create folder, smbclient succeeds #1703

Open s4n-cz opened 8 months ago

s4n-cz commented 8 months ago

Configuration

impacket version: v0.11.0 Python version: Python 3.11.7 Target OS: Kali

Debug Output With Command String

┌──(kali㉿kali)-[~/craft2]
└─$ impacket-smbclient -debug CRAFT2/thecybergeek:winniethepooh@192.168.186.188
Impacket v0.11.0 - Copyright 2023 Fortra

[+] Impacket Library Installation Path: /usr/lib/python3/dist-packages/impacket
Type help for list of commands
# shares
ADMIN$
C$
IPC$
WebApp
# use WebApp
# mkdir foo
[-] SMB SessionError: STATUS_ACCESS_DENIED({Access Denied} A process has requested access to an object but has not been granted those access rights.)
[+] Exception info
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/impacket/smbconnection.py", line 652, in createDirectory
    return self._SMBConnection.mkdir(shareName, pathName)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/impacket/smb3.py", line 1789, in mkdir
    fileId = self.create(treeId, pathName, GENERIC_ALL, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/impacket/smb3.py", line 1261, in create
    if ans.isValidAnswer(STATUS_SUCCESS):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/impacket/smb3structs.py", line 458, in isValidAnswer
    raise smb3.SessionError(self['Status'], self)
impacket.smb3.SessionError: SMB SessionError: STATUS_ACCESS_DENIED({Access Denied} A process has requested access to an object but has not been granted those access rights.)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/impacket/examples/smbclient.py", line 83, in onecmd
    retVal = cmd.Cmd.onecmd(self,s)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/cmd.py", line 217, in onecmd
    return func(arg)
           ^^^^^^^^^
  File "/usr/lib/python3/dist-packages/impacket/examples/smbclient.py", line 485, in do_mkdir
    self.smb.createDirectory(self.share,pathname)
  File "/usr/lib/python3/dist-packages/impacket/smbconnection.py", line 654, in createDirectory
    raise SessionError(e.get_error_code(), e.get_error_packet())
impacket.smbconnection.SessionError: SMB SessionError: STATUS_ACCESS_DENIED({Access Denied} A process has requested access to an object but has not been granted those access rights.)
# exit

┌──(kali㉿kali)-[~/craft2]
└─$ smbclient -U thecybergeek \\\\192.168.186.188\\WebApp
Password for [WORKGROUP\thecybergeek]:
Try "help" to get a list of possible commands.
smb: \> mkdir foo
smb: \> ls
  .                                   D        0  Sun Feb 18 09:45:46 2024
  ..                                  D        0  Sun Feb 18 09:45:46 2024
  assets                              D        0  Tue Apr  5 18:16:03 2022
  css                                 D        0  Tue Apr  5 18:16:03 2022
  foo                                 D        0  Sun Feb 18 09:45:46 2024
  index.php                           A     9768  Mon Jan 31 17:21:52 2022
  js                                  D        0  Tue Apr  5 18:16:03 2022
  upload.php                          A      896  Mon Jan 31 16:23:02 2022
  uploads                             D        0  Tue Apr  5 18:16:03 2022

        10327807 blocks of size 4096. 1772866 blocks available

Additional context

There is more details available in the issue created in NetExec's repository https://github.com/Pennyw0rth/NetExec/issues/182, since it was first reported there and later tracked down to Impacket.

The machine is Craft2 in Proving Grounds from Offsec (if somebody has a subscription there).

anadrianmanrique commented 8 months ago

can you please specify target's specs in order to replicate the error in our end? thanks

s4n-cz commented 8 months ago

can you please specify target's specs in order to replicate the error in our end? thanks

Can you please check the linked original issue with all the comments? I tried to provide more details about the issue there. https://github.com/Pennyw0rth/NetExec/issues/182

Also if you have some specific information in mind, please let me know what commands I should run on the system.

whlpentest commented 6 months ago

We have the same error : we can create files but not directories.