diff --git a/Database_Interaction/Databse_Interaction.py b/Database_Interaction/Databse_Interaction.py index 74e3c51570..83a80c0c66 100644 --- a/Database_Interaction/Databse_Interaction.py +++ b/Database_Interaction/Databse_Interaction.py @@ -1,5 +1,6 @@ import sqlite3 + def create_table(connection): cursor = connection.cursor() cursor.execute('''CREATE TABLE IF NOT EXISTS employees ( @@ -10,17 +11,21 @@ def create_table(connection): )''') connection.commit() + def insert_data(connection, name, position, salary): cursor = connection.cursor() cursor.execute("INSERT INTO employees (name, position, salary) VALUES (?, ?, ?)", (name, position, salary)) connection.commit() + def update_salary(connection, employee_id, new_salary): cursor = connection.cursor() - cursor.execute("UPDATE employees SET salary = ? WHERE id = ?", (new_salary, employee_id)) + cursor.execute("UPDATE employees SET salary = ? WHERE id = ?", + (new_salary, employee_id)) connection.commit() + def query_data(connection): cursor = connection.cursor() cursor.execute("SELECT * FROM employees") @@ -28,7 +33,9 @@ def query_data(connection): print("\nEmployee Data:") for row in rows: - print(f"ID: {row[0]}, Name: {row[1]}, Position: {row[2]}, Salary: {row[3]}") + print( + f"ID: {row[0]}, Name: {row[1]}, Position: {row[2]}, Salary: {row[3]}") + if __name__ == "__main__": database_name = "employee_database.db" diff --git a/Forced_Browse/Forced_Browse.py b/Forced_Browse/Forced_Browse.py index a6a9558fff..b79a19cc01 100644 --- a/Forced_Browse/Forced_Browse.py +++ b/Forced_Browse/Forced_Browse.py @@ -5,11 +5,13 @@ from concurrent.futures import ThreadPoolExecutor as executor from optparse import OptionParser + def printer(word): sys.stdout.write(word + " \r") sys.stdout.flush() return True + yellow = "\033[93m" green = "\033[92m" blue = "\033[94m" @@ -17,27 +19,32 @@ def printer(word): bold = "\033[1m" end = "\033[0m" + def check_status(domain, url): if not url or url.startswith("#") or len(url) > 30: return False - + printer("Testing: " + domain + url) try: link = domain + url req = requests.head(link) st = str(req.status_code) if st.startswith(("2", "1")): - print(green + "[+] " + st + " | Found: " + end + "[ " + url + " ]" + " \r") + print(green + "[+] " + st + " | Found: " + end + "[ " + url + + " ]" + " \r") elif st.startswith("3"): link = req.headers['Location'] - print(yellow + "[*] " + st + " | Redirection From: " + end + "[ " + url + " ]" + yellow + " -> " + end + "[ " + link + " ]" + " \r") + print(yellow + "[*] " + st + " | Redirection From: " + end + "[ " + url + " ]" + yellow + + " -> " + end + "[ " + link + " ]" + " \r") elif st.startswith("4"): if st != '404': - print(blue + "[!] " + st + " | Found: " + end + "[ " + url + " ]" + " \r") + print(blue + "[!] " + st + " | Found: " + end + "[ " + url + + " ]" + " \r") return True except Exception: return False + def presearch(domain, ext, url): if ext == 'Null' or ext == 'None': check_status(domain, url) @@ -47,6 +54,7 @@ def presearch(domain, ext, url): link = url if not i else url + "." + str(i) check_status(domain, link) + def main(): parser = OptionParser(green + """ #Usage:""" + yellow + """ @@ -60,10 +68,14 @@ def main(): """ + end) try: - parser.add_option("-t", dest="target", type="string", help="the target domain") - parser.add_option("-w", dest="wordlist", type="string", help="wordlist file") - parser.add_option("-d", dest="thread", type="int", help="the thread number") - parser.add_option("-e", dest="extension", type="string", help="the extensions") + parser.add_option("-t", dest="target", type="string", + help="the target domain") + parser.add_option("-w", dest="wordlist", + type="string", help="wordlist file") + parser.add_option("-d", dest="thread", type="int", + help="the thread number") + parser.add_option("-e", dest="extension", + type="string", help="the extensions") (options, _) = parser.parse_args() if not options.target or not options.wordlist: @@ -88,10 +100,12 @@ def main(): ext_list = ext.split(",") if ext != "Null" else ["Null"] with open(wordlist, 'r') as urls: with executor(max_workers=int(thread)) as exe: - jobs = [exe.submit(presearch, target, ext, url.strip('\n')) for url in urls] + jobs = [exe.submit(presearch, target, ext, + url.strip('\n')) for url in urls] took = (time.time() - start) / 60 - print(red + "Took: " + end + f"{round(took, 2)} m" + " \r") + print(red + "Took: " + end + + f"{round(took, 2)} m" + " \r") print("\n\t* Happy Hacking *") @@ -99,6 +113,7 @@ def main(): print(red + "#Error: " + end + str(e)) exit(1) + if __name__ == '__main__': start = time.time() main() diff --git a/Motor_Control/Motor_Control.py b/Motor_Control/Motor_Control.py index 0ca6b9d11a..cfd75bf2cf 100644 --- a/Motor_Control/Motor_Control.py +++ b/Motor_Control/Motor_Control.py @@ -11,11 +11,13 @@ GPIO.setup(servo_pin, GPIO.OUT) pwm = GPIO.PWM(servo_pin, 50) # 50 Hz PWM frequency + def set_servo_position(angle): duty_cycle = angle / 18 + 2 # Map angle to duty cycle pwm.ChangeDutyCycle(duty_cycle) time.sleep(0.5) # Give time for the servo to move + if __name__ == "__main__": try: pwm.start(0) # Start with 0% duty cycle (0 degrees) diff --git a/Network_Monitoring/Network_Monitoring.py b/Network_Monitoring/Network_Monitoring.py index cd68b93cdb..baba5bea0e 100644 --- a/Network_Monitoring/Network_Monitoring.py +++ b/Network_Monitoring/Network_Monitoring.py @@ -1,6 +1,7 @@ import ping3 import time + def ping_servers(server_list): while True: for server in server_list: @@ -12,6 +13,7 @@ def ping_servers(server_list): time.sleep(60) # Ping every 60 seconds + if __name__ == "__main__": servers_to_monitor = ["google.com", "example.com", "localhost"] diff --git a/OS_interaction/OS_interaction.py b/OS_interaction/OS_interaction.py index a50764c956..f2f6949b22 100644 --- a/OS_interaction/OS_interaction.py +++ b/OS_interaction/OS_interaction.py @@ -2,6 +2,7 @@ import time import os + def monitor_cpu_threshold(threshold): while True: cpu_percent = psutil.cpu_percent(interval=1) @@ -11,10 +12,12 @@ def monitor_cpu_threshold(threshold): print("CPU usage exceeds threshold!") # You can add more actions here, such as sending an email or notification. # For simplicity, we'll just print an alert message. - os.system("say 'High CPU usage detected!'") # macOS command to speak the message + # macOS command to speak the message + os.system("say 'High CPU usage detected!'") time.sleep(10) # Wait for 10 seconds before checking again + if __name__ == "__main__": threshold_percent = 80 # Define the CPU usage threshold in percentage monitor_cpu_threshold(threshold_percent) diff --git a/version_control_automation_script/version_control_automation_script.py b/version_control_automation_script/version_control_automation_script.py index b325184ff7..9825242b06 100644 --- a/version_control_automation_script/version_control_automation_script.py +++ b/version_control_automation_script/version_control_automation_script.py @@ -1,5 +1,6 @@ import subprocess + def create_and_commit_branch(branch_name, commit_message): # Create a new branch subprocess.run(["git", "checkout", "-b", branch_name]) @@ -14,6 +15,7 @@ def create_and_commit_branch(branch_name, commit_message): # Push the changes to the remote repository subprocess.run(["git", "push", "origin", branch_name]) + if __name__ == "__main__": new_branch_name = "feature/awesome-feature" commit_msg = "Added an awesome feature"