diff --git a/file_utils.py b/file_utils.py index 4aea8a3..88b789f 100644 --- a/file_utils.py +++ b/file_utils.py @@ -31,6 +31,7 @@ from bs4 import BeautifulSoup from pdf2image import convert_from_path from PIL import Image +import webhook, octopii def truncate(local_location): characters_per_file = 1232500 @@ -142,6 +143,8 @@ def append_to_output_file(data, file_name): with open(file_name, 'w') as write_file: loaded_json.append(data) + if octopii.notifyURL is not None: + webhook.push_data(json.dumps(loaded_json, indent=4), octopii.notifyURL) write_file.write(json.dumps(loaded_json, indent=4)) except: diff --git a/octopii.py b/octopii.py index af60499..d3be026 100644 --- a/octopii.py +++ b/octopii.py @@ -25,6 +25,7 @@ """ output_file = "output.json" +notifyURL = "" import json, textract, sys, urllib, cv2, os, json, shutil, traceback os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' @@ -116,9 +117,16 @@ def search_pii(file_path): print_logo() help_screen() exit(-1) - else: - location = sys.argv[1] + location = sys.argv[1] + + # Check for the -notify flag + notify_index = sys.argv.index('-notify') if '-notify' in sys.argv else -1 + + if notify_index != -1 and notify_index + 1 < len(sys.argv): + notifyURL = sys.argv[notify_index + 1] + else: + notifyURL = None rules=text_utils.get_regexes() diff --git a/webhook.py b/webhook.py index d60f87e..7b612d7 100644 --- a/webhook.py +++ b/webhook.py @@ -28,7 +28,10 @@ def push_data(data: str, url: str): headers = {'Content-type': 'application/json'} - data = f"{"text":'{data}'}" + if "discord" in url: + data = f"{'content':'{data}'}" + else: + data = f"{'text':'{data}'}" req = requests.post ( url, # Example: https://hooks.slack.com/services/<>/<>/<>