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

Update smbexec.py #1863

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update smbexec.py #1863

wants to merge 1 commit into from

Conversation

AabyssZG
Copy link

Update smbexec.py to fixing Bug

When I use smbexec.py,find a Bug:

C:\impacket\impacket-master\examples>python3 smbexec.py Administrator:QWE@123@10.10.0.1 -debug

[+] Impacket Library Installation Path: C:\Python\Python38\lib\site-packages\impacket
[+] StringBinding ncacn_np:10.10.0.1[\pipe\svcctl]
[+] Executing %COMSPEC% /Q /c echo cd  ^> \\%COMPUTERNAME%\C$\__output 2^>^&1 > %SYSTEMROOT%\xSBmWrWK.bat & %COMSPEC% /Q /c %SYSTEMROOT%\xSBmWrWK.bat & del %SYSTEMROOT%\xSBmWrWK.bat
Traceback (most recent call last):
  File "C:\Python\Python38\lib\site-packages\impacket\smbconnection.py", line 771, in getFile
    return self._SMBConnection.retr_file(shareName, pathName, callback)
  File "C:\Python\Python38\lib\site-packages\impacket\smb3.py", line 1912, in retrieveFile
    fileId = self.create(treeId, path, FILE_READ_DATA, shareAccessMode, FILE_NON_DIRECTORY_FILE, mode, 0, createContexts=createContexts)
  File "C:\Python\Python38\lib\site-packages\impacket\smb3.py", line 1312, in create
    if ans.isValidAnswer(STATUS_SUCCESS):
  File "C:\Python\Python38\lib\site-packages\impacket\smb3structs.py", line 460, in isValidAnswer
    raise smb3.SessionError(self['Status'], self)
impacket.smb3.SessionError: SMB SessionError: STATUS_SHARING_VIOLATION(A file cannot be opened because the share access flags are incompatible.)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "smbexec.py", line 161, in run
    self.shell = RemoteShell(self.__share, rpctransport, self.__mode, self.__serviceName, self.__shell_type)
  File "smbexec.py", line 209, in __init__
    self.do_cd('')
  File "smbexec.py", line 251, in do_cd
    self.execute_remote('cd ' )
  File "smbexec.py", line 304, in execute_remote
    self.get_output()
  File "smbexec.py", line 271, in get_output
    self.transferClient.getFile(self.__share, OUTPUT_FILENAME, output_callback)
  File "C:\Python\Python38\lib\site-packages\impacket\smbconnection.py", line 775, in getFile
    raise SessionError(e.get_error_code(), e.get_error_packet())
impacket.smbconnection.SessionError: SMB SessionError: code: 0xc0000043 - STATUS_SHARING_VIOLATION - A file cannot be opened because the share access flags are incompatible.

[-] SMB SessionError: code: 0xc0000043 - STATUS_SHARING_VIOLATION - A file cannot be opened because the share access flags are incompatible.

Bugs-2

Beacuse the Old File C$\__output is occupied by a process, the solution is to specify a new file name.

The latest version has not yet been repaired,so i submit this PR,thank you.

@anadrianmanrique anadrianmanrique added the in review This issue or pull request is being analyzed label Dec 12, 2024
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

Successfully merging this pull request may close these issues.

3 participants