diff --git a/README.md b/README.md index 633f031..d030f16 100755 --- a/README.md +++ b/README.md @@ -23,7 +23,6 @@ This script also requires you to install the following PIP packages: ``` pip3 install python-whois pip3 install requests -pip3 install pyAesCrypt pip3 install matrix-nio ``` diff --git a/moderation_tool.py b/moderation_tool.py index 6554a32..9f3f643 100755 --- a/moderation_tool.py +++ b/moderation_tool.py @@ -58,11 +58,11 @@ while pass_token == False: print("20) Shadow ban a user.\t\t\t\t69) Unblock a room.") print("\n#### Server Commands ####\t\t\t\t\t#### Report Generation ####") print("100) Delete and block a specific media.\t\t\t\t150) Generate user report.") - print("101) Purge remote media repository up to a certain date.\t151) Decrypt user report .zip file.") - print("102) Prepare database for copying events of multiple rooms.\t152) Lookup homeserver admin contact details.") - print("\t\t\t\t\t\t\t\t153) Send a test email (to yourself).") - print("#### rdlist ####\t\t\t\t\t\t154) Sent a test Matrix message (to yourself).") - print("120) Block all rooms with specific rdlist tags.\t\t\t155) Send test incident reports (to yourself).") + print("101) Purge remote media repository up to a certain date.\t151) Lookup homeserver admin contact details.") + print("102) Prepare database for copying events of multiple rooms.\t152) Send a test email (to yourself).") + print("\t\t\t\t\t\t\t\t153) Sent a test Matrix message (to yourself).") + print("#### rdlist ####\t\t\t\t\t\t154) Send test incident reports (to yourself).") + print("120) Block all rooms with specific rdlist tags.") print("121) Block all rooms with recommended rdlist tags.") print("122) Get rdlist tags for a room.") print("\n#### ipinfo.io ####") @@ -193,15 +193,13 @@ while pass_token == False: elif menu_input == "150": report_commands.generate_user_report('','') elif menu_input == "151": - report_commands.decrypt_zip_file() - elif menu_input == "152": admin_contact_dict, is_whois = report_commands.lookup_homeserver_admin('') print(f"\nAdmin contacts: {json.dumps(admin_contact_dict, indent=4, sort_keys=True)}\nWhois: {str(is_whois)}") - elif menu_input == "153": + elif menu_input == "152": report_commands.test_send_email() - elif menu_input == "154": + elif menu_input == "153": bot_commands.test_matrix_message() - elif menu_input == "155": + elif menu_input == "154": report_commands.test_send_incident_reports() elif menu_input == "q" or menu_input == "Q" or menu_input == "e" or menu_input == "E": print("\nExiting...\n") diff --git a/rdlist_commands.py b/rdlist_commands.py index ce0a6f7..38d204e 100644 --- a/rdlist_commands.py +++ b/rdlist_commands.py @@ -2,8 +2,6 @@ import os import subprocess import json -import random -import string import time import user_commands import room_commands @@ -133,9 +131,9 @@ def block_all_rooms_with_rdlist_tags(rdlist_use_recommended,preset_user_ID,prese all_room_ids = list(all_room_ids) # convert the set to a list - print(f"all_local_users: {all_local_users}") - print(f"all_remote_users: {all_remote_users}") - print(f"all_room_ids: {all_room_ids}") + #print(f"all_local_users: {all_local_users}") + #print(f"all_remote_users: {all_remote_users}") + #print(f"all_room_ids: {all_room_ids}") # If there's at least 1 local user detected, ask the admin if they want to generate a user report for every user found in rdlist rooms if len(all_local_users) > 0: @@ -143,7 +141,6 @@ def block_all_rooms_with_rdlist_tags(rdlist_use_recommended,preset_user_ID,prese generate_user_report_confirmation = input("\nDo you want to generate a user report file for each of these users? y/n? ") if generate_user_report_confirmation.lower() in ['y', 'yes', 'Y', 'Yes']: for user_id in all_local_users: - print(f"\nGenerating user report for user: {user_id}") # Generate report_dict for each user report_content = report_commands.generate_rdlist_report_summary(all_local_users[user_id], user_id) report_commands.generate_user_report(user_id, report_content) diff --git a/report_commands.py b/report_commands.py index 0e93dc7..963166c 100644 --- a/report_commands.py +++ b/report_commands.py @@ -2,11 +2,8 @@ import os import json import whois -import random -import string import datetime import zipfile -import pyAesCrypt import smtplib import requests import asyncio @@ -72,10 +69,7 @@ def get_report_folder(): return report_folder -def encrypt_user_folder(user_report_folder, username): - # Generate a strong random password - strong_password = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(20)) - +def zip_report_folder(user_report_folder, username): # Get parent directory of user_report_folder parent_directory = os.path.dirname(os.path.abspath(user_report_folder)) @@ -88,22 +82,7 @@ def encrypt_user_folder(user_report_folder, username): for file in files: zip_file.write(os.path.join(root, file), arcname=os.path.relpath(os.path.join(root, file), user_report_folder)) - # Buffer size - 64K - bufferSize = 64 * 1024 - - # Encrypt the .zip file - pyAesCrypt.encryptFile(zip_file_name, zip_file_name + ".aes", strong_password, bufferSize) - - # Delete the original zip file - #os.remove(zip_file_name) - - # Write the password to a file - password_file = open(zip_file_name + ".aes" + ".password", "w") - password_file.write(strong_password) - password_file.close() - - # You can return the password if you need to use it later, or you can directly print it here - return strong_password, zip_file_name + ".aes" + return zip_file_name def generate_user_report(preset_username, report_details): if len(preset_username) == 0: @@ -222,28 +201,17 @@ def generate_user_report(preset_username, report_details): break # Generate a random password, then encrypt the ./report/username/ folder to a timestamped .zip file - strong_password, encrypted_zip_file_name = encrypt_user_folder(user_report_folder, username) + zip_file_name = zip_report_folder(user_report_folder, username) # Measure the size of the encrypted .zip file in MB - encrypted_zip_file_size = os.path.getsize(encrypted_zip_file_name) / 1000000 + zip_file_size = os.path.getsize(zip_file_name) / 1000000 # Print the password and the encrypted .zip file name - print("Report generated successfully on user: \"" + username + "\"\n\nYou can send this .zip file and password when reporting a user to law enforcement.") - print("\nPassword: " + strong_password) - print("Encrypted .zip file location: " + encrypted_zip_file_name) - print("Encrypted .zip file size: " + str(encrypted_zip_file_size) + " MB\n") + print("Report generated successfully on user: \"" + username + "\"\n\nYou can send this .zip file when reporting a user to law enforcement.") + print(".zip file location: " + zip_file_name) + print(".zip file size: " + str(zip_file_size) + " MB\n") - return encrypted_zip_file_name, strong_password - -def decrypt_zip_file(): - # Ask user for the location of the encrypted .zip file - encrypted_zip_file_name = input("\nPlease enter the location of the encrypted .zip file: ") - # Ask user for the password - strong_password = input("Please enter the password: ") - # Decrypt the ZIP file into the same location as the encrypted ZIP file - pyAesCrypt.decryptFile(encrypted_zip_file_name, encrypted_zip_file_name[:-4], strong_password, 64 * 1024) - # Print the location of the decrypted ZIP file - print("\nDecrypted .zip file location: " + encrypted_zip_file_name[:-4] + "\n") + return zip_file_name def lookup_homeserver_admin(preset_baseurl): if hardcoded_variables.testing_mode == True: @@ -338,7 +306,7 @@ def test_send_email(): print("\nFailed to send email.") def generate_rdlist_report_summary(room_dict, user_id): - print(f"user_dict: {room_dict}") + #print(f"user_dict: {room_dict}") report_content = f"""\n~~~User Report~~~\n\nUsername: {user_id}\n""" for room_id, rdlist_tags in room_dict.items():