byt3bl33d3r / CrackMapExec

A swiss army knife for pentesting networks
BSD 2-Clause "Simplified" License
8.45k stars 1.64k forks source link

"BrokenPipeError" #579

Closed Biepa closed 2 years ago

Biepa commented 2 years ago

Describe the bug Had a "BrokenPipError" with the default, apt installed crackmapexec in Kali. Tried to reinstall via pipx and installed the apt version. Still the same error. I guess its a problem with the setup? Otherwise other users would have brought this up. But I can't see where the problem is.

To Reproduce Steps to reproduce the behavior:

  1. Install via pipx
  2. Run cme smb <ip> --shares

Expected behavior Not throwing exceptions?!

Crackmapexec info

Additional context

SMB         192.168.170.55  445    SHENZI           [*] Windows 10.0 Build 19041 x64 (name:SHENZI) (domain:shenzi) (signing:False) (SMBv1:False)
Traceback (most recent call last):
  File "/home/kali/.local/pipx/venvs/crackmapexec/lib/python3.10/site-packages/cme/protocols/smb.py", line 599, in shares
    for share in self.conn.listShares():
  File "/home/kali/.local/pipx/venvs/crackmapexec/lib/python3.10/site-packages/impacket/smbconnection.py", line 416, in listShares
    dce.connect()
  File "/home/kali/.local/pipx/venvs/crackmapexec/lib/python3.10/site-packages/impacket/dcerpc/v5/rpcrt.py", line 803, in connect
    return self._transport.connect()
  File "/home/kali/.local/pipx/venvs/crackmapexec/lib/python3.10/site-packages/impacket/dcerpc/v5/transport.py", line 517, in connect
    self.__tid = self.__smb_connection.connectTree('IPC$')
  File "/home/kali/.local/pipx/venvs/crackmapexec/lib/python3.10/site-packages/impacket/smbconnection.py", line 392, in connectTree
    return self._SMBConnection.connect_tree(share)
  File "/home/kali/.local/pipx/venvs/crackmapexec/lib/python3.10/site-packages/impacket/smb3.py", line 1094, in connectTree
    packetID = self.sendSMB(packet)
  File "/home/kali/.local/pipx/venvs/crackmapexec/lib/python3.10/site-packages/impacket/smb3.py", line 429, in sendSMB
    self._NetBIOSSession.send_packet(data)
  File "/home/kali/.local/pipx/venvs/crackmapexec/lib/python3.10/site-packages/impacket/nmb.py", line 912, in send_packet
    self._sock.sendall(p.rawData())
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/kali/.local/bin/cme", line 8, in <module>
    sys.exit(main())
  File "/home/kali/.local/pipx/venvs/crackmapexec/lib/python3.10/site-packages/cme/crackmapexec.py", line 254, in main
    asyncio.run(
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/kali/.local/pipx/venvs/crackmapexec/lib/python3.10/site-packages/cme/crackmapexec.py", line 102, in start_threadpool
    await asyncio.gather(*jobs)
  File "/home/kali/.local/pipx/venvs/crackmapexec/lib/python3.10/site-packages/cme/crackmapexec.py", line 68, in run_protocol
    await asyncio.wait_for(
  File "/usr/lib/python3.10/asyncio/tasks.py", line 408, in wait_for
    return await fut
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/kali/.local/pipx/venvs/crackmapexec/lib/python3.10/site-packages/cme/protocols/smb.py", line 125, in __init__
    connection.__init__(self, args, db, host)
  File "/home/kali/.local/pipx/venvs/crackmapexec/lib/python3.10/site-packages/cme/connection.py", line 62, in __init__
    self.proto_flow()
  File "/home/kali/.local/pipx/venvs/crackmapexec/lib/python3.10/site-packages/cme/connection.py", line 102, in proto_flow
    self.call_cmd_args()
  File "/home/kali/.local/pipx/venvs/crackmapexec/lib/python3.10/site-packages/cme/connection.py", line 109, in call_cmd_args
    r = getattr(self, k)()
  File "/home/kali/.local/pipx/venvs/crackmapexec/lib/python3.10/site-packages/cme/protocols/smb.py", line 640, in shares
    error = e.getErrorString()
AttributeError: 'BrokenPipeError' object has no attribute 'getErrorString'
swordfish0x0 commented 2 years ago

Also seeing similar behaviors, runnning latest kali updated.

sudo crackmapexec smb 10.x.x.xxx --shares -u ''

SMB 10.X.X.XXX 445 TARGET [*] Windows Server 2012 R2 Standard 9600 x64 (name:TARGET) (domain:TARGET) (signing:False) (SMBv1:True) Traceback (most recent call last): File "/usr/lib/python3/dist-packages/cme/protocols/smb.py", line 599, in shares for share in self.conn.listShares(): File "/usr/lib/python3/dist-packages/impacket/smbconnection.py", line 382, in listShares dce.connect() File "/usr/lib/python3/dist-packages/impacket/dcerpc/v5/rpcrt.py", line 803, in connect return self._transport.connect() File "/usr/lib/python3/dist-packages/impacket/dcerpc/v5/transport.py", line 517, in connect self.tid = self.smb_connection.connectTree('IPC$') File "/usr/lib/python3/dist-packages/impacket/smbconnection.py", line 358, in connectTree return self._SMBConnection.connect_tree(share) File "/usr/lib/python3/dist-packages/impacket/smb.py", line 2831, in tree_connect_andx self.sendSMB(smb) File "/usr/lib/python3/dist-packages/impacket/smb.py", line 2662, in sendSMB self._sess.send_packet(smb.getData()) File "/usr/lib/python3/dist-packages/impacket/nmb.py", line 912, in send_packet self._sock.sendall(p.rawData()) BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/bin/crackmapexec", line 8, in sys.exit(main()) File "/usr/lib/python3/dist-packages/cme/crackmapexec.py", line 254, in main asyncio.run( File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete return future.result() File "/usr/lib/python3/dist-packages/cme/crackmapexec.py", line 102, in start_threadpool await asyncio.gather(jobs) File "/usr/lib/python3/dist-packages/cme/crackmapexec.py", line 68, in run_protocol await asyncio.wait_for( File "/usr/lib/python3.10/asyncio/tasks.py", line 408, in wait_for return await fut File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(self.args, **self.kwargs) File "/usr/lib/python3/dist-packages/cme/protocols/smb.py", line 125, in init connection.init(self, args, db, host) File "/usr/lib/python3/dist-packages/cme/connection.py", line 62, in init self.proto_flow() File "/usr/lib/python3/dist-packages/cme/connection.py", line 102, in proto_flow self.call_cmd_args() File "/usr/lib/python3/dist-packages/cme/connection.py", line 109, in call_cmd_args r = getattr(self, k)() File "/usr/lib/python3/dist-packages/cme/protocols/smb.py", line 640, in shares error = e.getErrorString() AttributeError: 'BrokenPipeError' object has no attribute 'getErrorString'

as a data point I tried changing the min protocol from SMB2 to LANMAN1 and restarting smbd, it made no difference, same error

mpgn commented 2 years ago

Fixed by #560