|
| 1 | +# © 2024 CIPIX |
| 2 | +# All rights reserved. |
| 3 | +# Tous droits réservés. |
| 4 | + |
| 5 | +import os, sys, requests |
| 6 | +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 7 | +from config.config import * |
| 8 | +from config.menu import Prompt |
| 9 | + |
| 10 | +terminalTitle('IpInfo') |
| 11 | + |
| 12 | +def pprint(text, info): |
| 13 | + print(f'{ADD} {text} : {lightLilac}{info}{reset}') |
| 14 | + |
| 15 | +def scanIp(ip): |
| 16 | + global token |
| 17 | + token = data['ipinfoToken'] |
| 18 | + if ip in ['myip', 'my', 'me'] : |
| 19 | + if token == 'null': |
| 20 | + url = f"https://ipinfo.io/json" |
| 21 | + else: |
| 22 | + url = f"https://ipinfo.io/json?token={token}" |
| 23 | + else : |
| 24 | + if token == 'null': |
| 25 | + url = f"https://ipinfo.io/{ip}" |
| 26 | + else: |
| 27 | + url = f"https://ipinfo.io/{ip}?token={token}" |
| 28 | + response = requests.get(url) |
| 29 | + if response.status_code == 200: |
| 30 | + return response.json() |
| 31 | + else: |
| 32 | + return None |
| 33 | + |
| 34 | +def main(): |
| 35 | + print(f'\n{TIME()} {INPUT} please enter an ip address (enter "me" for your IP information){reset}\n') |
| 36 | + ip = input(Prompt('IpInfo')).lower().replace(' ','') |
| 37 | + info = scanIp(ip) |
| 38 | + print('') |
| 39 | + if info: |
| 40 | + if info.get("bogon"): |
| 41 | + print(f"{TIME_RED()} {ADD_RED} The IP {ip} is a bogon address ! {reset}") |
| 42 | + |
| 43 | + else : |
| 44 | + pprint("IP", info.get('ip')) |
| 45 | + pprint("Hostname", info.get('hostname')) |
| 46 | + pprint("City", info.get('city')) |
| 47 | + pprint("Region", info.get('region')) |
| 48 | + pprint("Country", info.get('country')) |
| 49 | + pprint("Location", info.get('loc')) |
| 50 | + pprint("Organization", info.get('org')) |
| 51 | + pprint("Postal", info.get('postal')) |
| 52 | + pprint("Timezone", info.get('timezone')) |
| 53 | + |
| 54 | + if token == 'null': |
| 55 | + print(f"\n{TIME_YELLOW()} {INFO_YELLOW} With a token, you could obtain much more information.\n For more details, please visit https://ipinfo.io/.") |
| 56 | + |
| 57 | + else: |
| 58 | + asn = info.get('asn', {}) |
| 59 | + pprint("ASN", asn.get('asn')) |
| 60 | + pprint("ASN Name", asn.get('name')) |
| 61 | + pprint("ASN Domain", asn.get('domain')) |
| 62 | + pprint("ASN Route", asn.get('route')) |
| 63 | + pprint("ASN Type", asn.get('type')) |
| 64 | + |
| 65 | + company = info.get('company', {}) |
| 66 | + pprint("Company Name", company.get('name')) |
| 67 | + pprint("Company Domain", company.get('domain')) |
| 68 | + pprint("Company Type", company.get('type')) |
| 69 | + |
| 70 | + carrier = info.get('carrier', {}) |
| 71 | + pprint("Carrier Name", carrier.get('name')) |
| 72 | + pprint("Carrier MCC", carrier.get('mcc')) |
| 73 | + pprint("Carrier MNC", carrier.get('mnc')) |
| 74 | + |
| 75 | + privacy = info.get('privacy', {}) |
| 76 | + pprint("VPN", privacy.get('vpn')) |
| 77 | + pprint("Proxy", privacy.get('proxy')) |
| 78 | + pprint("Tor", privacy.get('tor')) |
| 79 | + pprint("Relay", privacy.get('relay')) |
| 80 | + pprint("Hosting", privacy.get('hosting')) |
| 81 | + pprint("Service", privacy.get('service')) |
| 82 | + |
| 83 | + abuse = info.get('abuse', {}) |
| 84 | + pprint("Abuse Address", abuse.get('address')) |
| 85 | + pprint("Abuse Country", abuse.get('country')) |
| 86 | + pprint("Abuse Email", abuse.get('email')) |
| 87 | + pprint("Abuse Name", abuse.get('name')) |
| 88 | + pprint("Abuse Network", abuse.get('network')) |
| 89 | + pprint("Abuse Phone", abuse.get('phone')) |
| 90 | + else: |
| 91 | + print(f"{TIME_RED()} {ERROR} Unable to retrieve information for this IP.") |
| 92 | + |
| 93 | +if __name__ == "__main__": |
| 94 | + main() |
| 95 | + print('') |
| 96 | + Pause() |
| 97 | + mainMenu() |
0 commit comments