Skip to content

Commit

Permalink
made changes to webhook method
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4f53 committed Nov 14, 2023
1 parent c56722f commit 0fae319
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
7 changes: 3 additions & 4 deletions file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
SOFTWARE.
"""

import requests, xmltodict, json, requests, cv2, urllib, http, traceback, os, textract
import requests, xmltodict, json, requests, cv2, urllib, http, traceback, os, textract, webhook, octopii
from skimage import io
import numpy as np
from urllib.request import Request, urlopen, re
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
Expand Down Expand Up @@ -143,9 +142,9 @@ 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)
if len(octopii.notifyURL) > 0: webhook.push_data(json.dumps(loaded_json, indent=4), octopii.notifyURL)
write_file.write(json.dumps(loaded_json, indent=4))

except:
traceback.print_exc()
print ("Couldn't write to "+ file_name +". Please check if the path is correct and try again.")
8 changes: 3 additions & 5 deletions octopii.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def search_pii(file_path):
location = sys.argv[1]

# Check for the -notify flag
notify_index = sys.argv.index('-notify') if '-notify' in sys.argv else -1
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]
Expand Down Expand Up @@ -208,11 +208,9 @@ def search_pii(file_path):
file_utils.append_to_output_file(results, output_file)
print ("\nOutput saved in " + output_file)

except textract.exceptions.MissingFileError:
print ("\nCouldn't find file '" + file_path + "', skipping...")
except textract.exceptions.MissingFileError: print ("\nCouldn't find file '" + file_path + "', skipping...")

except textract.exceptions.ShellError:
print ("\nFile '" + file_path + "' is empty or corrupt, skipping...")
except textract.exceptions.ShellError: print ("\nFile '" + file_path + "' is empty or corrupt, skipping...")

if temp_exists: shutil.rmtree(temp_dir)

Expand Down
6 changes: 2 additions & 4 deletions webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@

def push_data(data: str, url: str):
headers = {'Content-type': 'application/json'}
if "discord" in url:
data = f"{'content':'{data}'}"
else:
data = f"{'text':'{data}'}"
if "discord" in url: data = "{\"content\":\"{" + data + "}\"}"
else: data = "{\"text\":\"{" + data + "}\"}"

req = requests.post (
url, # Example: https://hooks.slack.com/services/<>/<>/<>
Expand Down

0 comments on commit 0fae319

Please sign in to comment.