From 3191d43722774ac2fbde4a4db8bf806143c5bd56 Mon Sep 17 00:00:00 2001 From: Naboot42 Date: Fri, 4 Aug 2023 11:48:00 +0200 Subject: [PATCH] add theHarvester --- secator/tasks/theHarvester.py | 72 ++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/secator/tasks/theHarvester.py b/secator/tasks/theHarvester.py index fbe24c12..4a3931fc 100644 --- a/secator/tasks/theHarvester.py +++ b/secator/tasks/theHarvester.py @@ -1,26 +1,30 @@ -import os import json +import os + +import validators from secator.decorators import task -from secator.definitions import (DELAY, PROXY, RATE_LIMIT, RETRIES, THREADS, TIMEOUT, PROXY, LIMIT, SCREENSHOT, OPT_NOT_SUPPORTED, TEMP_FOLDER) +from secator.definitions import (DELAY, LIMIT, OPT_NOT_SUPPORTED, PROXY, + RATE_LIMIT, RETRIES, SCREENSHOT, TEMP_FOLDER, + THREADS, TIMEOUT) +from secator.output_types import Ip, Subdomain, Url, UserAccount from secator.tasks._categories import ReconUser from secator.utils import get_file_timestamp -from secator.output_types import UserAccount + @task() class theHarvester(ReconUser): - """theHarvester is a simple to use, yet powerful tool designed to be used during the reconnaissance stage of a red -team assessment or penetration test.""" - cmd = 'theHarvester ' + """theHarvester is a tool designed to be used during the reconnaissance stage.""" + cmd = 'theHarvester' file_flag = None input_flag = '--domain' json_flag = '--filename' opt_prefix = '--' - + opts = { 'source': {'type': str, 'short': 'b', 'help': 'bevigil, censys, fullhunt, securityTrails'}, - } - + } + opt_key_map = { PROXY: 'proxies', LIMIT: 'limit', @@ -31,7 +35,7 @@ class theHarvester(ReconUser): RETRIES: OPT_NOT_SUPPORTED, TIMEOUT: OPT_NOT_SUPPORTED } - + @staticmethod def on_start(self): output_path = self.get_opt_value('output_path') @@ -41,8 +45,8 @@ def on_start(self): self.output_path = output_path self.cmd = self.cmd.replace('--filename', f'--filename {self.output_path}') -def yielder(self): - prev = self.print_item_count + def yielder(self): + #prev = self.print_item_count self.print_item_count = False list(super().yielder()) if self.return_code != 0: @@ -54,25 +58,33 @@ def yielder(self): if self.print_orig: # original h8mail output yield data return - targets = data['hosts'] - for target in targets: - email = target['target'] - target_data = target['data'] - if not len(target_data) > 0: + hosts = data.get('hosts', []) + #asns = data.get('asns', []) + interesting_urls = data.get('interesting_urls', []) + ips = data.get('ips', []) + emails = data.get('emails', []) + target = self.targets[0] + + for ip in ips: + yield Ip(ip=ip, host=target) + for host in hosts: + parts = host.split(':') + if len(parts) == 1: continue - entries = target_data[0] - for entry in entries: - source, site_name = tuple(entry.split(':')) - yield UserAccount(**{ - "site_name": site_name, - "username": email.split('@')[0], - "email": email, - "extra_data": { - 'source': source - }, - }) + if len(parts) > 2: + host = parts[0] + ip = ':'.join(parts[1:-1]) + else: + host, ip = tuple(parts) + if validators.ip_address.ipv4(ip) or validators.ip_address.ipv6(ip): + yield Ip(ip=ip, host=host) + yield Subdomain(host=host, domain=target) + for interesting_url in interesting_urls: + yield Url(url=interesting_url) + for email in emails: + yield UserAccount(email=emails) - install_cmd = ('git clone https://github.com/laramies/theHarvester || True &&' +install_cmd = ('git clone https://github.com/laramies/theHarvester || True &&' 'cd theHarvester || python3 -m pip install -r requirements/base.txt') - socks5_proxy = True \ No newline at end of file +socks5_proxy = True