Skip to content

format code with autopep8 #2952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Database_Interaction/Databse_Interaction.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sqlite3


def create_table(connection):
cursor = connection.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS employees (
Expand All @@ -10,25 +11,31 @@ 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")
rows = cursor.fetchall()

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"
Expand Down
35 changes: 25 additions & 10 deletions Forced_Browse/Forced_Browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,46 @@
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"
red = "\033[91m"
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)
Expand All @@ -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 + """
Expand All @@ -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:
Expand All @@ -88,17 +100,20 @@ 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 *")

except Exception as e:
print(red + "#Error: " + end + str(e))
exit(1)


if __name__ == '__main__':
start = time.time()
main()
2 changes: 2 additions & 0 deletions Motor_Control/Motor_Control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions Network_Monitoring/Network_Monitoring.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ping3
import time


def ping_servers(server_list):
while True:
for server in server_list:
Expand All @@ -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"]

Expand Down
5 changes: 4 additions & 1 deletion OS_interaction/OS_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import time
import os


def monitor_cpu_threshold(threshold):
while True:
cpu_percent = psutil.cpu_percent(interval=1)
Expand All @@ -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)
Original file line number Diff line number Diff line change
@@ -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])
Expand All @@ -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"
Expand Down