Runs zgrab and stores the result if necessary
(
logger, ips, port, run_command, zones_struct, zgrab_collection, tnum
)
| 319 | |
| 320 | |
| 321 | def process_thread( |
| 322 | logger, ips, port, run_command, zones_struct, zgrab_collection, tnum |
| 323 | ): |
| 324 | """ |
| 325 | Runs zgrab and stores the result if necessary |
| 326 | """ |
| 327 | json_output = run_command(ips, tnum) |
| 328 | if ("success_count" in json_output and json_output["success_count"] > 0) or ( |
| 329 | "statuses" in json_output and json_output["statuses"]["http"]["successes"] > 0 |
| 330 | ): |
| 331 | result_file = open( |
| 332 | "./json_p" + port + "/p" + port + "-" + str(tnum) + ".json", "r" |
| 333 | ) |
| 334 | results = [] |
| 335 | for result in result_file: |
| 336 | results.append(json.loads(result)) |
| 337 | result_file.close() |
| 338 | for result in results: |
| 339 | if ( |
| 340 | "zgrab2" in global_zgrab_path and "error" in result["data"]["http"] |
| 341 | ) or "error" in result: |
| 342 | logger.warning("Failed " + port + ": " + str(result["ip"])) |
| 343 | else: |
| 344 | result["aws"] = zones_struct["ip_manager"].is_aws_ip(result["ip"]) |
| 345 | result["azure"] = zones_struct["ip_manager"].is_azure_ip(result["ip"]) |
| 346 | result["gcp"] = zones_struct["ip_manager"].is_gcp_ip(result["ip"]) |
| 347 | result["tracked"] = zones_struct["ip_manager"].is_tracked_ip( |
| 348 | result["ip"] |
| 349 | ) |
| 350 | insert_result( |
| 351 | result, |
| 352 | port, |
| 353 | zones_struct["ip_context"], |
| 354 | zones_struct["zones"], |
| 355 | zgrab_collection, |
| 356 | ) |
| 357 | logger.debug("Inserted " + port + ": " + result["ip"]) |
| 358 | else: |
| 359 | logger.warning("Failed " + port + ": " + str(ips)) |
| 360 | |
| 361 | |
| 362 | def process_data(logger, tnum, q, port, command, zones_struct, zgrab_collection): |
no test coverage detected