Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
s4n-cz opened this issue Feb 18, 2024 · 3 comments
Open

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

s4n-cz opened this issue Feb 18, 2024 · 3 comments
Labels
in review This issue or pull request is being analyzed

Comments

@s4n-cz
Copy link

s4n-cz commented Feb 18, 2024

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 Pennyw0rth/NetExec#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).

@s4n-cz s4n-cz changed the title smbclient fails to create folder, smbclient succeeds impacket-smbclient fails to create folder, smbclient succeeds Feb 18, 2024
@anadrianmanrique anadrianmanrique added the in review This issue or pull request is being analyzed label Feb 22, 2024
@anadrianmanrique
Copy link
Contributor

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

@s4n-cz
Copy link
Author

s4n-cz commented Feb 26, 2024

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. Pennyw0rth/NetExec#182

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

@whlpentest
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in review This issue or pull request is being analyzed
Projects
None yet
Development

No branches or pull requests

3 participants