Skip to content
Browse files

Support decompressing gzip encoding if it somehow slips by (google do…

…es this sometimes).
  • Loading branch information...
1 parent 12b2cb5 commit cf5a863c033633d254a1f5d5aa4e9c57e8b54b9d @moxie0 committed
Showing with 11 additions and 2 deletions.
  1. +11 −2 sslstrip/ServerConnection.py
View
13 sslstrip/ServerConnection.py
@@ -16,7 +16,7 @@
# USA
#
-import logging, re, string, random
+import logging, re, string, random, zlib, gzip, StringIO
from twisted.web.http import HTTPClient
from URLMonitor import URLMonitor
@@ -40,6 +40,7 @@ def __init__(self, command, uri, postData, headers, client):
self.client = client
self.urlMonitor = URLMonitor.getInstance()
self.isImageRequest = False
+ self.isCompressed = False
self.contentLength = None
self.shutdownComplete = False
@@ -87,7 +88,11 @@ def handleHeader(self, key, value):
self.isImageRequest = True
logging.debug("Response is image content, not scanning...")
- if (key.lower() == 'content-length'):
+ if (key.lower() == 'content-encoding'):
+ if (value.find('gzip') != -1):
+ logging.debug("Response is compressed...")
+ self.isCompressed = True
+ elif (key.lower() == 'content-length'):
self.contentLength = value
elif (key.lower() == 'set-cookie'):
self.client.responseHeaders.addRawHeader(key, value)
@@ -114,6 +119,10 @@ def handleResponseEnd(self):
HTTPClient.handleResponseEnd(self)
def handleResponse(self, data):
+ if (self.isCompressed):
+ logging.debug("Decompressing content...")
+ data = gzip.GzipFile('', 'rb', 9, StringIO.StringIO(data)).read()
+
logging.log(self.getLogLevel(), "Read from server:\n" + data)
data = self.replaceSecureLinks(data)

0 comments on commit cf5a863

Please sign in to comment.
Something went wrong with that request. Please try again.