Report is now in .json format
This commit is contained in:
parent
1f0d8c3032
commit
c509637865
4 changed files with 34 additions and 27 deletions
|
@ -4,19 +4,20 @@ import datetime
|
|||
import urllib.request
|
||||
|
||||
def main_loop():
|
||||
json_object = []
|
||||
for i in range(times):
|
||||
url = url_generator(domains, log)
|
||||
try:
|
||||
response = urllib.request.urlopen(url)
|
||||
print(url + " exists!")
|
||||
f.write("\n" + url + " | STATUS_CODE: " + str(response.getcode()))
|
||||
json_object.append('{"website_url":"' + url + '","response_type":"SUCCESS","response_code":"' + str(response.getcode()) + '","response_details":"Server seems to be ' + str(response.info()["Server"]) + '"}')
|
||||
except Exception as e:
|
||||
if "[Errno 11001]" in str(e): continue
|
||||
if "[" in str(e) and "]" in str(e): e = str(e)[str(e).index("[") + 1:str(e).index("]")] + ": " + str(e)[str(e).index("]") + 2:][:-1]
|
||||
print(url + " exists!")
|
||||
f.write("\n" + url + " | ERROR_CODE: " + str(e))
|
||||
err_code = str(e)[str(e).index("[") + 1:str(e).index("]")] if "[" in str(e) and "]" in str(e) else "NONE FOUND"
|
||||
json_object.append('{"website_url":"' + url + '","response_type":"ERROR","response_code":"' + err_code + '","response_details":"' + str(e).replace("\\", "") + '"}')
|
||||
|
||||
f.write("\n---\n")
|
||||
f.write(str(json_object).replace("'", ""))
|
||||
f.close()
|
||||
print("Finished at " + str(datetime.datetime.now().time())[0:5].replace(":", "h") + "m")
|
||||
|
||||
|
@ -35,7 +36,7 @@ try:
|
|||
except:
|
||||
print("-t argument expected a number!")
|
||||
sys.exit()
|
||||
domains = sys.argv[sys.argv.index('-d') + 1] if '-d' in sys.argv else ['.com', '.net', '.edu', '.gov', '.cn', '.org']
|
||||
domains = sys.argv[sys.argv.index('-d') + 1] if '-d' in sys.argv else ['.co', '.com', '.net', '.edu', '.gov', '.cn', '.org', '.cc']
|
||||
mode = sys.argv[sys.argv.index('-m') + 1].split(",") if '-m' in sys.argv else ['http']
|
||||
log = '-l' in sys.argv
|
||||
|
||||
|
@ -43,6 +44,5 @@ print("\nI am going to look for images through " + str(times) + " random URLs wi
|
|||
print("These URLs use the following protocols: " + str(mode))
|
||||
print("Started at " + str(datetime.datetime.now().time())[0:5].replace(":", "h") + "m")
|
||||
|
||||
f = open("PY_report.txt", "a+")
|
||||
f.write("---")
|
||||
f = open("PY_report_" + str(datetime.datetime.now().strftime("%d%H%M")) + ".json", "a+")
|
||||
main_loop()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue