@@ -0,0 +1,3025 @@
+# -*- coding: utf-8 -*-%0A# -------------------------------------------------------------------------------%0A# Name:         sfp_skymem%0A# Purpose:      SpiderFoot plug-in for retrieving up to six e-mail addresses%0A#               belonging to your target from Skymem.%0A#%0A# Author:      Brendan Coles %3Cbcoles@gmail.com%3E%0A#%0A# Created:     29/09/2018%0A# Copyright:   (c) Brendan Coles 2018%0A# Licence:     GPL%0A# -------------------------------------------------------------------------------%0A%0Aimport re%0Afrom sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent%0A%0A%0Aclass sfp_skymem(SpiderFootPlugin):%0A    %22%22%22Skymem:Footprint,Investigate,Passive:Search Engines::Look up e-mail addresses on Skymem.%22%22%22%0A%0A%0A    results = list()%0A%0A    # Default options%0A    opts = %7B%0A    %7D%0A%0A    # Option descriptions%0A    optdescs = %7B%0A    %7D%0A%0A    def setup(self, sfc, userOpts=dict()):%0A        self.sf = sfc%0A        self.__dataSource__ = %22Skymem%22%0A        self.results = list()%0A%0A        for opt in userOpts.keys():%0A            self.opts%5Bopt%5D = userOpts%5Bopt%5D%0A%0A    # What events is this module interested in for input%0A    def watchedEvents(self):%0A        return %5B%22DOMAIN_NAME%22%5D%0A%0A    # What events this module produces%0A    # This is to support the end user in selecting modules based on events%0A    # produced.%0A    def producedEvents(self):%0A        return %5B%22EMAILADDR%22%5D%0A%0A    # Handle events sent to this module%0A    def handleEvent(self, event):%0A        eventName = event.eventType%0A        srcModuleName = event.module%0A        eventData = event.data%0A%0A        if eventData in self.results:%0A            return None%0A        else:%0A            self.results.append(eventData)%0A%0A        self.sf.debug(%22Received event, %22 + eventName + %22, from %22 + srcModuleName)%0A%0A        # Get e-mail addresses on this domain%0A        if eventName == %22DOMAIN_NAME%22:%0A            res = self.sf.fetchUrl(%22http://www.skymem.info/srch?q=%22 + eventData, timeout=self.opts%5B'_fetchtimeout'%5D, useragent=self.opts%5B'_useragent'%5D)%0A%0A        if res%5B'content'%5D is None:%0A            return None%0A%0A        pat = re.compile(%22(%5Ba-zA-Z%5C.0-9_%5C-%5D+@%5Ba-zA-Z%5C.0-9%5C-%5D+%5C.%5Ba-zA-Z%5C.0-9%5C-%5D+)%22)%0A        matches = re.findall(pat, res%5B'content'%5D)%0A        for match in matches:%0A            evttype = %22EMAILADDR%22%0A            self.sf.debug(%22Found possible email: %22 + match)%0A%0A            # Handle false positive matches%0A            if len(match) %3C 5:%0A                self.sf.debug(%22Likely invalid address.%22)%0A                continue%0A%0A            # Handle messed up encodings%0A            if %22%25%22 in match:%0A                self.sf.debug(%22Skipped address: %22 + match)%0A                continue%0A%0A            # Skip unrelated emails%0A            mailDom = match.lower().split('@')%5B1%5D%0A            if not self.getTarget().matches(mailDom):%0A                self.sf.debug(%22Skipped address: %22 + match)%0A                continue%0A%0A            self.sf.info(%22Found e-mail address: %22 + match)%0A            evt = SpiderFootEvent(evttype, match, self.__name__, event)%0A            self.notifyListeners(evt)%0A%0A        return None%0A%0A# End of sfp_skymem class%0A

Add Skymem module