Author: admin

  • To-Do List Manager Script

    def display_tasks(tasks):
        if not tasks:
            print("Your to-do list is empty.")
        else:
            print("Your To-Do List:")
            for index, task in enumerate(tasks, start=1):
                print(f"{index}. {task}")
    
    def main():
        tasks = []
        while True:
            print("\nOptions:")
            print("1. Add task")
            print("2. Remove task")
            print("3. View tasks")
            print("4. Exit")
            
            choice = input("Select an option (1-4): ")
            
            if choice == '1':
                task = input("Enter the task: ")
                tasks.append(task)
                print(f"Task '{task}' added.")
            elif choice == '2':
                display_tasks(tasks)
                try:
                    task_index = int(input("Enter the task number to remove: ")) - 1
                    if 0 <= task_index < len(tasks):
                        removed_task = tasks.pop(task_index)
                        print(f"Task '{removed_task}' removed.")
                    else:
                        print("Invalid task number.")
                except ValueError:
                    print("Please enter a valid number.")
            elif choice == '3':
                display_tasks(tasks)
            elif choice == '4':
                print("Exiting the To-Do List Manager.")
                break
            else:
                print("Invalid option. Please try again.")
    
    if __name__ == "__main__":
        main()
  • URL Shortener

    import pyshorteners
    
    def shorten_url(long_url):
        s = pyshorteners.Shortener()
        short_url = s.tinyurl.short(long_url)
        return short_url
    
    if __name__ == "__main__":
        long_url = input("Enter the URL to shorten: ")
        short_url = shorten_url(long_url)
        print(f"Shortened URL: {short_url}")
  • News Headlines Fetcher

    import requests
    
    def fetch_latest_news(api_key):
        url = f"https://newsapi.org/v2/top-headlines?country=us&apiKey={api_key}"
        response = requests.get(url)
    
        if response.status_code == 200:
            articles = response.json().get('articles')
            if articles:
                print("Latest News Headlines:")
                for article in articles:
                    print(f"- {article['title']}")
            else:
                print("No articles found.")
        else:
            print(f"Error fetching news: {response.status_code}")
    
    if __name__ == "__main__":
        api_key = input("Enter your NewsAPI key: ")
    #sign up at newsapi to get an api key
        fetch_latest_news(api_key)
  • Website Change Monitor Script

    import requests
    import time
    import hashlib
    
    def get_website_content(url):
        response = requests.get(url)
        return response.text
    
    def hash_content(content):
        return hashlib.sha256(content.encode('utf-8')).hexdigest()
    
    def monitor_website(url, check_interval):
        print(f"Monitoring changes to {url} every {check_interval} seconds...")
        initial_content = get_website_content(url)
        initial_hash = hash_content(initial_content)
    
        while True:
            time.sleep(check_interval)
            current_content = get_website_content(url)
            current_hash = hash_content(current_content)
    
            if current_hash != initial_hash:
                print(f"Change detected on {url}!")
                initial_hash = current_hash
            else:
                print("No changes detected.")
    
    if __name__ == "__main__":
        target_url = input("Enter a URL to monitor (e.g., http://example.com): ")
        interval = int(input("Enter the check interval in seconds: "))
        monitor_website(target_url, interval)
  • Basic Vulnerability Scanner Script

    import requests
    
    def check_sql_injection(url):
        payload = "' OR '1'='1"
        response = requests.get(url + payload)
        if "error" not in response.text.lower():
            return True
        return False
    
    def check_xss(url):
        payload = "<script>alert('XSS')</script>"
        response = requests.get(url + payload)
        if payload in response.text:
            return True
        return False
    
    def scan_vulnerabilities(url):
        print(f"Scanning {url} for vulnerabilities...")
        
        if check_sql_injection(url):
            print("Potential SQL Injection vulnerability found!")
        else:
            print("No SQL Injection vulnerability detected.")
    
        if check_xss(url):
            print("Potential XSS vulnerability found!")
        else:
            print("No XSS vulnerability detected.")
    
    if __name__ == "__main__":
        target_url = input("Enter a URL to scan for vulnerabilities (e.g., http://example.com): ")
        scan_vulnerabilities(target_url)
  • Random Compliment Generator

    import random
    
    def get_random_compliment():
        compliments = [
            "You're amazing!",
            "Your smile lights up the room.",
            "You have a great sense of humor!",
            "You're a true friend.",
            "You brighten my day!",
            "You're a wonderful person.",
            "You have a fantastic sense of style!",
            "You're incredibly talented."
        ]
        
        return random.choice(compliments)
    
    if __name__ == "__main__":
        print("Here's a compliment for you:")
        print(get_random_compliment())
  • WHOIS Lookup Script

    import whois
    
    def whois_lookup(domain):
        try:
            domain_info = whois.whois(domain)
            print(f"WHOIS information for {domain}:")
            print(f"  Domain Name: {domain_info.domain_name}")
            print(f"  Registrar: {domain_info.registrar}")
            print(f"  Creation Date: {domain_info.creation_date}")
            print(f"  Expiration Date: {domain_info.expiration_date}")
            print(f"  Name Servers: {domain_info.name_servers}")
        except Exception as e:
            print(f"Error retrieving WHOIS information for '{domain}': {e}")
    
    if __name__ == "__main__":
        target_domain = input("Enter a domain name to look up (e.g., example.com): ")
        whois_lookup(target_domain)
  • Security Headers Checker Script

    import requests
    
    def check_security_headers(url):
        try:
            response = requests.get(url)
            headers = response.headers
    
            security_headers = {
                "Strict-Transport-Security": headers.get("Strict-Transport-Security"),
                "X-Content-Type-Options": headers.get("X-Content-Type-Options"),
                "X-Frame-Options": headers.get("X-Frame-Options"),
                "X-XSS-Protection": headers.get("X-XSS-Protection"),
                "Content-Security-Policy": headers.get("Content-Security-Policy"),
            }
    
            print(f"Security headers for {url}:")
            for header, value in security_headers.items():
                if value:
                    print(f"  {header}: {value}")
                else:
                    print(f"  {header}: Not present")
    
        except requests.exceptions.RequestException as e:
            print(f"Error accessing '{url}': {e}")
    
    if __name__ == "__main__":
        target_url = input("Enter a URL to check security headers (e.g., http://example.com): ")
        check_security_headers(target_url)
  • Password Strength Checker

    import re
    
    def check_password_strength(password):
        length_criteria = len(password) >= 8
        digit_criteria = re.search(r'\d', password) is not None
        uppercase_criteria = re.search(r'[A-Z]', password) is not None
        lowercase_criteria = re.search(r'[a-z]', password) is not None
        special_char_criteria = re.search(r'[@$!%*?&]', password) is not None
    
        if all([length_criteria, digit_criteria, uppercase_criteria, lowercase_criteria, special_char_criteria]):
            return "Strong password!"
        elif length_criteria and (digit_criteria or uppercase_criteria or lowercase_criteria):
            return "Moderate password."
        else:
            return "Weak password."
    
    if __name__ == "__main__":
        password_input = input("Enter a password to check its strength: ")
        strength = check_password_strength(password_input)
        print(strength)
  • URL Status Checker Script

    import requests
    
    def check_url_status(url):
        try:
            response = requests.get(url)
            if response.status_code == 200:
                print(f"The URL '{url}' is up!")
            else:
                print(f"The URL '{url}' returned status code: {response.status_code}")
        except requests.exceptions.RequestException as e:
            print(f"Error accessing '{url}': {e}")
    
    if __name__ == "__main__":
        url_to_check = input("Enter a URL to check (e.g., http://example.com): ")
        check_url_status(url_to_check)