mirror of
https://github.com/laramies/theHarvester.git
synced 2025-02-25 06:53:05 +08:00
Update censys module to support version 2 of the sdk, fix by @thehappydinoa and to get emails.
This commit is contained in:
parent
c0e2b38a51
commit
b2376857b8
2 changed files with 22 additions and 9 deletions
|
@ -192,10 +192,10 @@ async def store(search_engine: Any, source: str, process_param: Any = None, stor
|
|||
print(e)
|
||||
|
||||
elif engineitem == 'censys':
|
||||
from theHarvester.discovery import censys
|
||||
from theHarvester.discovery import censysearch
|
||||
try:
|
||||
censys_search = censys.SearchCensys(word)
|
||||
stor_lst.append(store(censys_search, engineitem, store_host=True))
|
||||
censys_search = censysearch.SearchCensys(word)
|
||||
stor_lst.append(store(censys_search, engineitem, store_host=True, store_emails=True))
|
||||
except Exception as e:
|
||||
if isinstance(e, MissingKey):
|
||||
print(e)
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from theHarvester.discovery.constants import MissingKey
|
||||
from theHarvester.lib.core import Core
|
||||
from censys.certificates import CensysCertificates
|
||||
from censys.exceptions import (
|
||||
from censys.search import CensysCertificates
|
||||
from censys.common import __version__
|
||||
from censys.common.exceptions import (
|
||||
CensysRateLimitExceededException,
|
||||
CensysUnauthorizedException,
|
||||
)
|
||||
|
@ -14,25 +15,37 @@ def __init__(self, domain):
|
|||
if self.key[0] is None or self.key[1] is None:
|
||||
raise MissingKey("Censys ID and/or Secret")
|
||||
self.totalhosts = set()
|
||||
self.emails = set()
|
||||
self.proxy = False
|
||||
|
||||
async def do_search(self):
|
||||
try:
|
||||
censys = CensysCertificates(api_id=self.key[0], api_secret=self.key[1])
|
||||
cert_search = CensysCertificates(
|
||||
api_id=self.key[0],
|
||||
api_secret=self.key[1],
|
||||
user_agent=f"censys/{__version__} (theHarvester/{Core.version()}; +https://github.com/laramies/theHarvester)",
|
||||
)
|
||||
except CensysUnauthorizedException:
|
||||
raise MissingKey("Censys ID and/or Secret")
|
||||
raise MissingKey('Censys ID and/or Secret')
|
||||
|
||||
query = f"parsed.names: {self.word}"
|
||||
try:
|
||||
response = censys.search(query=query, fields=["parsed.names", "metadata"])
|
||||
response = cert_search.search(
|
||||
query=query,
|
||||
fields=["parsed.names", "metadata", "parsed.subject.email_address"],
|
||||
)
|
||||
for cert in response:
|
||||
self.totalhosts.update(cert["parsed.names"])
|
||||
self.totalhosts.update(cert.get("parsed.names", []))
|
||||
self.emails.update(cert.get("parsed.subject.email_address", []))
|
||||
except CensysRateLimitExceededException:
|
||||
print("Censys rate limit exceeded")
|
||||
|
||||
async def get_hostnames(self) -> set:
|
||||
return self.totalhosts
|
||||
|
||||
async def get_emails(self) -> set:
|
||||
return self.emails
|
||||
|
||||
async def process(self, proxy=False):
|
||||
self.proxy = proxy
|
||||
await self.do_search()
|
Loading…
Reference in a new issue