mirror of
https://github.com/byt3bl33d3r/MITMf.git
synced 2025-08-14 02:37:06 -07:00
initial commit
This commit is contained in:
parent
fbf31c220a
commit
6fa335183c
37 changed files with 2698 additions and 0 deletions
47
plugins/Upsidedownternet.py
Normal file
47
plugins/Upsidedownternet.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
import logging
|
||||
from cStringIO import StringIO
|
||||
from plugins.plugin import Plugin
|
||||
|
||||
class Upsidedownternet(Plugin):
|
||||
name = "Upsidedownternet"
|
||||
optname = "upsidedownternet"
|
||||
desc = 'Flips images 180 degrees'
|
||||
has_opts = False
|
||||
implements = ["handleResponse","handleHeader"]
|
||||
|
||||
def initialize(self,options):
|
||||
from PIL import Image,ImageFile
|
||||
globals()['Image'] = Image
|
||||
globals()['ImageFile'] = ImageFile
|
||||
self.options = options
|
||||
|
||||
def handleHeader(self,request,key,value):
|
||||
'''Kill the image skipping that's in place for speed reasons'''
|
||||
if request.isImageRequest:
|
||||
request.isImageRequest = False
|
||||
request.isImage = True
|
||||
request.imageType = value.split("/")[1].upper()
|
||||
|
||||
def handleResponse(self,request,data):
|
||||
try:
|
||||
isImage = getattr(request,'isImage')
|
||||
except AttributeError:
|
||||
isImage = False
|
||||
|
||||
if isImage:
|
||||
try:
|
||||
image_type=request.imageType
|
||||
#For some reason more images get parsed using the parser
|
||||
#rather than a file...PIL still needs some work I guess
|
||||
p = ImageFile.Parser()
|
||||
p.feed(data)
|
||||
im = p.close()
|
||||
im=im.transpose(Image.ROTATE_180)
|
||||
output = StringIO()
|
||||
im.save(output,format=image_type)
|
||||
data=output.getvalue()
|
||||
output.close()
|
||||
logging.info("Flipped image")
|
||||
except Exception as e:
|
||||
print "Error: %s" % e
|
||||
return {'request':request,'data':data}
|
Loading…
Add table
Add a link
Reference in a new issue