def data(self, index, role):
        plugin = self.plugins[index.row()][0]
        if index.isValid():
            if role == Qt.DisplayRole:
                return QVariant(plugin.name)
            if role == Qt.DecorationRole:
                for directory in GeneralUtilities.getPluginDirs():
                    picturePath = os.path.join(directory,
                                               plugin.plugin_object.name,
                                               'logo.png')
                    if picturePath and os.path.exists(picturePath):
                        pixmap = QPixmap(picturePath)
                        return QIcon(
                            pixmap.scaled(30, 30, Qt.IgnoreAspectRatio,
                                          Qt.FastTransformation))
                pixmap = QPixmap(
                    os.path.join(GeneralUtilities.getIncludeDir(),
                                 'generic_plugin.png'))
                pixmap.scaled(30, 30, Qt.IgnoreAspectRatio)
                return QIcon(pixmap)
            if role == Qt.CheckStateRole:
                if plugin:
                    return Qt.Checked if plugin.name in self.checkedPlugins else Qt.Unchecked

        else:
            return QVariant()
Example #2
0
 def saveConfiguration(self, new_config):
     try:
         for c in ['string_options', 'boolean_options']:
             for l in self.config[c].keys():
                 if self.config[c][l] != new_config[c][l]:
                     self.config[c][l] = new_config[c][l]
         GeneralUtilities.getLocalPluginDir(self.name)
         self.config.write()
     except Exception, err:
         logger.error('Could not save the configuration for the ' + self.name + ' plugin.')
         logger.exception(err)
Example #3
0
 def saveConfiguration(self, new_config):
     try:
         # XXX Figure out why original code only stored these two sections,
         # XXX and not all of them
         for c in ['string_options', 'boolean_options']:
             for l in self.config[c].keys():
                 if self.config[c][l] != new_config[c][l]:
                     self.config[c][l] = new_config[c][l]
         GeneralUtilities.getLocalPluginDir(self.name)
         self.config.write()
     except Exception, err:
         logger.error('Could not save the configuration for the '+self.name+' plugin.')
         logger.exception(err)
 def data(self, index, role):
     target = self.targets[index.row()]
     if index.isValid() and (0 <= index.row() < len(self.targets)) and target: 
         column = index.column()
         if role == Qt.DecorationRole:
             if column == 1:
                 picturePath = os.path.join(GeneralUtilities.getTempDir(),
                                            target['targetPicture'])
                 if picturePath and os.path.exists(picturePath):
                     pixmap = QPixmap(picturePath)
                     return QIcon(pixmap.scaled(30, 30, Qt.IgnoreAspectRatio, Qt.FastTransformation))
                 else:
                     pixmap = QPixmap(':/creepy/user')
                     pixmap.scaled(20, 20, Qt.IgnoreAspectRatio)
                     return QIcon(pixmap)
         if role == Qt.DisplayRole:
             if column == 0:
                 return QVariant(target['pluginName'])
             elif column == 1:
                 return QVariant()
             elif column == 2:
                 return QVariant(target['targetUsername'])
             elif column == 3:
                 return QVariant(target['targetFullname'])
             elif column == 4:
                 return QVariant(target['targetUserid'])
     else: 
         return QVariant()
 def data(self, index, role):
     target = self.targets[index.row()]
     if index.isValid() and (0 <= index.row() < len(
             self.targets)) and target:
         column = index.column()
         if role == Qt.DecorationRole:
             if column == 1:
                 picturePath = os.path.join(GeneralUtilities.getTempDir(),
                                            target['targetPicture'])
                 if picturePath and os.path.exists(picturePath):
                     pixmap = QPixmap(picturePath)
                     return QIcon(
                         pixmap.scaled(30, 30, Qt.IgnoreAspectRatio,
                                       Qt.FastTransformation))
                 else:
                     pixmap = QPixmap(':/creepy/user')
                     pixmap.scaled(20, 20, Qt.IgnoreAspectRatio)
                     return QIcon(pixmap)
         if role == Qt.DisplayRole:
             if column == 0:
                 return QVariant(target['pluginName'])
             elif column == 1:
                 return QVariant()
             elif column == 2:
                 return QVariant(target['targetUsername'])
             elif column == 3:
                 return QVariant(target['targetFullname'])
             elif column == 4:
                 return QVariant(target['targetUserid'])
     else:
         return QVariant()
Example #6
0
    def searchForTargets(self, search_term):
        logger.debug('Attempting to search for targets. Search term was : ' +
                     search_term)
        possibleTargets = []
        try:
            if self.api is None:
                self.api = self.getAuthenticatedAPI()
            results = self.api.user_search(q=search_term)

            for i in results:
                target = {'pluginName': 'Instagram Plugin'}
                target['targetUserid'] = i.id
                target['targetUsername'] = i.username
                target['targetPicture'] = 'profile_pic_%s' % i.id
                target['targetFullname'] = i.full_name
                # save the pic in the temp folder to show it later
                filename = 'profile_pic_%s' % i.id
                temp_file = os.path.join(GeneralUtilities.getTempDir(),
                                         filename)
                if not os.path.exists(temp_file):
                    urllib.urlretrieve(i.profile_picture, temp_file)
                possibleTargets.append(target)
            logger.debug(
                str(len(possibleTargets)) +
                ' possible targets were found matching the search query')
        except Exception as err:
            logger.error('Error searching for targets with instagram plugin.')
            logger.error(err)
        return possibleTargets
Example #7
0
 def searchForTargets(self, search_term):
     possibleTargets = []
     logger.debug('Searching for Targets from Twitter Plugin. Search term is : ' + search_term)
     try:
         if self.api is None:
             self.api = self.getAuthenticatedAPI()
         search_results = self.api.search_users(q=search_term)
         if search_results:
             logger.debug('Twitter returned  ' + str(len(search_results)) + ' results')
             for i in search_results:
                 if self.options_boolean['exclude_geo_disabled'] == 'True' and not i.geo_enabled:
                     continue
                 target = {'pluginName': 'Twitter Plugin'}
                 target['targetUserid'] = i.id_str
                 target['targetUsername'] = i.screen_name
                 target['targetPicture'] = 'profile_pic_%s' % i.id_str
                 target['targetFullname'] = i.name
                 # save the pic in the temp folder to show it later
                 filename = 'profile_pic_%s' % i.id_str
                 temp_file = os.path.join(GeneralUtilities.getTempDir(), filename)
                 # Retieve and save the profile phot only if it does not exist
                 if not os.path.exists(temp_file):
                     urllib.urlretrieve(i.profile_image_url, temp_file)
                 possibleTargets.append(target)
     except tweepy.TweepError, e:
         logger.error('Error authenticating with Twitter API.')
         logger.error(e)
         if e.response.status_code == 429:
             remaining, limit, reset = self.getRateLimitStatus('search_users')
             return False, 'Error authenticating with Twitter: {0}. Your limits will be renewed at : {1}'.format(
                 e.message, reset.strftime('%Y-%m-%d %H:%M:%S %z'))
         return False, 'Error authenticating with Twitter: {0}'.format(e.message)
Example #8
0
 def deleteProject(self, projectName):
     # projectName comes as a Unicode, so we need to encode it to a string for shelve to find it
     try:
         os.remove(os.path.join(GeneralUtilities.getProjectsDir(), projectName.encode('utf-8')))
     except Exception, err:
         logger.error('Error deleting the project')
         logger.exception(err)
 def __init__(self, parent=None):
     # Load the installed plugins and read their metadata
     self.PluginManager = PluginManagerSingleton.get()
     self.PluginManager.setCategoriesFilter({'Input': InputPlugin})
     self.PluginManager.setPluginPlaces(GeneralUtilities.getPluginDirs())
     self.PluginManager.locatePlugins()
     self.PluginManager.collectPlugins()
     QDialog.__init__(self, parent)
     self.ui = Ui_PluginsConfigurationDialog()
     self.ui.setupUi(self)
Example #10
0
 def getConfigObj(self, config_filename=None):
     if config_filename is None:
         config_filename = self.name+".conf"
     configfiles = []
     for dir in GeneralUtilities.getPluginDirs():
         configfiles.append(expanduser(os.path.join(dir, self.name, config_filename)))
     logger.debug("Loading config from: "+str(configfiles))
     config = MultiLevelConfigObj(infiles = configfiles)
     config.create_empty = False
     return config
 def __init__(self, parent=None):
     # Load the installed plugins and read their metadata
     self.PluginManager = PluginManagerSingleton.get()
     self.PluginManager.setCategoriesFilter({'Input': InputPlugin})
     self.PluginManager.setPluginPlaces(GeneralUtilities.getPluginDirs())
     self.PluginManager.locatePlugins()
     self.PluginManager.collectPlugins()
     QDialog.__init__(self, parent)
     self.ui = Ui_PluginsConfigurationDialog()
     self.ui.setupUi(self)
Example #12
0
 def getConfigObj(self, config_filename=None):
     if config_filename is None:
         config_filename = self.name + '.conf'
     configfiles = []
     for directory in GeneralUtilities.getPluginDirs():
         configfiles.append(expanduser(os.path.join(directory, self.name, config_filename)))
     logger.debug('Loading config from: ' + str(configfiles))
     config = MultiLevelConfigObj(infiles=configfiles)
     config.create_empty = False
     return config
 def loadConfiguredPlugins(self):
     """
     Returns a list with the configured plugins that can be used for place based projects
     """
     self.PluginManager = PluginManagerSingleton.get()
     self.PluginManager.setCategoriesFilter({'Input': InputPlugin})
     self.PluginManager.setPluginPlaces(GeneralUtilities.getPluginDirs())
     self.PluginManager.locatePlugins()
     self.PluginManager.loadPlugins()
     pluginList = sorted(self.PluginManager.getAllPlugins(), key=lambda x: x.name)
     return [[plugin, 0] for plugin in pluginList if plugin.plugin_object.hasLocationBasedMode is True]
 def data(self, index, role):
     plugin = self.plugins[index.row()][0]
     if index.isValid():
         if role == Qt.DisplayRole:
             return QVariant(plugin.name)
         if role == Qt.DecorationRole:
             for dir in GeneralUtilities.getPluginDirs():
                 picturePath = os.path.join(dir, plugin.plugin_object.name, 'logo.png')
                 if picturePath and os.path.exists(picturePath):
                     pixmap = QPixmap(picturePath)
                     return QIcon(pixmap.scaled(30, 30, Qt.IgnoreAspectRatio, Qt.FastTransformation))
             pixmap = QPixmap(os.path.join(GeneralUtilities.getIncludeDir(), 'generic_plugin.png'))
             pixmap.scaled(30, 30, Qt.IgnoreAspectRatio)
             return QIcon(pixmap)
         if role == Qt.CheckStateRole:
             if plugin:
                 return (Qt.Checked if plugin.name in self.checkedPlugins else Qt.Unchecked)
                 
     else: 
         return QVariant()
Example #15
0
 def loadConfiguredPlugins(self):
     '''
     Returns a list with the configured plugins that can be used
     '''
     self.PluginManager = PluginManagerSingleton.get()
     self.PluginManager.setCategoriesFilter({'Input': InputPlugin})
     self.PluginManager.setPluginPlaces(GeneralUtilities.getPluginDirs())
     self.PluginManager.locatePlugins()
     self.PluginManager.loadPlugins()
     pluginList = sorted(self.PluginManager.getAllPlugins(), key=lambda x: x.name)
     return [[plugin, 0] for plugin in pluginList]
Example #16
0
    def storeProject(self, projectNodeObject):
        """
        Receives a projectNodeObject and stores it using the selected data persistence method.
        Decoupled here for flexibility
        """
        projectName = projectNodeObject.name().encode('utf-8') + '.db'

        storedProject = shelve.open(os.path.join(GeneralUtilities.getProjectsDir(), projectName))
        try:
            storedProject['project'] = projectNodeObject
        except Exception, err:
            logger.error('Error saving the project ')
            logger.exception(err)
Example #17
0
 def loadConfiguredPlugins(self):
     """
     Returns a list with the configured plugins that can be used for place based projects
     """
     self.PluginManager = PluginManagerSingleton.get()
     self.PluginManager.setCategoriesFilter({'Input': InputPlugin})
     self.PluginManager.setPluginPlaces(GeneralUtilities.getPluginDirs())
     self.PluginManager.locatePlugins()
     self.PluginManager.loadPlugins()
     pluginList = sorted(self.PluginManager.getAllPlugins(),
                         key=lambda x: x.name)
     return [[plugin, 0] for plugin in pluginList
             if plugin.plugin_object.hasLocationBasedMode is True]
Example #18
0
 def data(self, index, role):
     pluginListItem= self.plugins[index.row()]
     if index.isValid():
         if role == Qt.DisplayRole:
             return QVariant(pluginListItem[0].name)
         if role == Qt.DecorationRole:
             for directory in GeneralUtilities.getPluginDirs():
                 picturePath = os.path.join(directory, pluginListItem[0].plugin_object.name, 'logo.png')
                 if picturePath and os.path.exists(picturePath):
                     pixmap = QPixmap(picturePath)
                     return QIcon(pixmap)
             pixmap = QPixmap(':/creepy/folder')
             return QIcon(pixmap)
     else: 
         return QVariant()
Example #19
0
 def searchForTargets(self, search_term):
     possibleTargets = []
     logger.debug(
         'Searching for Targets from Twitter Plugin. Search term is : ' +
         search_term)
     try:
         if self.api is None:
             self.api = self.getAuthenticatedAPI()
         search_results = self.api.search_users(q=search_term)
         if search_results:
             logger.debug('Twitter returned  ' + str(len(search_results)) +
                          ' results')
             for i in search_results:
                 if self.options_boolean[
                         'exclude_geo_disabled'] == 'True' and not i.geo_enabled:
                     continue
                 target = {'pluginName': 'Twitter Plugin'}
                 target['targetUserid'] = i.id_str
                 target['targetUsername'] = i.screen_name
                 target['targetPicture'] = 'profile_pic_%s' % i.id_str
                 target['targetFullname'] = i.name
                 # save the pic in the temp folder to show it later
                 filename = 'profile_pic_%s' % i.id_str
                 temp_file = os.path.join(GeneralUtilities.getTempDir(),
                                          filename)
                 # Retieve and save the profile phot only if it does not exist
                 if not os.path.exists(temp_file):
                     urllib.urlretrieve(i.profile_image_url, temp_file)
                 possibleTargets.append(target)
     except tweepy.TweepError as e:
         logger.error('Error authenticating with Twitter API.')
         logger.error(e)
         if e.response.status_code == 429:
             remaining, limit, reset = self.getRateLimitStatus(
                 'search_users')
             return False, 'Error authenticating with Twitter: {0}. Your limits will be renewed at : {1}'.format(
                 e.message, reset.strftime('%Y-%m-%d %H:%M:%S %z'))
         return False, 'Error authenticating with Twitter: {0}'.format(
             e.message)
     except Exception as err:
         logger.error(err)
         logger.error('Error searching for targets in Twitter plugin.')
     return possibleTargets
Example #20
0
    def searchForTargets(self, search_term):
        logger.debug("Attempting to search for targets. Search term was : " + search_term)
        possibleTargets = []
        try:
            if self.api is None:
                self.api = self.getAuthenticatedAPI()
            results = self.api.user_search(q=search_term)

            for i in results:
                target = {'pluginName': 'Instagram Plugin'}
                target['targetUserid'] = i.id
                target['targetUsername'] = i.username
                target['targetPicture'] = 'profile_pic_%s' % i.id
                target['targetFullname'] = i.full_name
                # save the pic in the temp folder to show it later
                filename = 'profile_pic_%s' % i.id
                temp_file = os.path.join(GeneralUtilities.getTempDir(), filename)
                if not os.path.exists(temp_file):
                    urllib.urlretrieve(i.profile_picture, temp_file)
                possibleTargets.append(target)
            logger.debug(str(len(possibleTargets)) + " possible targets were found matching the search query")
        except Exception, err:
            logger.error("Error searching for targets with instagram plugin.")
            logger.error(err)
Example #21
0
import os
import logging
import urllib
from urlparse import urlparse, parse_qs

import pytz
from PyQt4.QtGui import QLabel, QLineEdit, QWizard, QWizardPage, QVBoxLayout, QMessageBox, QTextEdit, QPushButton
from instagram.client import InstagramAPI
from models.InputPlugin import InputPlugin
from utilities import GeneralUtilities, QtHandler
import functools
import webbrowser
# set up logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler(os.path.join(GeneralUtilities.getLogDir(), 'creepy_main.log'))
fh.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(levelname)s:%(asctime)s  In %(filename)s:%(lineno)d: %(message)s')
fh.setFormatter(formatter)
guiLoggingHandler = QtHandler.QtHandler()
guiLoggingHandler.setFormatter(formatter)
logger.addHandler(fh)
logger.addHandler(guiLoggingHandler)


class Instagram(InputPlugin):
    name = "instagram"
    hasWizard = True
    hasLocationBasedMode = True
    hasRateLimitInfo = False
Example #22
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
from yapsy.IPlugin import IPlugin
from configobj import ConfigObj
import logging
import os
from utilities import GeneralUtilities

# set up logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler(os.path.join(GeneralUtilities.getUserHome(), "creepy_main.log"))
fh.setLevel(logging.DEBUG)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
fh.setFormatter(formatter)
logger.addHandler(fh)


class InputPlugin(IPlugin):
    def __init__(self):
        pass

    def activate(self):
        pass

    def deactivate(self):
        pass

    def searchForTargets(self, search_term):
        return "dummyUser"
Example #23
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
from yapsy.IPlugin import IPlugin
from configobj import ConfigObj
import logging
import os
from utilities import GeneralUtilities

#set up logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler(
    os.path.join(GeneralUtilities.getLogDir(), 'creepy_main.log'))
fh.setLevel(logging.DEBUG)
formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
logger.addHandler(fh)


class InputPlugin(IPlugin):
    hasLocationBasedMode = False

    def __init__(self):
        pass

    def activate(self):
        pass

    def hasLocationBasedMode(self):
        return False
Example #24
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
import shelve
import os
import logging
from utilities import GeneralUtilities
# set up logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler(
    os.path.join(GeneralUtilities.getUserHome(), 'creepy_main.log'))
fh.setLevel(logging.DEBUG)
formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
logger.addHandler(fh)


class Project(object):
    def __init__(self,
                 projectName=None,
                 selectedTargets=None,
                 projectKeywords=None,
                 projectDescription=None,
                 enabledPlugins=None,
                 dateCreated=None,
                 locations=None,
                 analysis=None,
                 dateEdited=None,
                 results=None,
                 viewSettings=None):
Example #25
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
import shelve
import os
import logging
from utilities import GeneralUtilities

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler(os.path.join(GeneralUtilities.getLogDir(), 'creepy_main.log'))
fh.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
logger.addHandler(fh)


class Project(object):
    def __init__(self, projectType=None, projectName=None, selectedTargets=None, projectKeywords=None,
                 projectDescription=None, enabledPlugins=None, dateCreated=None, locations=None, analysis=None,
                 analysisDocument=None,dateEdited=None, results=None, viewSettings=None, poi=None):
        self.projectType = projectType
        self.projectName = projectName
        self.selectedTargets = selectedTargets
        self.projectKeywords = projectKeywords
        self.projectDescription = projectDescription
        self.enabledPlugins = enabledPlugins
        self.dateCreated = dateCreated
        self.dateEdited = dateEdited
        self.locations = locations
        self.poi = poi
        self.analysis = analysis