Skip to content

improved overall script added new features #273

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 3 commits into from
Mar 17, 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
33 changes: 25 additions & 8 deletions PASSWORD RELATED/RandomPassword/password.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
import string #String module will import all the nessary ascii character
import random #random module help us to import functions needed to generate random element.
import string
import secrets

passwrd = string.ascii_letters+string.digits+string.punctuation #This will generate a string consist of all ascii character.
# Define the set of characters to be used in the password
CHARACTER_SET = string.ascii_letters + string.digits + string.punctuation

numPass = int(input("How many passwords do you need to be generated? "))
length = int(input("Enter the length of the password(s): "))
def generate_password(length):
"""Generate a random password of the specified length."""
password = ''.join(secrets.choice(CHARACTER_SET) for i in range(length))
return password

print("List(s) of Generated passwords: ")
def main():
# Prompt the user for the number of passwords to generate and their length
while True:
try:
num_pass = int(input("How many passwords do you want to generate? "))
password_length = int(input("Enter the length of the password(s): "))
break
except ValueError:
print("Please enter a valid integer.")

for _ in range(numPass):
print(''.join(random.sample(passwrd, k=length))) #sample() generates an array of random characters of length k
# Generate the specified number of passwords and print them to the console
print("Generated passwords:")
for i in range(num_pass):
password = generate_password(password_length)
print(f"{i+1}. {password}")

if __name__ == "__main__":
main()
81 changes: 59 additions & 22 deletions PASSWORD RELATED/Saved Wi-FI Password/get-wifi-passwords.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,71 @@
"""
This scripts fetches all saved wifi passwords in your Windows PC
"""

import os
import platform
import subprocess


def get_all_profiles():
try:
data = subprocess.check_output(
["netsh", "wlan", "show", "profiles", "key=clear"]
).decode("utf-8", errors="backslashreplace")
return data
except FileNotFoundError:
system = platform.system()
if system == 'Windows':
try:
data = subprocess.check_output(
["netsh", "wlan", "show", "profiles", "key=clear"]
).decode("utf-8", errors="backslashreplace")
return data
except subprocess.CalledProcessError as error:
return f"Error: {error}"
else:
return "Only For Windows"


def get_profiles_info(profile):
try:
data = subprocess.check_output(
["netsh", "wlan", "show", "profiles", profile, "key=clear"]
).decode("utf-8", errors="backslashreplace")

return data
except subprocess.CalledProcessError:
return "Profile Not Found"
except FileNotFoundError:
system = platform.system()
if system == 'Windows':
try:
data = subprocess.check_output(
["netsh", "wlan", "show", "profiles", profile, "key=clear"]
).decode("utf-8", errors="backslashreplace")
return data
except subprocess.CalledProcessError as error:
return f"Error: {error}"
else:
return "Only For Windows"


def output_to_file(file_path, data):
with open(file_path, 'w') as f:
f.write(data)


def delete_profile(profile):
system = platform.system()
if system == 'Windows':
try:
subprocess.check_call(
["netsh", "wlan", "delete", "profile", f"name=\"{profile}\""]
)
return f"{profile} profile deleted successfully"
except subprocess.CalledProcessError as error:
return f"Error: {error}"
else:
return "Only For Windows"


if __name__ == "__main__":
print(get_all_profiles())
profile = input("Enter the profile Name: ")
print(get_profiles_info(profile))
print("Fetching all saved Wi-Fi profiles...")
profiles = get_all_profiles()
print(profiles)

if profiles != "Only For Windows":
profile_name = input("Enter the profile name: ")
profile_info = get_profiles_info(profile_name)
print(profile_info)

output_choice = input("Do you want to output the results to a file? (y/n): ")
if output_choice.lower() == 'y':
file_path = input("Enter the file path to save the output: ")
output_to_file(file_path, profile_info)

delete_choice = input("Do you want to delete this profile? (y/n): ")
if delete_choice.lower() == 'y':
delete_result = delete_profile(profile_name)
print(delete_result)