/usr/lib/python2.7/dist-packages/Halberd/ScanTask.py is in python-halberd 0.2.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | # -*- coding: iso-8859-1 -*-
"""Scanning tasks.
@var default_scantime: Time to spend probing the target expressed in seconds.
@type default_scantime: C{int}
@var default_parallelism: Number of parallel threads to launch for the scan.
@type default_parallelism: C{int}
@var default_conf_dir: Path to the directory where the configuration file is
located.
@type default_conf_dir: C{str}
@var default_conf_file: Name of the default configuration file for halberd.
@type default_conf_file: C{str}
@var default_ratio_threshold: Minimum clues-to-realservers ratio to trigger a
clue reanalysis.
@type default_ratio_threshold: C{float}
@var default_out: Default place where to write reports (None means stdout).
@type default_out: C{str}
"""
# Copyright (C) 2004, 2005, 2006, 2010 Juan M. Bello Rivas <jmbr@superadditive.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
import Halberd.conflib
default_scantime = 15
default_parallelism = 4
default_conf_dir = os.path.join(os.path.expanduser('~'), '.halberd')
default_conf_file = os.path.join(default_conf_dir,
'halberd' + os.extsep + 'cfg')
default_ratio_threshold = 0.6
default_out = None
class ConfError(Exception):
"""Error with configuration file(s)
"""
def __init__(self, msg):
self.msg = msg
def __str__(self):
return str(self.msg)
class ScanTask:
"""Describes the way a scan should be performed.
@ivar verbose: Display status information during the scan.
@type verbose: C{bool}
@ivar debug: Display debug information.
@type debug: C{bool}
@ivar urlfile: Root folder to use for storing results of MultiScans.
@type urlfile: C{str}
@ivar url: URL to scan.
@type url: C{str}
@ivar addr: Address of the target web server.
@type addr: C{str}
@ivar proxy_serv_addr: Address + port where to listen when operating as a
proxy.
@type proxy_serv_addr: C{tuple}
@ivar out: File where to write reports. If it's not set, stdout will be
used.
@type out: C{str}
@ivar save: File or directory name where the results will be written.
@type save: C{str}
@ivar keyfile: Key file for SSL connections.
@type keyfile: C{str}
@ivar certfile: Certificate to be used for SSL connections.
@type certfile: C{str}
@ivar clues: Sequence of clues obtained from the target.
@type clues: C{list}
@ivar analyzed: Sequence of clues after the analysis phase.
@type analyzed: C{list}
"""
def __init__(self):
self.scantime = default_scantime
self.parallelism = default_parallelism
self.conf_file = default_conf_file
self.verbose = False
self.debug = False
self.ratio_threshold = default_ratio_threshold
self.urlfile = ''
self.url = ''
self.addr = ''
self.proxy_serv_addr = ()
self.save = ''
self.out = default_out
self.keyfile = None
self.certfile = None
self.clues = []
self.analyzed = []
def readConf(self):
"""Read configuration file.
This method tries to read the specified configuration file. If we try
to read it at the default path and it's not there we create a
bare-bones file and use that one.
@raise ConfError: If there's some problem creating or reading the
configuration file.
"""
# xxx - Move this into Halberd.conflib as a higher level function.
reader = Halberd.conflib.ConfReader()
try:
reader.open(self.conf_file)
except IOError:
if self.conf_file == default_conf_file:
try:
os.mkdir(default_conf_dir)
reader.writeDefault(default_conf_file)
reader.open(default_conf_file)
except (OSError, IOError):
raise ConfError, 'unable to create a default conf. file'
else:
raise ConfError, 'unable to open configuration file %s\n'
except conflib.InvalidConfFile:
raise ConfError, 'invalid configuration file %s\n' % self.conf_file
confvals = reader.parse()
self.proxy_serv_addr = confvals[0]
self.keyfile, self.certfile = confvals[1:]
reader.close()
# vim: ts=4 sw=4 et
|