From 29e9d5f6cc9890cd0ba74b8b573f0c0d78255215 Mon Sep 17 00:00:00 2001 From: noarche Date: Thu, 3 Apr 2025 22:37:43 -0400 Subject: [PATCH 1/4] Update ip.py -Added Arguments -Added Default Option -Added Help Menu -Updated Colors -Removed less efficient user prompting for input -Fixed color bug in 'get_ip_info' function when exiting -Added 'updated by Noarche' to 'print_banner' function. --- ip.py | 163 ++++++++++++++++++++++------------------------------------ 1 file changed, 61 insertions(+), 102 deletions(-) diff --git a/ip.py b/ip.py index 61d60c1..a665c3a 100644 --- a/ip.py +++ b/ip.py @@ -1,79 +1,27 @@ - -# ############################### - -# import requests -# from bs4 import BeautifulSoup - -# print(f""" -# \033[34m -# ██╗░░░██╗██████╗░░█████╗░███╗░░██╗██╗██╗░░░██╗███╗░░░███╗ -# ██║░░░██║██╔══██╗██╔══██╗████╗░██║██║██║░░░██║████╗░████║ -# ██║░░░██║██████╔╝███████║██╔██╗██║██║██║░░░██║██╔████╔██║ -# ██║░░░██║██╔══██╗██╔══██║██║╚████║██║██║░░░██║██║╚██╔╝██║ -# ╚██████╔╝██║░░██║██║░░██║██║░╚███║██║╚██████╔╝██║░╚═╝░██║ -# ░╚═════╝░╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░╚══╝╚═╝░╚═════╝░╚═╝░░░░░╚═╝ - -# Dev : DevUranium.t.me -# GitHUB : -# """) - -# def get_csrf_token(): -# url = "https://check-host.net/ip-info" -# response = requests.get(url) -# response.raise_for_status() -# soup = BeautifulSoup(response.text, 'html.parser') - -# csrf_token_input = soup.find('input', {'name': 'csrf_token'}) -# if csrf_token_input: -# csrf_token = csrf_token_input['value'] -# return csrf_token -# else: -# print("CSRF token not found.") -# return None - -# def send_request(ip_address): -# csrf_token = get_csrf_token() -# if csrf_token is not None: -# url = f"https://check-host.net/ip-info?host={ip_address}&csrf_token={csrf_token}" -# response = requests.get(url) -# response.raise_for_status() - -# soup = BeautifulSoup(response.text, 'html.parser') -# table = soup.find('table', class_='ipinfo-table') - -# data = {} - -# for row in table.find_all('tr'): -# columns = row.find_all('td') -# if len(columns) == 2: -# key = columns[0].get_text(strip=True) -# value = columns[1].get_text(strip=True) -# data[key] = value - -# for key, value in data.items(): -# print(f"{key} : {value}") -# else: -# print("Cannot send request without CSRF token.") - -# ip = input("\033[32mIP Enter : \033[0m") - -# send_request(ip) - -# ############################### - - +import sys import requests from bs4 import BeautifulSoup def print_banner(): print(f""" - \033[34m + \033[95m ██╗░░░██╗██████╗░░█████╗░███╗░░██╗██╗██╗░░░██╗███╗░░░███╗ ██║░░░██║██╔══██╗██╔══██╗████╗░██║██║██║░░░██║████╗░████║ ██║░░░██║██████╔╝███████║██╔██╗██║██║██║░░░██║██╔████╔██║ ██║░░░██║██╔══██╗██╔══██║██║╚████║██║██║░░░██║██║╚██╔╝██║ ╚██████╔╝██║░░██║██║░░██║██║░╚███║██║╚██████╔╝██║░╚═╝░██║ ░╚═════╝░╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░╚══╝╚═╝░╚═════╝░╚═╝░░░░░╚═╝\033[0m + + \033[91m ų℘ɖąɬɛɖ ცყ אσα૨૮ɦε \033[0m + """) + +def print_help(): + print(f""" + \033[96mUsage:\033[0m + \033[92m python ip.py -1 \033[0m : Get detailed IP information. + \033[92m python ip.py -2 \033[0m : Check if the IP is residential. + \033[92m python ip.py \033[0m : Default to checking if the IP is residential. + \033[92m python ip.py -h\033[0m : Display this help message. """) def get_csrf_token(): @@ -87,7 +35,7 @@ def get_csrf_token(): csrf_token = csrf_token_input['value'] return csrf_token else: - print("CSRF token not found.") + print("\033[91mCSRF token not found.\033[0m") return None def get_ip_info(ip_address): @@ -110,9 +58,9 @@ def get_ip_info(ip_address): data[key] = value for key, value in data.items(): - print(f"\033[36m{key} : \033[33m{value}") + print(f"\033[94m{key} : \033[93m{value}\033[0m") else: - print("Cannot send request without CSRF token.") + print("\033[91mCannot send request without CSRF token.\033[0m") def check_ip_residential(ip_address): url = f'https://proxycheck.io/v2/{ip_address}?vpn=1&asn=1' @@ -140,47 +88,58 @@ def check_ip_residential(ip_address): proxy = ip_data.get('proxy', "") IPtype = ip_data.get('type', "") - print(f"IP: {ip_address}") - print(f"Status: {status}") - print(f"ASN: {asn}") - print(f"Provider: {provider}") - print(f"Organisation: {organisation}") - print(f"Continent: {continent}") - print(f"Country: {country}") - print(f"ISO code: {isocode}") - print(f"Region: {region}") - print(f"Region code: {regioncode}") - print(f"Timezone: {timezone}") - print(f"City: {city}") - print(f"Postcode: {postcode}") - print(f"Latitude: {latitude}") - print(f"Longitude: {longitude}") - print(f"Currency: {currency}") - print(f"Currency symbol: {symbol}") - print(f"Proxy: {proxy}") - print(f"IP type: {IPtype}") + print(f"\033[92mIP: {ip_address}\033[0m") + print(f"\033[94mStatus: \033[93m{status}\033[0m") + print(f"\033[94mASN: \033[93m{asn}\033[0m") + print(f"\033[94mProvider: \033[93m{provider}\033[0m") + print(f"\033[94mOrganisation: \033[93m{organisation}\033[0m") + print(f"\033[94mContinent: \033[93m{continent}\033[0m") + print(f"\033[94mCountry: \033[93m{country}\033[0m") + print(f"\033[94mISO code: \033[93m{isocode}\033[0m") + print(f"\033[94mRegion: \033[93m{region}\033[0m") + print(f"\033[94mRegion code: \033[93m{regioncode}\033[0m") + print(f"\033[94mTimezone: \033[93m{timezone}\033[0m") + print(f"\033[94mCity: \033[93m{city}\033[0m") + print(f"\033[94mPostcode: \033[93m{postcode}\033[0m") + print(f"\033[94mLatitude: \033[93m{latitude}\033[0m") + print(f"\033[94mLongitude: \033[93m{longitude}\033[0m") + print(f"\033[94mCurrency: \033[93m{currency}\033[0m") + print(f"\033[94mCurrency symbol: \033[93m{symbol}\033[0m") + print(f"\033[94mProxy: \033[93m{proxy}\033[0m") + print(f"\033[94mIP type: \033[93m{IPtype}\033[0m") except Exception as e: - print(f'Error: {str(e)}') + print(f'\033[91mError: {str(e)}\033[0m') def main(): - print_banner() - print("Choose an option:") - print("1. IP Info") - print("2. IP Check Residential") - - choice = input("Enter number: ") - - if choice not in ['1', '2']: - print("\033[31mInvalid choice.\033[0m") + if len(sys.argv) < 2: + print_banner() + print_help() + return + + if len(sys.argv) == 2 and not sys.argv[1].startswith('-'): + # Default to '-2' if only an IP address is provided + ip_address = sys.argv[1] + check_ip_residential(ip_address) return - ip = input("Enter IP address: ") + option = sys.argv[1] - if choice == '1': - get_ip_info(ip) - elif choice == '2': - check_ip_residential(ip) + if option == '-h': + print_help() + elif option in ['-1', '-2']: + if len(sys.argv) < 3: + print("\033[91mError: IP address is required.\033[0m") + return + + ip_address = sys.argv[2] + if option == '-1': + get_ip_info(ip_address) + elif option == '-2': + check_ip_residential(ip_address) + else: + print("\033[91mInvalid option.\033[0m") + print_help() if __name__ == "__main__": main() From d8d583ad01b0939a247260561dd57428ddaa0065 Mon Sep 17 00:00:00 2001 From: noarche Date: Fri, 4 Apr 2025 01:15:30 -0400 Subject: [PATCH 2/4] Update README.md --- README.md | 53 +++++++++++++++++++++-------------------------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index eaa5494..bacebd2 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ pip install requests beautifulsoup4 1. **Clone the repository**: ```bash - git clone https://github.com/DevURANIUM/IP.git + git clone https://github.com/noarche/IP cd IP ``` @@ -52,31 +52,15 @@ pip install requests beautifulsoup4 1. **Run the script**: Start the script by running: ```bash - python3 ip.py + python3 ip.py 127.0.0.1 ``` -2. **Choose an option**: - - **Option 1**: Enter `1` to retrieve general IP information from [Check-host.net](https://check-host.net/). - - **Option 2**: Enter `2` to check if the IP is residential using [Proxycheck.io](https://proxycheck.io/). - -### Example - -1. Run the script: - - ```bash - python3 ip.py - ``` - -2. Enter the IP address when prompted, and choose between: - - **Option 1**: General IP Info (Check-host.net) - - **Option 2**: Residential Check (Proxycheck.io) - The script will display detailed information about the IP address, including its location, ASN, provider, and whether it is a proxy or VPN. ## Code Overview -- **IP Information Retrieval**: Fetches general IP data from Check-host.net, including location, ASN, and ISP. -- **Residential Check**: Uses Proxycheck.io to determine if the IP is residential, including the provider, ASN, and other details like city, region, and timezone. +- **python ip.py -1 127.0.0.1**: Fetches general IP data from Check-host.net, including location, ASN, and ISP. +- **python ip.py 127.0.0.1**: Uses Proxycheck.io to determine if the IP is residential, including the provider, ASN, and other details like city, region, and timezone. ## Dependencies @@ -93,22 +77,27 @@ pip install requests beautifulsoup4 This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. -## Support & Contributions -If you encounter any issues or have suggestions for improvement, please reach out via: +# ꧁꧂ Buy me a coffee ☕ + +![qrCode](https://raw.githubusercontent.com/noarche/cd-ripper/main/unrelated-ignore/CryptoQRcodes.png) + +**Bitcoin** address `bc1qnpjpacyl9sff6r4kfmn7c227ty9g50suhr0y9j` + + +**Ethereum** address `0x94FcBab18E4c0b2FAf5050c0c11E056893134266` + + +**Litecoin** address `ltc1qu7ze2hlnkh440k37nrm4nhpv2dre7fl8xu0egx` + + -- [Telegram](https://t.me/DevURANIUM) -- [GitHub Issues](https://github.com/DevURANIUM/IP/issues) +------------------------------------------------------------------- -## Donation Links +![noarche's GitHub stats](https://github-readme-stats.vercel.app/api?username=noarche&show_icons=true&theme=transparent) -Support the project through donations: -- **BTC**: `bc1qcclcp574hnznm0nmdzzf0ta7366svjskttqks3` -- **TRON**: `TXJqhhwvkrTdnf5HReZf55hEzZuxjto3R4` -- **USDT-(TRC20)**: `TXJqhhwvkrTdnf5HReZf55hEzZuxjto3R4` -- **TON**: `UQAJH2N0pqpvC9YN841w5NH1dCN9Lakwkpjvoy7vXf-vfqgv` +## Credits ---- +This script has been updated and customized to my personal preferance, a fork of the [original by devURANIUM](https://github.com/DevURANIUM/IP) -This file provides an organized and professional overview of the project, similar to the format you requested. From be4f0ba8e16a1340fad4a441b121688912651b98 Mon Sep 17 00:00:00 2001 From: noarche Date: Fri, 4 Apr 2025 11:19:47 -0400 Subject: [PATCH 3/4] Update ip.py -Added domain name resolution. Example python3 ip.py github.com --- ip.py | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/ip.py b/ip.py index a665c3a..683fb2a 100644 --- a/ip.py +++ b/ip.py @@ -1,6 +1,7 @@ import sys import requests from bs4 import BeautifulSoup +import socket def print_banner(): print(f""" @@ -18,12 +19,21 @@ def print_banner(): def print_help(): print(f""" \033[96mUsage:\033[0m - \033[92m python ip.py -1 \033[0m : Get detailed IP information. - \033[92m python ip.py -2 \033[0m : Check if the IP is residential. - \033[92m python ip.py \033[0m : Default to checking if the IP is residential. - \033[92m python ip.py -h\033[0m : Display this help message. + \033[92m python ip.py -1 \033[0m : Get detailed IP information. + \033[92m python ip.py -2 \033[0m : Check if the IP is residential. + \033[92m python ip.py \033[0m : Default to checking if the IP is residential. + \033[92m python ip.py -h\033[0m : Display this help message. """) +def resolve_to_ip(address): + """Resolve a domain name to an IP address. If already an IP, return as is.""" + try: + ip_address = socket.gethostbyname(address) + return ip_address + except socket.gaierror: + print(f"\033[91mError: Unable to resolve domain '{address}' to an IP address.\033[0m") + return None + def get_csrf_token(): url = "https://check-host.net/ip-info" response = requests.get(url) @@ -118,9 +128,10 @@ def main(): return if len(sys.argv) == 2 and not sys.argv[1].startswith('-'): - # Default to '-2' if only an IP address is provided - ip_address = sys.argv[1] - check_ip_residential(ip_address) + address = sys.argv[1] + ip_address = resolve_to_ip(address) + if ip_address: + check_ip_residential(ip_address) return option = sys.argv[1] @@ -129,10 +140,14 @@ def main(): print_help() elif option in ['-1', '-2']: if len(sys.argv) < 3: - print("\033[91mError: IP address is required.\033[0m") + print("\033[91mError: IP address or domain is required.\033[0m") return - ip_address = sys.argv[2] + address = sys.argv[2] + ip_address = resolve_to_ip(address) + if not ip_address: + return + if option == '-1': get_ip_info(ip_address) elif option == '-2': From 44dafa161b1a237e46205f3d46d8bb1a57204416 Mon Sep 17 00:00:00 2001 From: noarche Date: Fri, 4 Apr 2025 13:21:16 -0400 Subject: [PATCH 4/4] Update ip.py -Checks both sources by default and combines information without duplicate. Displays all information as result. Get full results with: 'python3 ip.py google.com' --- ip.py | 97 +++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 77 insertions(+), 20 deletions(-) diff --git a/ip.py b/ip.py index 683fb2a..13c32f6 100644 --- a/ip.py +++ b/ip.py @@ -72,6 +72,39 @@ def get_ip_info(ip_address): else: print("\033[91mCannot send request without CSRF token.\033[0m") +def get_ip_info_summary(ip_address): + """Fetch and return a summary of IP info (Host name, IP range, Local time).""" + csrf_token = get_csrf_token() + if csrf_token is not None: + url = f"https://check-host.net/ip-info?host={ip_address}&csrf_token={csrf_token}" + response = requests.get(url) + response.raise_for_status() + + soup = BeautifulSoup(response.text, 'html.parser') + table = soup.find('table', class_='ipinfo-table') + + data = {} + + for row in table.find_all('tr'): + columns = row.find_all('td') + if len(columns) == 2: + key = columns[0].get_text(strip=True) + value = columns[1].get_text(strip=True) + data[key] = value + + host_name = data.get('Host name', 'N/A') + ip_range = data.get('IP range', 'N/A') + local_time = data.get('Local time', 'N/A') + + return { + 'Host name': host_name, + 'IP range': ip_range, + 'Local time': local_time + } + else: + print("\033[91mCannot send request without CSRF token.\033[0m") + return None + def check_ip_residential(ip_address): url = f'https://proxycheck.io/v2/{ip_address}?vpn=1&asn=1' response = requests.get(url) @@ -98,28 +131,31 @@ def check_ip_residential(ip_address): proxy = ip_data.get('proxy', "") IPtype = ip_data.get('type', "") - print(f"\033[92mIP: {ip_address}\033[0m") - print(f"\033[94mStatus: \033[93m{status}\033[0m") - print(f"\033[94mASN: \033[93m{asn}\033[0m") - print(f"\033[94mProvider: \033[93m{provider}\033[0m") - print(f"\033[94mOrganisation: \033[93m{organisation}\033[0m") - print(f"\033[94mContinent: \033[93m{continent}\033[0m") - print(f"\033[94mCountry: \033[93m{country}\033[0m") - print(f"\033[94mISO code: \033[93m{isocode}\033[0m") - print(f"\033[94mRegion: \033[93m{region}\033[0m") - print(f"\033[94mRegion code: \033[93m{regioncode}\033[0m") - print(f"\033[94mTimezone: \033[93m{timezone}\033[0m") - print(f"\033[94mCity: \033[93m{city}\033[0m") - print(f"\033[94mPostcode: \033[93m{postcode}\033[0m") - print(f"\033[94mLatitude: \033[93m{latitude}\033[0m") - print(f"\033[94mLongitude: \033[93m{longitude}\033[0m") - print(f"\033[94mCurrency: \033[93m{currency}\033[0m") - print(f"\033[94mCurrency symbol: \033[93m{symbol}\033[0m") - print(f"\033[94mProxy: \033[93m{proxy}\033[0m") - print(f"\033[94mIP type: \033[93m{IPtype}\033[0m") + return { + "IP": ip_address, + "Status": status, + "ASN": asn, + "Provider": provider, + "Organisation": organisation, + "Continent": continent, + "Country": country, + "ISO code": isocode, + "Region": region, + "Region code": regioncode, + "Timezone": timezone, + "City": city, + "Postcode": postcode, + "Latitude": latitude, + "Longitude": longitude, + "Currency": currency, + "Currency symbol": symbol, + "Proxy": proxy, + "IP type": IPtype + } except Exception as e: print(f'\033[91mError: {str(e)}\033[0m') + return {} def main(): if len(sys.argv) < 2: @@ -131,7 +167,28 @@ def main(): address = sys.argv[1] ip_address = resolve_to_ip(address) if ip_address: - check_ip_residential(ip_address) + print("\033[97m𝘗𝘳𝘰𝘤𝘦𝘴𝘴𝘪𝘯•._.••`¯\033[0m") + residential_results = [] + try: + residential_results = check_ip_residential(ip_address) + except Exception as e: + print(f"\033[91mError during residential check: {str(e)}\033[0m") + + print("\033[96m𝘗𝘳𝘰𝘤𝘦𝘴𝘴𝘪𝘯•._.••`¯´´•.¸¸.•`\033[0m") + summary = {} + try: + summary = get_ip_info_summary(ip_address) + except Exception as e: + print(f"\033[91mError during IP info fetch: {str(e)}\033[0m") + + print("\n\033[92m𝘗𝘳𝘰𝘤𝘦𝘴𝘴𝘦𝘥•._.••`¯´´•.¸¸.•`´¯`••._.•\033[0m") + if residential_results: + for key, value in residential_results.items(): + print(f"\033[94m{key}: \033[93m{value}\033[0m") + if summary: + print(f"\033[94mHost name: \033[93m{summary.get('Host name', 'N/A')}\033[0m") + print(f"\033[94mIP range: \033[93m{summary.get('IP range', 'N/A')}\033[0m") + print(f"\033[94mLocal time: \033[93m{summary.get('Local time', 'N/A')}\033[0m") return option = sys.argv[1]