Quantcast
Viewing all articles
Browse latest Browse all 14040

Log all data passing on socket

How am I able to log all of the data passing on a Python socket?

For audit, security and debugging purposes I've attempted creating a few wrappers around the socket object. They log all of the data passed to methods like .recv() and .sendall().

Unfortunately, there are a few main problems with that approach:

  1. It is not forward / backwards compatible. A new method on the socket object for sending data in any Python minor version will not be logged. I can only allow using my custom object, but that will enforce my interface, without the possibility to create __getattr__.
  2. In case of network disconnection in the middle of a .sendall(), I do not know what was already sent.

Python's built-in audit does not contain anything for the actual data passed on the socket.

I wish to avoid the usage of tcpdump and stay within the confines of Python.


Viewing all articles
Browse latest Browse all 14040

Trending Articles