def call_sslyze(target, port, commands, timeout=15): """ Calls sslyze, and returns the result Result: (success: boolean, data: unicode) """ commands.insert(0, '--timeout=%s' % timeout) commands.append("%s:%s" % (target, str(port))) return call.call(["python", _SSLYZE_CMD] + commands)
def main(self, *args, **kwargs): """ Main function @param args: @param kwargs: @return: """ cmd = os.path.join(self._get_library_path("harvester"), "theHarvester_email.py") ok, output = call.call(["python", cmd, "-b", "all", "-d", self.target]) if ok: self._write_result(output) else: self._write_result("ERROR CALLING theHarvester script")
def _ping(self, target, packet): """ Call ping """ ok, out = call.call(['ping', '-s', str(packet - 8), '-c', '1', target]) if not ok: raise ValueError('"ping" calling error!') for line in out.split('\n'): if 'unknown host' in line: raise ValueError('Unknown host: %s' % target) elif 'bytes from' in line or '0 received' in line: return '%s: %s' % (packet, line) return ''
def main(self, *args): """ Main function """ target = self.host or self.ip self._check_stop() called_ok, output = call.call(["traceroute", target]) self._check_stop() if not called_ok: self._write_result('Traceroute launching error!') else: if output.find('Cannot handle "host"') >= 0: self._write_result('Host not found: %s' % target) else: self._write_result(output)
def get_cms_type(url): """ Returns ( success/failure of CMS-Explorer call: bool, type of CMS for url: string ) """ with call.cd(_CMS_EXPLORER_PATH): for cms in _CMS_LIST: res, out = call.call([ "perl", "cms-explorer.pl", "-url", url, "-type", cms, "-verbosity", "1" ]) if not res: return False, "" if out.find("Installed:") >= 0: output = "%s Detected\n%s" % (cms.capitalize(), out) return True, output return True, "Nothing found."
def dispatch(self, origin, args): bytes, event, args = args[0], args[1], args[2:] text = decode(bytes) for priority in ('high', 'medium', 'low'): items = self.commands[priority].items() for regexp, funcs in items: for func in funcs: if event != func.event: continue match = regexp.match(text) if not match: continue code = self.wrapped(origin, text, match) input = self.input( origin, text, bytes, match, event, args ) nick = input.nick.lower() # blocking ability if os.path.isfile("blocks"): g = open("blocks", "r") contents = g.readlines() g.close() try: bad_masks = contents[0].split(',') except: bad_masks = [''] try: bad_nicks = contents[1].split(',') except: bad_nicks = [''] # check for blocked hostmasks if len(bad_masks) > 0: host = origin.host host = host.lower() for hostmask in bad_masks: hostmask = hostmask.replace( "\n", "").strip() if len(hostmask) < 1: continue try: re_temp = re.compile(hostmask) if re_temp.findall(host): return except: if hostmask in host: return # check for blocked nicks if len(bad_nicks) > 0: for nick in bad_nicks: nick = nick.replace("\n", "").strip() if len(nick) < 1: continue try: re_temp = re.compile(nick) if re_temp.findall(input.nick): return except: if nick in input.nick: return if func.thread: targs = (self, func, origin, code, input) t = threading.Thread(target=call, args=targs) t.start() else: call(self, func, origin, code, input)