0% found this document useful (0 votes)
5 views3 pages

Simple Cybersecurity Scripts

The document describes two programs: a Password Strength Checker that evaluates password length and complexity, and a Simple Log File Analyzer that counts errors, warnings, and info messages in a log file. The Password Strength Checker assigns a strength score based on criteria such as length and character variety, while the Log File Analyzer reads a log file and summarizes the counts of different message types. Both programs are implemented in Python and provide feedback based on their respective analyses.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Simple Cybersecurity Scripts

The document describes two programs: a Password Strength Checker that evaluates password length and complexity, and a Simple Log File Analyzer that counts errors, warnings, and info messages in a log file. The Password Strength Checker assigns a strength score based on criteria such as length and character variety, while the Log File Analyzer reads a log file and summarizes the counts of different message types. Both programs are implemented in Python and provide feedback based on their respective analyses.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Password Strength Checker

Checks password length and complexity.

The program
import re
password = input("Enter password: ")
strength = 0
if len(password) >= 8:
strength += 1
if [Link](r"[A-Z]", password):
strength += 1
if [Link](r"[a-z]", password):
strength += 1
if [Link](r"[0-9]", password):
strength += 1
if [Link](r"[!@#$%^&*()]", password):
strength += 1
if strength == 5:
print("Strong password")
elif strength >= 3:
print("Moderate password")
else:
print("Weak password")
2. Simple Log File Analyzer
Counts errors, warnings, and info messages in a log file.
Example log file ([Link]):
INFO User logged in
ERROR Database connection failed
WARNING Disk space low
INFO File uploaded
ERROR Invalid password

The program
def analyze_log(file_name):
errors = 0
warnings = 0
infos = 0
with open(file_name, "r") as file:
for line in file:
if "ERROR" in line:
errors += 1
elif "WARNING" in line:
warnings += 1
elif "INFO" in line:
infos += 1
print("Log Analysis Result")
print("-------------------")
print(f"Errors : {errors}")
print(f"Warnings : {warnings}")
print(f"Info : {infos}")
analyze_log("[Link]")

You might also like