├── LICENSE ├── README.md ├── img ├── demo.png └── url-status-checker-logo.png ├── requirements.txt └── url-status-checker.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Sayed Ali 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Status Checker 2 |

3 |
4 | 5 |
6 | URL Status Checker v2.1 7 |
8 |

9 | Status Checker is a Python script that checks the status of one or multiple URLs/domains and categorizes them based on their HTTP status codes. 10 | Version 2.1.0 11 | 12 | ## Features 13 | 14 | - Check the status of single or multiple URLs/domains. 15 | - Asynchronous HTTP requests for improved performance. 16 | - Follow the Redirections. 17 | - Track all the involved IP addresses. 18 | - Color-coded output for better visualization of status codes. 19 | - Progress bar when checking multiple URLs. 20 | - Save results to an output file. 21 | - Error handling for inaccessible URLs and invalid responses. 22 | - Command-line interface for easy usage. 23 | 24 | ## Installation 25 | 26 | 1. Clone the repository: 27 | 28 | ```bash 29 | git clone https://github.com/your_username/status-checker.git 30 | cd status-checker 31 | ``` 32 | 33 | 2. Install dependencies: 34 | 35 | ```bash 36 | pip install -r requirements.txt 37 | ``` 38 | 39 | ## Usage 40 | 41 | ```bash 42 | python status_checker.py [-h] [-d DOMAIN] [-l LIST] [-o OUTPUT] [-v] [-update] 43 | ``` 44 | 45 | - `-d`, `--domain`: Single domain/URL to check. 46 | - `-l`, `--list`: File containing a list of domains/URLs to check. 47 | - `-o`, `--output`: File to save the output. 48 | - `-v`, `--version`: Display version information. 49 | - `-update`: Update the tool. 50 | 51 | ### Using bash watch command: 52 | ```bash 53 | watch -n 72000 python url-status-checker.py -l url_list 54 | ``` 55 | 56 | **Example:** 57 | 58 | ```bash 59 | python status_checker.py -l urls.txt -o results.txt 60 | ``` 61 | **Preview:** 62 | 63 | 64 | ## License 65 | 66 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. 67 | -------------------------------------------------------------------------------- /img/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BLACK-SCORP10/url-status-checker/a8f3c16dd47b493425a5bffdc999194b734ec7fd/img/demo.png -------------------------------------------------------------------------------- /img/url-status-checker-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BLACK-SCORP10/url-status-checker/a8f3c16dd47b493425a5bffdc999194b734ec7fd/img/url-status-checker-logo.png -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | httpx 2 | argparse 3 | tqdm 4 | colorama 5 | -------------------------------------------------------------------------------- /url-status-checker.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import httpx 3 | import asyncio 4 | from tqdm import tqdm 5 | from colorama import Fore, Style 6 | import socket 7 | from urllib.parse import urlparse 8 | 9 | # Banner 10 | BANNER = """ 11 | ╔═══════════════════════════════╗ 12 | ║ StatusChecker.py ║ 13 | ║ Created By: BLACK_SCORP10 ║ 14 | ║ Enanched By: matteocapricci ║ 15 | ╚═══════════════════════════════╝ 16 | """ 17 | 18 | # Color Codes 19 | COLORS = { 20 | "1xx": Fore.WHITE, 21 | "2xx": Fore.GREEN, 22 | "3xx": Fore.YELLOW, 23 | "4xx": Fore.RED, 24 | "5xx": Fore.LIGHTRED_EX, 25 | "Invalid": Fore.WHITE 26 | } 27 | 28 | # Function to resolve hostname to IP:Port 29 | def resolve_ip_and_port(url): 30 | try: 31 | parsed = urlparse(url) 32 | hostname = parsed.hostname 33 | scheme = parsed.scheme 34 | port = parsed.port or (443 if scheme == "https" else 80) 35 | ip_address = socket.gethostbyname(hostname) 36 | return f"{ip_address}:{port}" 37 | except Exception: 38 | return "IP:Port Not Found" 39 | 40 | # Function to check URL status and redirection 41 | async def check_url_status(session, url_id, url): 42 | if "://" not in url: 43 | url = "https://" + url 44 | try: 45 | response = await session.get(url, follow_redirects=True, timeout=10) 46 | final_url = str(response.url) 47 | 48 | original_ip_port = resolve_ip_and_port(url) 49 | redirect_ip_port = resolve_ip_and_port(final_url) if final_url != url else None 50 | 51 | return url_id, url, response.status_code, final_url if final_url != url else None, original_ip_port, redirect_ip_port 52 | except httpx.RequestError: 53 | return url_id, url, None, None, None, None 54 | 55 | # Argument parser 56 | def parse_arguments(): 57 | parser = argparse.ArgumentParser(description="URL Status Checker") 58 | parser.add_argument("-d", "--domain", help="Single domain/URL to check") 59 | parser.add_argument("-l", "--list", help="File containing list of domains/URLs to check") 60 | parser.add_argument("-o", "--output", help="File to save the output") 61 | parser.add_argument("-v", "--version", action="store_true", help="Display version information") 62 | parser.add_argument("-update", action="store_true", help="Update the tool") 63 | return parser.parse_args() 64 | 65 | # Main function 66 | async def main(): 67 | args = parse_arguments() 68 | 69 | if args.version: 70 | print("StatusChecker.py version 1.0") 71 | return 72 | 73 | if args.update: 74 | print("Checking for updates...") # Implement update logic here 75 | return 76 | 77 | print(BANNER) 78 | 79 | urls = set() 80 | 81 | if args.domain: 82 | urls.add(args.domain) 83 | elif args.list: 84 | with open(args.list, 'r') as file: 85 | urls.update(file.read().splitlines()) 86 | else: 87 | print("No input provided. Use -d or -l option.") 88 | return 89 | 90 | async with httpx.AsyncClient() as session: 91 | results = {} 92 | tasks = [check_url_status(session, url_id, url) for url_id, url in enumerate(urls)] 93 | if len(urls) > 1: 94 | with tqdm(total=len(urls), desc="Checking URLs") as pbar: 95 | for coro in asyncio.as_completed(tasks): 96 | url_id, url, status, redirect, ip, redirect_ip = await coro 97 | results[url_id] = (url, status, redirect, ip, redirect_ip) 98 | pbar.update(1) 99 | else: 100 | for coro in asyncio.as_completed(tasks): 101 | url_id, url, status, redirect, ip, redirect_ip = await coro 102 | results[url_id] = (url, status, redirect, ip, redirect_ip) 103 | 104 | status_codes = { 105 | "1xx": [], 106 | "2xx": [], 107 | "3xx": [], 108 | "4xx": [], 109 | "5xx": [], 110 | "Invalid": [] 111 | } 112 | 113 | for url_id, (url, status, redirect, ip, redirect_ip) in results.items(): 114 | if status is not None: 115 | status_group = str(status)[0] + "xx" 116 | status_codes[status_group].append((url, status, redirect, ip, redirect_ip)) 117 | else: 118 | status_codes["Invalid"].append((url, "Invalid", None, "IP:Port Not Found", None)) 119 | 120 | for code, urls_info in status_codes.items(): 121 | if urls_info: 122 | print(COLORS.get(code, Fore.WHITE) + f'===== {code.upper()} =====') 123 | for url, status, redirect, ip, redirect_ip in urls_info: 124 | redirect_str = f"[Redirect: {redirect} ({redirect_ip})]" if redirect else "[Redirect: None]" 125 | print(f'[Status: {status}] [IP: {ip}] {url} {redirect_str}\n') 126 | print(Style.RESET_ALL) 127 | 128 | if args.output: 129 | with open(args.output, 'w') as file: 130 | for code, urls_info in status_codes.items(): 131 | if urls_info: 132 | file.write(f'===== {code.upper()} =====\n') 133 | for url, status, redirect, ip, redirect_ip in urls_info: 134 | redirect_str = f"[Redirect: {redirect} ({redirect_ip})]" if redirect else "[Redirect: None]" 135 | file.write(f'[Status: {status}] [IP: {ip}] {url} {redirect_str}\n') 136 | 137 | if __name__ == "__main__": 138 | asyncio.run(main()) 139 | --------------------------------------------------------------------------------