Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nu11secur1ty
GitHub Repository: nu11secur1ty/Kali-Linux
Path: blob/master/sslstrip-work-2019/sslstrip/ServerConnectionFactory.py
1306 views
1
# Copyright (c) 2004-2009 Moxie Marlinspike
2
#
3
# This program is free software; you can redistribute it and/or
4
# modify it under the terms of the GNU General Public License as
5
# published by the Free Software Foundation; either version 3 of the
6
# License, or (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful, but
9
# WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
# General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
16
# USA
17
#
18
19
import logging
20
from twisted.internet.protocol import ClientFactory
21
22
class ServerConnectionFactory(ClientFactory):
23
24
def __init__(self, command, uri, postData, headers, client):
25
self.command = command
26
self.uri = uri
27
self.postData = postData
28
self.headers = headers
29
self.client = client
30
31
def buildProtocol(self, addr):
32
return self.protocol(self.command, self.uri, self.postData, self.headers, self.client)
33
34
def clientConnectionFailed(self, connector, reason):
35
logging.debug("Server connection failed.")
36
37
destination = connector.getDestination()
38
39
if (destination.port != 443):
40
logging.debug("Retrying via SSL")
41
self.client.proxyViaSSL(self.headers['host'], self.command, self.uri, self.postData, self.headers, 443)
42
else:
43
self.client.finish()
44
45
46