Code Monkey home page Code Monkey logo

websites-monitor's People

Contributors

actions-user avatar fabriziosalmi avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

websites-monitor's Issues

v2

main.py

from datetime import datetime

# Import checks
from checks import (
    check_domain_breach, check_domain_expiration, check_ssl_cert, check_dns_blacklist,
    check_domainsblacklists_blacklist, check_hsts, check_xss_protection, check_redirect_chains,
    check_pagespeed_performances, check_website_load_time, check_rate_limiting, check_cdn,
    check_brotli_compression, check_deprecated_libraries, check_clientside_rendering,
    check_mixed_content, check_content_type_headers, check_internationalization, check_floc,
    check_amp_compatibility, check_robot_txt, check_sitemap, check_favicon, check_alt_tags,
    check_open_graph_protocol, check_semantic_markup, check_ad_and_tracking, check_privacy_protected_whois,
    check_privacy_exposure
)

# Initialize an error log
error_log = []


def log_error(message):
    """A simple function to log errors for later use."""
    error_log.append(message)
    print(message)  # This will also print the error in the console


# Read websites from external file
with open('websites.txt', 'r') as f:
    websites = [line.strip() for line in f.readlines()]

# Initialize Markdown report
report_md = "# Websites Monitor\n"

# Read the project description and usage instructions
with open('project_description.md', 'r') as f:
    report_md += f"{f.read()}\n"

with open('usage_instructions.md', 'r') as f:
    report_md += f"{f.read()}\n"

# Initialize the table
report_md += "\n## Monitoring Checks\n"
report_md += "| Check Type | " + " | ".join(websites) + " |\n"
report_md += "|------------|" + "---|" * len(websites) + "\n"

# List of check functions and their human-readable names
check_functions = [
    ("Domain breach", check_domain_breach),
    # ... [other checks]
    ("Privacy Exposure", check_privacy_exposure),
]

# Populate the table with check results
for check_name, check_func in check_functions:
    report_md += f"| {check_name} | "
    for website in websites:
        try:
            result = check_func(website)
            report_md += f"{result} | "
        except Exception as e:
            err_msg = f"Error occurred with {check_name} for {website}: {e}"
            log_error(err_msg)
            report_md += "⚪ | "  # Add a default grey indicator for errors
    report_md += "\n"

# Timestamp
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
report_md += f"\n---\nLast Updated: {current_time}\n"

# Write the Markdown report to a file
with open("README.md", "w") as f:
    f.write(report_md)

# Exit with a non-zero code if errors were encountered
if error_log:
    exit(1)

Check server software

import requests

def check_server_software(website):
    """
    Detect the web server software of the website.
    
    Args:
    - website (str): URL of the website to be checked.
    
    Returns:
    - str: "🟢" if server software is suppressed or not easily identifiable,
           "🔴" if server software is openly exposed,
           "⚪" for any errors.
    """

    try:
        response = requests.get(website)
        server_header = response.headers.get("Server")

        if server_header:
            print(f"Server software identified: {server_header}")
            return "🔴"
        else:
            return "🟢"

    except Exception as e:
        print(f"Error occurred: {e}")
        return "⚪"

print(check_server_software("https://example.com"))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.