fortra / impacket

Impacket is a collection of Python classes for working with network protocols.
https://www.coresecurity.com
Other
13.38k stars 3.56k forks source link

Unable to find smbserver.py logs #1771

Closed IrfanNian closed 2 months ago

IrfanNian commented 3 months ago

Configuration

impacket version: 0.11.0 Python version: 3.10.12 Target OS: Ubuntu

Trying to setup honeyshare using the smbserver.py example, works as expected. However, I can't seem to find the logs of devices connecting/trying to connect to the smb server. Even indicated a file under the server.SetLogFile but still nothing is logged. Where does the log supposed to be usually reside?

gabrielg5 commented 2 months ago

Hi @IrfanNian,

I've been checking a bit this issue and found what's causing it not to be updated, even when explicitly setting the file path in smbserver.py https://github.com/fortra/impacket/blob/ff1725ac2a3df5c5ed28ab3fb3b574c6390c8b6c/examples/smbserver.py#L100-L102

When SetLogFile is called, smbserver config file is re-processed but in order for the logging configuration to be updated - due to the fact that the logger already has handlers configured -, basicConfig needs to be called with force = True (logging.basicConfig (docs.python.org)) https://github.com/fortra/impacket/blob/ff1725ac2a3df5c5ed28ab3fb3b574c6390c8b6c/impacket/smbserver.py#L4670-L4674

I've tested internally that change and, first, a couple lines are logged in the console and after SetLogFile everything is moved to the configured log file. Will be doing some more tests to find the best approach to handle this and create a PR.

thank you!