This repository has been archived by the owner on Dec 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
These handler methods get a first pass at socket data before the consuming recv. These can be used to, for example, hook into libraries that read from sockets themselves or otherwise consume the data in the handler. This is the start of moving all the SSL MiTM code out of Connection and into SSL specific handlers as well as adding handlers dynamically. This change is pretty straightfoward except for the work to be done to support peek on mitm'd connections. pyOpenSSL does not support peek so we need to read into a buffer and read from that when peeking. This requires some pretty hacky code to keep select working correct on a connection where there is data remaning in the peek buffer as the underlying socket is no longer ready to be selected for reading (as it would be with real MSG_PEEK) so in that case we use a different fd for select that is always ready for reading.
- Loading branch information
1 parent
6082025
commit 7ba522d
Showing
2 changed files
with
87 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,24 @@ def on_ssl(self, client_hello): | |
""" | ||
pass | ||
|
||
def peek_request(self, request): | ||
"""Called with the data from a request _before_ it has been read from the socket. | ||
This comment has been minimized.
Sorry, something went wrong. |
||
This can be used to prempt the socket recv and handle data yourself. | ||
Returns if the request should be considered handled and recv should not be called on the underlying socket | ||
""" | ||
return False | ||
|
||
def peek_response(self, response): | ||
"""Called with the data from a response _before_ it has been read from the socket. | ||
This comment has been minimized.
Sorry, something went wrong.
chadbrubaker
Author
Contributor
|
||
This can be used to prempt the socket recv and handle data yourself. | ||
Returns if the response should be considered handled and recv should not be called on the underlying socket | ||
""" | ||
return False | ||
|
||
|
||
class BaseConnectionHandler(BaseHandler): | ||
|
||
|
Please adjust the documentation of these two methods to make it clear that it's not about accessing data before it's sent/received via a socket, but rather about accessing data received either from client or from server before it's processed further.