Skip to content

Commit

Permalink
Fix #366 based on @alessandrofg's fix for develop.
Browse files Browse the repository at this point in the history
  • Loading branch information
DePierre committed Feb 21, 2015
1 parent 1b97af1 commit e97f84e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion framework/core.py
Expand Up @@ -396,6 +396,7 @@ def initialise_framework(self, options):
logging.info("Loading framework please wait..")
# self.initlogger()

self.initialise_plugin_handler_and_params(options)
# No processing required, just list available modules.
if options['list_plugins']:
self.PluginHandler.show_plugin_list(options['list_plugins'])
Expand All @@ -408,7 +409,6 @@ def initialise_framework(self, options):
self.StartProxy(options) # Proxy mode is started in that function.
# Set anonymised invoking command for error dump info.
self.Error.SetCommand(self.AnonymiseCommand(command))
self.initialise_plugin_handler_and_params(options)
return True

def initialise_plugin_handler_and_params(self, options):
Expand Down
7 changes: 3 additions & 4 deletions framework/db/plugin_manager.py
Expand Up @@ -210,7 +210,7 @@ def GenerateQueryUsingSession(self, criteria):
query = query.filter(models.Plugin.name.in_(criteria["name"]))
return query

def GetAll(self, criteria=None, not_criteria=None):
def GetAll(self, criteria={}, not_criteria=None):
query = self.GenerateQueryUsingSession(criteria)
if not_criteria is not None:
for key, value in not_criteria.iteritems():
Expand All @@ -228,9 +228,8 @@ def GetPluginsByType(self, PluginType):
def GetPluginsByGroup(self, PluginGroup):
return(self.GetAll({"group": PluginGroup}))

def GetPluginsByGroupType(self, PluginGroup, PluginTypeList):
plugins = self.Core.DB.session.query(models.Plugin).filter(models.Plugin.group == PluginGroup, models.Plugin.type.in_(PluginTypeList)).all()
return(self.DerivePluginDicts(plugins))
def GetPluginsByGroupType(self, PluginGroup, PluginType):
return self.GetAll({"type": PluginType, "group": PluginGroup})

def GetGroupsForPlugins(self, Plugins):
groups = self.Core.DB.session.query(models.Plugin.group).filter(or_(models.Plugin.code.in_(Plugins), models.Plugin.name.in_(Plugins))).distinct().all()
Expand Down
12 changes: 6 additions & 6 deletions framework/plugin/plugin_handler.py
Expand Up @@ -105,7 +105,7 @@ def PluginAlreadyRun(self, PluginInfo):
def NormalRequestsAllowed(self):
#AllowedPluginTypes = self.Core.Config.GetAllowedPluginTypes('web')
#GetAllowedPluginTypes('web')
AllowedPluginTypes = self.Core.Config.Plugin.GetAllowedTypes('web')
AllowedPluginTypes = self.Core.DB.Plugin.GetAllowedTypes('web')
return 'semi_passive' in AllowedPluginTypes or 'active' in AllowedPluginTypes

def RequestsPossible(self):
Expand Down Expand Up @@ -141,7 +141,7 @@ def IsActiveTestingPossible(self): # Checks if 1 active plugin is enabled = acti
Possible = False
#for PluginType, PluginFile, Title, Code, ReferenceURL in self.Core.Config.GetPlugins(): # Processing Loop
#for PluginType, PluginFile, Title, Code in self.Core.Config.Plugin.GetOrder(self.PluginGroup):
for Plugin in self.Core.Config.Plugin.GetOrder(self.PluginGroup):
for Plugin in self.Core.DB.Plugin.GetOrder(self.PluginGroup):
if self.IsChosenPlugin(Plugin) and Plugin['type'] == 'active':
Possible = True
break
Expand Down Expand Up @@ -328,10 +328,10 @@ def SwitchToTarget(self, Target):
self.Core.DB.Target.SetTarget(Target) # Tell Target DB that all Gets/Sets are now Target-specific

def get_plugins_in_order_for_PluginGroup(self, PluginGroup):
return self.Core.Config.Plugin.GetOrder(PluginGroup)
return self.Core.DB.Plugin.GetOrder(PluginGroup)

def get_plugins_in_order(self, PluginGroup):
return self.Core.Config.Plugin.GetOrder(PluginGroup)
return self.Core.DB.Plugin.GetOrder(PluginGroup)

def ProcessPluginsForTargetList(self, PluginGroup, Status, TargetList): # TargetList param will be useful for netsec stuff to call this
PluginDir = self.GetPluginGroupDir(PluginGroup)
Expand Down Expand Up @@ -402,12 +402,12 @@ def show_plugin_list(self, group, msg=INTRO_BANNER_GENERAL):
logging.info(msg + "\nAvailable AUXILIARY plugins:")
elif group == 'net':
logging.info(msg + "\nAvailable NET plugins:")
for plugin_type in self.Core.Config.Plugin.GetTypesForGroup(group):
for plugin_type in self.Core.DB.Plugin.GetTypesForGroup(group):
self.show_plugin_types(plugin_type, group)

def show_plugin_types(self, plugin_type, group):
logging.info("\n" + '*' * 40 + " " + plugin_type.title().replace('_', '-') + " plugins " + '*' * 40)
for Plugin in self.Core.Config.Plugin.GetAll(group, plugin_type):
for Plugin in self.Core.DB.Plugin.GetPluginsByGroupType(group, plugin_type):
# 'Name' : PluginName, 'Code': PluginCode, 'File' : PluginFile, 'Descrip' : PluginDescrip } )
LineStart = " " + Plugin['type'] + ": " + Plugin['name']
Pad1 = "_" * (60 - len(LineStart))
Expand Down

0 comments on commit e97f84e

Please sign in to comment.