From 59686d3dd5827337345da0aa5f4719fa19cb2be1 Mon Sep 17 00:00:00 2001 From: L1ghtn1ng Date: Mon, 31 May 2021 23:35:48 +0100 Subject: [PATCH] add orjson and *.json to gitignore --- .gitignore | 1 + theHarvester/__main__.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 1541daec..c9b4ed35 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.htm *.vscode *.xml +*.json debug_results.txt venv .mypy_cache diff --git a/theHarvester/__main__.py b/theHarvester/__main__.py index df093efc..7632df26 100644 --- a/theHarvester/__main__.py +++ b/theHarvester/__main__.py @@ -9,7 +9,7 @@ from theHarvester.lib.core import * import argparse import asyncio -import json +import orjson import netaddr import re import sys @@ -828,8 +828,8 @@ async def handler(lst): shodanalysis = sorted(set(shodanalysis)) shodan_dict["servers"] = [server for server in shodanalysis] json_dict["shodan"] = shodan_dict - with open(filename, 'w+') as json_file: - json.dump(json_dict, json_file, indent=4) + with open(filename, 'wb+') as fp: + fp.write(orjson.dumps(json_dict, option=orjson.OPT_SORT_KEYS)) print('[*] JSON File saved.') except Exception as error: print(f'\033[93m[!] An error occurred while saving the JSON file: {error} \033[0m')