thinkst / opencanary

Modular and decentralised honeypot
http://opencanary.org
BSD 3-Clause "New" or "Revised" License
2.27k stars 355 forks source link

SMTP Timeout #233

Closed ErrorCode67 closed 1 year ago

ErrorCode67 commented 1 year ago

Fresh install of latest OpenCanary on Ubuntu 22.04. Starting OpenCanary I am getting smtp timeout issues. I have verified the smtp server is operational and can send mail via postfix from the box running OpenCanary. Thoughts?

$ sudo apt-get install python3-dev python3-pip python3-virtualenv python3-venv python3-scapy libssl-dev libpcap-dev $ sudo apt install samba # if you plan to use the smb module $ virtualenv env/ $ . env/bin/activate $ pip install opencanary $ pip install scapy pcapy # optional

            "SMTP": {
                "class": "logging.handlers.SMTPHandler",
                "mailhost": ["mymailserver", 25],
                "fromaddr": "opencanary04@mydomain.com",
                "toaddrs" : ["alerts@mydomain.com"],
                "subject" : "OpenCanary Alert - opencanary04"
            }

--- Logging error --- Traceback (most recent call last): File "/usr/lib/python3.10/logging/handlers.py", line 1057, in emit smtp = smtplib.SMTP(self.mailhost, port, timeout=self.timeout) File "/usr/lib/python3.10/smtplib.py", line 255, in init (code, msg) = self.connect(host, port) File "/usr/lib/python3.10/smtplib.py", line 341, in connect self.sock = self._get_socket(host, port, self.timeout) File "/usr/lib/python3.10/smtplib.py", line 312, in _get_socket return socket.create_connection((host, port), timeout, File "/usr/lib/python3.10/socket.py", line 845, in create_connection raise err File "/usr/lib/python3.10/socket.py", line 833, in create_connection sock.connect(sa) OSError: [Errno 101] Network is unreachable Call stack: File "/home/drc/env/bin/twistd", line 8, in sys.exit(run()) File "/home/drc/env/lib/python3.10/site-packages/twisted/scripts/twistd.py", line 31, in run app.run(runApp, ServerOptions) File "/home/drc/env/lib/python3.10/site-packages/twisted/application/app.py", line 674, in run runApp(config) File "/home/drc/env/lib/python3.10/site-packages/twisted/scripts/twistd.py", line 25, in runApp runner.run() File "/home/drc/env/lib/python3.10/site-packages/twisted/application/app.py", line 381, in run self.application = self.createOrGetApplication() File "/home/drc/env/lib/python3.10/site-packages/twisted/application/app.py", line 453, in createOrGetApplication application = getApplication(self.config, passphrase) File "/home/drc/env/lib/python3.10/site-packages/twisted/application/app.py", line 464, in getApplication application = service.loadApplication(filename, style, passphrase) File "/home/drc/env/lib/python3.10/site-packages/twisted/application/service.py", line 416, in loadApplication application = sob.loadValueFromFile(filename, 'application') File "/home/drc/env/lib/python3.10/site-packages/twisted/persisted/sob.py", line 177, in loadValueFromFile eval(codeObj, d, d) File "/home/drc/env/bin/opencanary.tac", line 145, in start_mod(application, klass) File "/home/drc/env/bin/opencanary.tac", line 101, in start_mod logMsg({'logdata': msg}) File "/home/drc/env/bin/opencanary.tac", line 121, in logMsg logger.log(data, retry=False) File "/home/drc/env/lib/python3.10/site-packages/opencanary/logger.py", line 175, in log self.logger.warn(json.dumps(logdata, sort_keys=True))

jayjb commented 1 year ago

Hi @ErrorCode67,

Thanks for getting in touch. This is interesting. In your traceback, it mentions that

OSError: [Errno 101] Network is unreachable

This suggests that the Opencanary is struggling to contact your SMTP server. Can you contact your mail server form the box or are you trying to use postfix from the Opencanary daemon?

ErrorCode67 commented 1 year ago

I ended up installing Ubuntu 20.04 to finish up the project and the issue went away. I will try to do a fresh install of 22.04 for testing. One additional note. This is on a HP Chromebox with re-flashed bios to allow an OS other than ChromeOS. It does have a Intel Core i5-7300U, 4Gb ram, etc. I am using only standard installation media and repos. I have not seen any other issues with applications running on them.

ErrorCode67 commented 1 year ago

Also of note this is/was Ubuntu server installs with no gui.

ErrorCode67 commented 1 year ago

and finally to answer your question. When OpenCanary was unable to send email I installed postfix and was able to send emails using standard mail program.

jayjb commented 1 year ago

Thanks @ErrorCode67. I'm closing this issue for now because it sounds like you found a workaround.