From c1e9e0c9c10391c1ab8b0229d2699a99e639f90b Mon Sep 17 00:00:00 2001 From: NotoriousRebel Date: Thu, 13 Feb 2020 17:19:51 -0500 Subject: [PATCH 1/3] removed unncessary tests. --- tests/discovery/githubcode.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/tests/discovery/githubcode.py b/tests/discovery/githubcode.py index da88196c..df8b6d28 100644 --- a/tests/discovery/githubcode.py +++ b/tests/discovery/githubcode.py @@ -84,24 +84,6 @@ async def test_invalid_fragments_from_response(self): test_result = await test_class_instance.fragments_from_response(self.MalformedResponse.response.json()) assert test_result == [] - async def test_handle_response_ok(self): - Core.github_key = MagicMock(return_value="lol") - test_class_instance = githubcode.SearchGithubCode(word="test", limit=500) - test_result = await test_class_instance.handle_response() - assert isinstance(test_result, SuccessResult) - - async def test_handle_response_retry(self): - Core.github_key = MagicMock(return_value="lol") - test_class_instance = githubcode.SearchGithubCode(word="test", limit=500) - test_result = await test_class_instance.handle_response(self.RetryResponse.response.json()) - assert isinstance(test_result, RetryResult) - - async def test_handle_response_fail(self): - Core.github_key = MagicMock(return_value="lol") - test_class_instance = githubcode.SearchGithubCode(word="test", limit=500) - test_result = await test_class_instance.handle_response(self.FailureResponse.response.json()) - assert isinstance(test_result, ErrorResult) - async def test_next_page(self): Core.github_key = MagicMock(return_value="lol") test_class_instance = githubcode.SearchGithubCode(word="test", limit=500) From 7f8aea33ad2bff59f7cd6a6b29516511ffaf50f4 Mon Sep 17 00:00:00 2001 From: NotoriousRebel Date: Thu, 13 Feb 2020 17:32:17 -0500 Subject: [PATCH 2/3] flake8 fixes. --- tests/discovery/githubcode.py | 1 - theHarvester/discovery/bufferoverun.py | 6 ++++-- theHarvester/discovery/certspottersearch.py | 10 ++++++++++ theHarvester/discovery/crtsh.py | 1 + 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/discovery/githubcode.py b/tests/discovery/githubcode.py index df8b6d28..248e3038 100644 --- a/tests/discovery/githubcode.py +++ b/tests/discovery/githubcode.py @@ -1,5 +1,4 @@ from theHarvester.discovery import githubcode -from theHarvester.discovery.githubcode import RetryResult, ErrorResult, SuccessResult from theHarvester.discovery.constants import MissingKey from theHarvester.lib.core import Core from unittest.mock import MagicMock diff --git a/theHarvester/discovery/bufferoverun.py b/theHarvester/discovery/bufferoverun.py index d2e07d6d..90068b95 100644 --- a/theHarvester/discovery/bufferoverun.py +++ b/theHarvester/discovery/bufferoverun.py @@ -16,11 +16,13 @@ async def do_search(self): dct = responses self.totalhosts: set = { - host.split(',')[0].replace('www','') if ',' in host and self.word.replace('www.', '') in host.split(',')[0] in host else + host.split(',')[0].replace('www', '') if ',' in host and self.word.replace('www.', '') in host.split(',')[ + 0] in host else host.split(',')[1] for host in dct['FDNS_A']} - self.totalips: set = {ip.split(',')[0]for ip in dct['FDNS_A'] if + self.totalips: set = {ip.split(',')[0] for ip in dct['FDNS_A'] if re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", ip.split(',')[0])} + async def get_hostnames(self) -> set: return self.totalhosts diff --git a/theHarvester/discovery/certspottersearch.py b/theHarvester/discovery/certspottersearch.py index 70cc9385..1aa49a5a 100644 --- a/theHarvester/discovery/certspottersearch.py +++ b/theHarvester/discovery/certspottersearch.py @@ -35,3 +35,13 @@ async def process(self, proxy=False): self.proxy = proxy await self.do_search() print('\tSearching results.') + +async def main(): + x = SearchCertspoter(word='arrow.com') + await x.do_search() + hosts = await x.get_hostnames() + print(hosts) + +if __name__ == '__main__': + import asyncio + asyncio.run(main()) \ No newline at end of file diff --git a/theHarvester/discovery/crtsh.py b/theHarvester/discovery/crtsh.py index 71700276..671e9f94 100644 --- a/theHarvester/discovery/crtsh.py +++ b/theHarvester/discovery/crtsh.py @@ -1,5 +1,6 @@ from theHarvester.lib.core import * import aiohttp +from typing import Set class SearchCrtsh: From eba479a6106164977316c6c566dd4b0bbf90c40f Mon Sep 17 00:00:00 2001 From: NotoriousRebel Date: Thu, 13 Feb 2020 17:51:20 -0500 Subject: [PATCH 3/3] small misc. changes. --- theHarvester/discovery/bufferoverun.py | 2 +- theHarvester/discovery/certspottersearch.py | 10 ---------- theHarvester/discovery/crtsh.py | 3 ++- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/theHarvester/discovery/bufferoverun.py b/theHarvester/discovery/bufferoverun.py index 90068b95..c72c4b36 100644 --- a/theHarvester/discovery/bufferoverun.py +++ b/theHarvester/discovery/bufferoverun.py @@ -16,7 +16,7 @@ async def do_search(self): dct = responses self.totalhosts: set = { - host.split(',')[0].replace('www', '') if ',' in host and self.word.replace('www.', '') in host.split(',')[ + host.split(',')[0].replace('www.', '') if ',' in host and self.word.replace('www.', '') in host.split(',')[ 0] in host else host.split(',')[1] for host in dct['FDNS_A']} diff --git a/theHarvester/discovery/certspottersearch.py b/theHarvester/discovery/certspottersearch.py index 1aa49a5a..70cc9385 100644 --- a/theHarvester/discovery/certspottersearch.py +++ b/theHarvester/discovery/certspottersearch.py @@ -35,13 +35,3 @@ async def process(self, proxy=False): self.proxy = proxy await self.do_search() print('\tSearching results.') - -async def main(): - x = SearchCertspoter(word='arrow.com') - await x.do_search() - hosts = await x.get_hostnames() - print(hosts) - -if __name__ == '__main__': - import asyncio - asyncio.run(main()) \ No newline at end of file diff --git a/theHarvester/discovery/crtsh.py b/theHarvester/discovery/crtsh.py index 671e9f94..9a828c2f 100644 --- a/theHarvester/discovery/crtsh.py +++ b/theHarvester/discovery/crtsh.py @@ -19,7 +19,8 @@ async def do_search(self) -> Set: response = await AsyncFetcher.fetch(client, url, json=True, proxy=self.proxy) await client.close() data = set( - [dct['name_value'][2:] if '*.' == dct['name_value'][:2] else dct['name_value'] for dct in response]) + [dict(dct)['name_value'][2:] if '*.' == dict(dct)['name_value'][:2] else dict(dct)['name_value'] + for dct in response]) except Exception as e: print(e) return data