Open smithdavida opened 2 months ago
Hey @smithdavida, thanks for the suggestion! Fofa looks like a pretty cool service.
Are you interested in writing the module? We are always looking for help in that department. It should be pretty easy, take a look at our shodan module and let me know what you think. Fofa should be pretty similar!
I'm glad you accepted my suggestion!I completed the code to be able to run locally: `import requests import base64 from urllib.parse import urlparse
watched_events = ["DNS_NAME"] produced_events = ["DNS_NAME"] flags = ["affiliates", "subdomain-enum", "passive", "safe"] meta = {"description": "Query Fofa's API for subdomains", "auth_required": True} baseurl = "https://fofa.info/api/v1/search/all"
def query(domain): key = "xxxxxxxxxxxxx" query_str = f"domain={domain}" encoded_query_str = base64.b64encode(query_str.encode()).decode() qbase64 = f"{encoded_query_str}" params = { "size": 10000, "key": key, "qbase64": qbase64 } response = requests.get(url, params=params) return response.json()
def extract_domains(fofa_results): domains = set() for result in fofa_results["results"]: domain = urlparse(result[0]).netloc domains.add(domain) return list(domains)
fofa_results = query("example.com") domains = extract_domains(fofa_results) print(domains)`
The output is similar to this: [ 'example.com', 'www.example.com', 'mail.example.com']
Would you be so kind as to put that in a pull request? 😁🙏
# ...fork bbot
# clone your fork
git clone git@github.com:smithdavida/bbot && cd bbot
# create new branch
git switch -c fofa-module
# add your module
git add bbot/modules/fofa.py
# commit and push changes
git commit -m "added fofa module"
git push
This is a masterpiece! I hope fofa api can be added in the future