Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python2.7
- from scapy.all import *
- from scapy_http import http # for layer HTTP
- from default import PSniffer # base plugin class
- class ExamplePlugin(PSniffer):
- _activated = False
- _instance = None
- meta = {
- 'Name' : 'Example',
- 'Version' : '1.0',
- 'Description' : 'Brief description of the new plugin',
- 'Author' : 'your name',
- }
- def __init__(self):
- for key,value in self.meta.items():
- self.__dict__[key] = value
- @staticmethod
- def getInstance():
- if ExamplePlugin._instance is None:
- ExamplePlugin._instance = ExamplePlugin()
- return ExamplePlugin._instance
- def filterPackets(self,pkt): # (pkt) object in order to modify the data on the fly
- if pkt.haslayer(http.HTTPRequest): # filter only http request
- http_layer = pkt.getlayer(http.HTTPRequest) # get http fields as dict type
- ip_layer = pkt.getlayer(IP)# get ip headers fields as dict type
- print http_layer.fields['Method'] # show method http request
- # show all item in Header request http
- for item in http_layer.fields['Headers']:
- print('{} : {}'.format(item,http_layer.fields['Headers'][item]))
- print ip_layer.fields['src'] # show source ip address
- print ip_layer.fields['dst'] # show destiny ip address
- print http_layer # show item type dict
- print ip_layer # show item type dict
- return self.output.emit({'name_module':'send output to tab TCP-Proxy'})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement