byt3bl33d3r / CrackMapExec

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

crackmapexec fails when querying smb #539

Closed robertstrom closed 2 years ago

robertstrom commented 2 years ago

Describe the bug errors / no results when running smb module when on newer versions of Kali

To Reproduce Steps to reproduce the behavior:

  1. Kali 2022.1 upgraded or fresh install, go to a command prompt and run a simple command to connect to a Windows server using smb command = crackmapexec smb 10.129.142.11 -u administrator -p XtH4nkS4Pl4y1nGX

results

+-$ crackmapexec smb $IP -u administrator -p XtH4nkS4Pl4y1nGX  

Traceback (most recent call last):

  File "/usr/bin/crackmapexec", line 8, in <module>

    sys.exit(main())

  File "/home/rstrom/.local/lib/python3.9/site-packages/cme/crackmapexec.py", line 162, in main

    target_file_type = identify_target_file(target)

  File "/home/rstrom/.local/lib/python3.9/site-packages/cme/helpers/misc.py", line 9, in identify_target_file

    with open(target_file, 'r') as target_file_handle:

IsADirectoryError: [Errno 21] Is a directory: '10.129.142.11'

see posted screenshots

Expected behavior SMB connection and results as shown in screenshot below when run on Kali 2019.4 fresh install and fresh install of crackmapexec

Screenshots If applicable, add screenshots to help explain your problem.

Crackmapexec info

Additional context Add any other context about the problem here.

crackmapexec fails on kali 2022.1 crackmapexec_kali2022 1_fails

crackmapexec failure and then an smbmap success using the same user and password smbmap_kali2022 1_success_same_user

crackmapexec success on kali 2019.4 crackmapexec_on_kali_2019 4 smbmap_kali2022 1_success_same_user

mpgn commented 2 years ago

Just output me the result of the command ls on your recon folder.

robertstrom commented 2 years ago

image

Do not believe that there is anything here except for file and directories that I created (none of the related to cme)

drwxr-xr-x  - rstrom 15 Feb 20:26 10.129.142.11/
drwxr-xr-x  - rstrom 15 Feb 22:10 Docs/
drwxr-xr-x  - rstrom 15 Feb 22:10 Reports/
drwxr-xr-x  - rstrom 15 Feb 22:11 smbfiles/
.rw-r--r-- 36 rstrom 15 Feb 23:17 users.txt
mpgn commented 2 years ago

The error that pop up on cme is very explicit IsADirectoryError: [Errno 21] Is a directory: '10.129.142.11'

You have a folder name '10.129.142.11', just remove it and you are good to go

robertstrom commented 2 years ago

OK / very interesting. nmapAutotomator creates the folder when using that tool. I will remove the directory and test this evening or this weekend. That's just too crazy simple ;-) but does help explain why I didn't have problems on the older Kali image since testing cme was the only thing that I did on it. Thanks very much!