mirror of
https://github.com/byt3bl33d3r/MITMf.git
synced 2025-07-07 21:42:17 -07:00
Replace on self is useless
This commit is contained in:
parent
3031412133
commit
3d3099fb00
1 changed files with 39 additions and 39 deletions
|
@ -4,53 +4,53 @@ from plugins.plugin import Plugin
|
||||||
from plugins.CacheKill import CacheKill
|
from plugins.CacheKill import CacheKill
|
||||||
|
|
||||||
class Replace(CacheKill,Plugin):
|
class Replace(CacheKill,Plugin):
|
||||||
name = "Replace"
|
name = "Replace"
|
||||||
optname = "replace"
|
optname = "replace"
|
||||||
implements = ["handleResponse","handleHeader","connectionMade"]
|
implements = ["handleResponse","handleHeader","connectionMade"]
|
||||||
has_opts = True
|
has_opts = True
|
||||||
desc = "Replace arbitrary content in HTML content"
|
desc = "Replace arbitrary content in HTML content"
|
||||||
|
|
||||||
def initialize(self,options):
|
def initialize(self,options):
|
||||||
'''Called if plugin is enabled, passed the options namespace'''
|
'''Called if plugin is enabled, passed the options namespace'''
|
||||||
self.options = options
|
self.options = options
|
||||||
self.match_str = options.match_str
|
self.search_str = options.search_str
|
||||||
self.replace_str = options.replace_str
|
self.replace_str = options.replace_str
|
||||||
|
|
||||||
if self.options.preserve_cache:
|
if self.options.keep_cache:
|
||||||
self.implements.remove("handleHeader")
|
self.implements.remove("handleHeader")
|
||||||
self.implements.remove("connectionMade")
|
self.implements.remove("connectionMade")
|
||||||
|
|
||||||
self.ctable = {}
|
self.ctable = {}
|
||||||
self.dtable = {}
|
self.dtable = {}
|
||||||
self.mime = "text/html"
|
self.mime = "text/html"
|
||||||
|
|
||||||
print "[*] Replace plugin online"
|
print "[*] Replace plugin online"
|
||||||
|
|
||||||
def handleResponse(self,request,data):
|
def handleResponse(self,request,data):
|
||||||
ip,hn,mime = self._get_req_info(request)
|
ip,hn,mime = self._get_req_info(request)
|
||||||
|
|
||||||
if self._should_replace(ip,hn,mime) and (not self.replace_str==self.search_str==None) and (not self.search_str==""):
|
if self._should_replace(ip,hn,mime) and (not self.replace_str==self.search_str==None) and (not self.search_str==""):
|
||||||
data = self.replace(self.search_str, self.replace_str)
|
data = data.replace(self.search_str, self.replace_str)
|
||||||
|
self.ctable[ip] = time.time()
|
||||||
|
self.dtable[ip+hn] = True
|
||||||
|
|
||||||
self.ctable[ip] = time.time()
|
logging.info("%s [%s] Replaced '%s' with '%s'" % (request.client.getClientIP(), request.headers['host'], self.search_str, self.replace_str))
|
||||||
self.dtable[ip+hn] = True
|
|
||||||
|
|
||||||
logging.info("%s [%s] Replaced '%s' with '%s'" % (request.client.getClientIP(), request.headers['host'], self.match_str, self.replace_str))
|
return {'request':request,'data':data}
|
||||||
|
|
||||||
return {'request':request,'data':data}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def add_options(self,options):
|
def add_options(self,options):
|
||||||
options.add_argument("--replace-str",type=str,default="",help="String you would like to replace.")
|
options.add_argument("--replace-str",type=str,default="",help="String you would like to replace.")
|
||||||
options.add_argument("--search-str",type=str,default="",help="String you would like to replace --replace-str with. Default: '' (empty string)")
|
options.add_argument("--search-str",type=str,default="",help="String you would like to replace --replace-str with. Default: '' (empty string)")
|
||||||
options.add_argument("--preserve-cache",action="store_true",help="Don't kill the server/client caching.")
|
options.add_argument("--keep-cache",action="store_true",help="Don't kill the server/client caching.")
|
||||||
|
|
||||||
def _should_replace(self,ip,hn,mime):
|
def _should_replace(self,ip,hn,mime):
|
||||||
return mime.find(self.mime)!=-1
|
return mime.find(self.mime)!=-1
|
||||||
|
|
||||||
def _get_req_info(self,request):
|
def _get_req_info(self,request):
|
||||||
ip = request.client.getClientIP()
|
ip = request.client.getClientIP()
|
||||||
hn = request.client.getRequestHostname()
|
hn = request.client.getRequestHostname()
|
||||||
mime = request.client.headers['Content-Type']
|
mime = request.client.headers['Content-Type']
|
||||||
return (ip,hn,mime)
|
|
||||||
|
return (ip,hn,mime)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue