Added check to verify existence of output directory and pep8 fixes.

This commit is contained in:
NotoriousRebel 2020-07-04 22:04:15 -04:00
parent 4b04c70beb
commit 5ee07edb3f
3 changed files with 47 additions and 27 deletions

View file

@ -593,6 +593,9 @@ async def handler(lst):
from aiomultiprocess import Pool
from theHarvester.screenshot.screenshot import ScreenShotter
screen_shotter = ScreenShotter(args.screenshot)
path_exists = screen_shotter.verify_path()
# Verify path exists if not create it or if user does not create it skip screenshot
if path_exists:
await screen_shotter.verify_installation()
print(f'Screenshots can be found: {screen_shotter.output}{screen_shotter.slash}')
start = time.perf_counter()
@ -615,7 +618,12 @@ async def handler(lst):
except Exception as ee:
print(f'An exception has occurred while mapping: {ee}')
end = time.perf_counter()
print(f"Finished taking screenshots in {end - start} seconds")
# There is probably an easier way to do this
total = end - start
mon, sec = divmod(total, 60)
hr, mon = divmod(mon, 60)
total_time = "%02d:%02d" % (mon, sec)
print(f"Finished taking screenshots in {total_time} seconds")
print('[+] Note there may be leftover chrome processes you may have to kill manually\n')
# Shodan

View file

@ -303,7 +303,6 @@ async def generatescreenshots(tups: List):
<p>&nbsp;</p>
<p>&nbsp;</p>
'''
base = 'var tabledata = [ '
for tup in tups:
date = tup[0]

View file

@ -7,7 +7,7 @@
import aiohttp
import asyncio
from datetime import datetime
import json
import os
import sys
@ -18,6 +18,19 @@ def __init__(self, output):
self.slash = "\\" if 'win' in sys.platform else '/'
self.slash = "" if (self.output[-1] == "\\" or self.output[-1] == "/") else self.slash
def verify_path(self):
try:
if not os.path.isdir(self.output):
answer = input(f'[+] The output path you have entered does not exist would you like to create it (y/n): ')
if answer.lower() == 'yes' or answer.lower() == 'y':
os.mkdir(self.output)
return True
print('path is a directory')
return True
except Exception as e:
print(f"An exception has occurred while attempting to verify output path's existence: {e}")
return False
@staticmethod
async def verify_installation():
# Helper function that verifies pyppeteer & chromium are installed