mirror of
https://github.com/byt3bl33d3r/MITMf.git
synced 2025-07-07 05:22:15 -07:00
Cleanup
This commit is contained in:
parent
3fb5f3d20d
commit
60e8856d36
1 changed files with 13 additions and 13 deletions
|
@ -11,25 +11,25 @@ class Replace(CacheKill,Plugin):
|
|||
desc = "Replace arbitrary content in HTML content"
|
||||
|
||||
def initialize(self,options):
|
||||
'''Called if plugin is enabled, passed the options namespace'''
|
||||
self.options = options
|
||||
|
||||
self.search_str = options.search_str
|
||||
self.replace_str = options.replace_str
|
||||
self.regex_file = options.regex_file
|
||||
|
||||
if self.options.keep_cache:
|
||||
self.implements.remove("handleHeader")
|
||||
self.implements.remove("connectionMade")
|
||||
|
||||
if self.search_str==self.replace_str=="" and self.regex_file is None:
|
||||
print "[*] Please provide a search and replace string or a regex file"
|
||||
quit()
|
||||
if (self.search_str==None or self.search_str=="") and self.regex_file is None:
|
||||
sys.exit("[*] Please provide a search string or a regex file")
|
||||
|
||||
self.regexes = []
|
||||
if self.regex_file is not None:
|
||||
print "[*] Loading regexes from file"
|
||||
for line in self.regex_file:
|
||||
self.regexes.append(line.strip().split("\t"))
|
||||
|
||||
if self.options.keep_cache:
|
||||
self.implements.remove("handleHeader")
|
||||
self.implements.remove("connectionMade")
|
||||
|
||||
self.ctable = {}
|
||||
self.dtable = {}
|
||||
self.mime = "text/html"
|
||||
|
@ -40,8 +40,8 @@ class Replace(CacheKill,Plugin):
|
|||
ip,hn,mime = self._get_req_info(request)
|
||||
|
||||
if self._should_replace(ip,hn,mime):
|
||||
# Did the user provide us a search and replace str?
|
||||
if self.search_str!="" and self.replace_str!="":
|
||||
|
||||
if self.search_str!=None and self.search_str!="":
|
||||
data = data.replace(self.search_str, self.replace_str)
|
||||
logging.info("%s [%s] Replaced '%s' with '%s'" % (request.client.getClientIP(), request.headers['host'], self.search_str, self.replace_str))
|
||||
|
||||
|
@ -51,9 +51,9 @@ class Replace(CacheKill,Plugin):
|
|||
try:
|
||||
data = re.sub(regex[0], regex[1], data)
|
||||
|
||||
logging.info("%s [%s] Replaced '%s' with '%s'" % (request.client.getClientIP(), request.headers['host'], regex[0], regex[1]))
|
||||
logging.info("%s [%s] Occurances matching '%s' replaced with '%s'" % (request.client.getClientIP(), request.headers['host'], regex[0], regex[1]))
|
||||
except Exception, e:
|
||||
logging.error("%s [%s] Your provided regex (%s) or replace value (%s) is empyt or invalid. Please debug your provided regex(es)" % (request.client.getClientIP(), request.headers['host'], regex[0], regex[1]))
|
||||
logging.error("%s [%s] Your provided regex (%s) or replace value (%s) is empty or invalid. Please debug your provided regex(es)" % (request.client.getClientIP(), request.headers['host'], regex[0], regex[1]))
|
||||
|
||||
self.ctable[ip] = time.time()
|
||||
self.dtable[ip+hn] = True
|
||||
|
@ -63,8 +63,8 @@ class Replace(CacheKill,Plugin):
|
|||
return
|
||||
|
||||
def add_options(self,options):
|
||||
options.add_argument("--search-str",type=str,default=None,help="String you would like to replace --replace-str with. Default: '' (empty string)")
|
||||
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("--regex-file",type=file,help="Load file with regexes. File format: <regex1>[tab]<regex2>[new-line]")
|
||||
options.add_argument("--keep-cache",action="store_true",help="Don't kill the server/client caching.")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue