Skip to content

Commit

Permalink
remove dnsdumpster as it does not work and hackertarget is the parent…
Browse files Browse the repository at this point in the history
… company and gives more results anyway
L1ghtn1ng committed Jan 26, 2025
1 parent bd62dd9 commit d945356
Showing 5 changed files with 46 additions and 104 deletions.
59 changes: 44 additions & 15 deletions discovery/dnsdumpster.py
Original file line number Diff line number Diff line change
@@ -3,31 +3,60 @@


class SearchDnsDumpster:
def __init__(self, word) -> None:
self.word = word
self.key = Core.dnsdumpster_key()
if self.key is None:
def __init__(self, word: str) -> None:
"""
Initialize the SearchDnsDumpster class with the target domain and initialize the necessary attributes.
"""
self.word: str = word
self.key: str | None = Core.dnsdumpster_key()
if not self.key:
raise MissingKey('dnsdumpster')
self.total_results = None
self.proxy = False
self.total_results: list[dict] = []
self.proxy: bool = False

async def do_search(self) -> None:
url = f'https://api.dnsdumpster.com/domain/{self.word}'
headers = {'User-Agent': Core.get_user_agent(), 'X-API-Key': self.key}
"""
Perform an asynchronous search for DNS information using the DNSDumpster API.
"""
url = f'https://api.dnsdumpster.com/domain/{self.word}' # Construct the API endpoint
headers = {"X-API-Key": self.key} # Define the necessary headers

try:
# Use AsyncFetcher to fetch data from the API
responses = await AsyncFetcher.fetch_all([url], headers=headers, proxy=self.proxy)

# Check if responses contain any data
if not responses or len(responses) == 0:
print('Error: No responses received from the DNSDumpster API')
return

# Extract the first response (note: fetch_all always returns a list)
response = responses[0]
if response.status == 200:
json_response = await response.json()
self.total_results = json_response.get('a', [])

# Validate the response and extract data
if isinstance(response, dict) and response.get('status') == 200:
self.total_results = response.get('a', []) # Access the 'a' (hostnames) part of the response
else:
print(f'Error: Received status code {response.status}')
print(
f"Error: Received invalid response or status code: {response.get('status') if isinstance(response, dict) else 'Unknown'}")

except Exception as e:
print(f'An exception occurred in DNSdumpster: {e}')
print(f'An exception occurred in DNSDumpster: {e}')

async def get_hostnames(self) -> list[str]:
"""
Extract hostnames from the search results.
"""
if not self.total_results:
return []

async def get_hostnames(self):
return [entry['host'] for entry in self.total_results]
# Extract hostnames from DNS results
return [entry.get('host', '') for entry in self.total_results if 'host' in entry]

async def process(self, proxy: bool = False) -> None:
"""
Start the search process.
:param proxy: Enable or disable proxy usage.
"""
self.proxy = proxy
await self.do_search()
17 changes: 1 addition & 16 deletions theHarvester/__main__.py
Original file line number Diff line number Diff line change
@@ -25,7 +25,6 @@
certspottersearch,
criminalip,
crtsh,
dnsdumpster,
dnssearch,
duckduckgosearch,
fullhuntsearch,
@@ -149,7 +148,7 @@ async def start(rest_args: argparse.Namespace | None = None):
'-b',
'--source',
help="""anubis, baidu, bevigil, binaryedge, bing, bingapi, bufferoverun, brave,
censys, certspotter, criminalip, crtsh, dnsdumpster, duckduckgo, fullhunt, github-code,
censys, certspotter, criminalip, crtsh, duckduckgo, fullhunt, github-code,
hackertarget, hunter, hunterhow, intelx, netlas, onyphe, otx, pentesttools, projectdiscovery,
rapiddns, rocketreach, securityTrails, sitedossier, subdomaincenter, subdomainfinderc99, threatminer, tomba,
urlscan, virustotal, yahoo, zoomeye""",
@@ -509,20 +508,6 @@ async def store(
except Exception as e:
print(f'[!] A timeout occurred with crtsh, cannot find {args.domain}\n {e}')

elif engineitem == 'dnsdumpster':
try:
dns_dumpster_search = dnsdumpster.SearchDnsDumpster(word)
stor_lst.append(
store(
dns_dumpster_search,
engineitem,
store_host=True,
store_ip=True,
)
)
except Exception as e:
print(f'[!] An error occurred with dnsdumpster: {e}')

elif engineitem == 'duckduckgo':
duckduckgo_search = duckduckgosearch.SearchDuckDuckGo(word, limit)
stor_lst.append(
3 changes: 0 additions & 3 deletions theHarvester/data/api-keys.yaml
Original file line number Diff line number Diff line change
@@ -11,9 +11,6 @@ apikeys:
bufferoverun:
key:

dnsdumpster:
key:

censys:
id:
secret:
62 changes: 0 additions & 62 deletions theHarvester/discovery/dnsdumpster.py

This file was deleted.

9 changes: 1 addition & 8 deletions theHarvester/lib/core.py
Original file line number Diff line number Diff line change
@@ -35,7 +35,6 @@ def _read_config(filename: str) -> str:
with contextlib.suppress(FileNotFoundError):
file = path.expanduser() / filename
config = file.read_text()
print(f'Read {filename} from {file}')
return config

# Fallback to creating default in user's home dir
@@ -67,10 +66,6 @@ def bing_key() -> str:
def bufferoverun_key() -> str:
return Core.api_keys()['bufferoverun']['key']

@staticmethod
def dnsdumpster_key() -> str:
return Core.api_keys()['dnsdumpster']['key']

@staticmethod
def censys_key() -> tuple:
return Core.api_keys()['censys']['id'], Core.api_keys()['censys']['secret']
@@ -176,7 +171,6 @@ def get_supportedengines() -> list[str | Any]:
'certspotter',
'criminalip',
'crtsh',
'dnsdumpster',
'duckduckgo',
'fullhunt',
'github-code',
@@ -321,9 +315,8 @@ async def post_fetch(
@classmethod
async def fetch(cls, session, url, params: Sized = '', json: bool = False, proxy: str = '') -> str | dict | list | bool:
# This fetch method solely focuses on get requests
# Wrap in try except due to 0x89 png/jpg files
try:
# Wrap in try except due to 0x89 png/jpg files
# This fetch method solely focuses on get requests
if proxy != '':
proxy = str(random.choice(cls().proxy_list))
if len(params) != 0:

0 comments on commit d945356

Please sign in to comment.