Download the latest OWASP Amass information.
(
logger, amass_collection, remote_amass_collection, dns_manager, zones
)
| 173 | |
| 174 | |
| 175 | def download_amass_data( |
| 176 | logger, amass_collection, remote_amass_collection, dns_manager, zones |
| 177 | ): |
| 178 | """ |
| 179 | Download the latest OWASP Amass information. |
| 180 | """ |
| 181 | logger.info("Beginning Amass download") |
| 182 | now = datetime.now() |
| 183 | mirror_date = datetime.now() - timedelta(days=7, hours=9) |
| 184 | amass_results = remote_amass_collection.find( |
| 185 | {"timestamp": {"$gt": mirror_date}}, {"_id": 0} |
| 186 | ).batch_size(50) |
| 187 | |
| 188 | google_dns = GoogleDNS.GoogleDNS() |
| 189 | |
| 190 | for result in amass_results: |
| 191 | zone = check_zones(result["name"], zones) |
| 192 | if zone is not None: |
| 193 | time.sleep(1) |
| 194 | if record_finding(logger, dns_manager, google_dns, zone, result): |
| 195 | amass_collection.replace_one( |
| 196 | {"name": result["name"]}, result, upsert=True |
| 197 | ) |
| 198 | |
| 199 | # Establish a date four months back |
| 200 | scrub_date = datetime.now() - timedelta(days=120, hours=9) |
| 201 | |
| 202 | # Remove data from scrub_date |
| 203 | amass_collection.delete_many({"timestamp": {"$lte": scrub_date}}) |
| 204 | remote_amass_collection.delete_many({"timestamp": {"$lte": now}}) |
| 205 | |
| 206 | |
| 207 | def download_jobs_status(logger, jobs_collection, remote_jobs_collection): |
no test coverage detected