├── lib ├── exception.py ├── globals.py ├── ascii.py ├── args.py ├── http.py └── parse_info.py ├── main.py └── README.md /lib/exception.py: -------------------------------------------------------------------------------- 1 | class ExceptionHandler(Exception): 2 | pass -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | #/usr/bin/env python3 2 | 3 | # Author: Kr0ff 4 | # ver: VERSION (Global variable in globals.py) 5 | 6 | from lib.args import * 7 | from lib.globals import * 8 | from lib.ascii import * 9 | 10 | if __name__ == "__main__": 11 | PrintArt() 12 | arg_parser() 13 | -------------------------------------------------------------------------------- /lib/globals.py: -------------------------------------------------------------------------------- 1 | VERSION = "0.1" 2 | IPLOCATION_URL = "https://api.iplocation.net/" 3 | API_URI = "?ip=" 4 | STATUS_SUCCESS = 200 # 200 OK Successfully processed the request. 5 | STATUS_BADREQUEST = 400 # 400 Bad Request Failed to complete the request. 6 | STATUS_FAILURE = 404 # 404 Not Found Command not found. -------------------------------------------------------------------------------- /lib/ascii.py: -------------------------------------------------------------------------------- 1 | # https://www.asciiart.eu/text-to-ascii-art 2 | def PrintArt(): 3 | art = ''' 4 | dBBBBb dBP dBBBBBb dBBBBBb dBBBBP 5 | dB' dB' dBP.BP 6 | dBBBB dBP dBBBP' dBBBP' dBP.BP 7 | dB' BB dBP dBP dBP dBP.BP 8 | dBBBBBB dBP dBP dBP dBBBBP @Kr0ff 9 | 10 | gippo - Retrieve information about a given IP address from \"iplocation.net\" 11 | ''' 12 | 13 | print(art) 14 | -------------------------------------------------------------------------------- /lib/args.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | 3 | from .http import * 4 | 5 | def arg_parser(): 6 | # Print ASCII cos its cool :) 7 | # print(printAscii()) 8 | 9 | parser = argparse.ArgumentParser(description='gippo - Retrieve information about a given IP address from \"iplocation.net\"') 10 | 11 | parser.add_argument("-i", "--ip", help="IP address to check against \"iplocation.net\"", required=False) 12 | parser.add_argument("-v", "--version", help="Show version", required=False, action="store_true") 13 | arg = parser.parse_args() 14 | 15 | if arg.version: 16 | print(f"[*] Version: {VERSION}") 17 | 18 | if arg.ip: 19 | send_request(arg.ip) 20 | 21 | -------------------------------------------------------------------------------- /lib/http.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | from .globals import * 4 | from .exception import * 5 | from .parse_info import * 6 | 7 | # Send request to api.iplocation.net 8 | def send_request(target_ip: str) -> None: 9 | FINAL_URL = IPLOCATION_URL + API_URI + target_ip 10 | 11 | s = requests.Session() 12 | r = s.get(FINAL_URL, verify=True, timeout=10) 13 | 14 | if r.status_code == STATUS_FAILURE: 15 | raise Exception("[-] Failed to send request to \"iplocation.net\"") 16 | elif r.status_code == STATUS_BADREQUEST: 17 | raise Exception("[!] Failed to complete the request") 18 | elif r.status_code == STATUS_SUCCESS: 19 | ret = True 20 | parse_output(r.text) 21 | else: 22 | raise Exception("[-!-] Unknown error !") 23 | -------------------------------------------------------------------------------- /lib/parse_info.py: -------------------------------------------------------------------------------- 1 | import json 2 | from prettytable import PrettyTable 3 | 4 | from .globals import * 5 | from .exception import * 6 | from .http import * 7 | 8 | def CreateTable( 9 | ip, 10 | ip_number, 11 | ip_version, 12 | country_name, 13 | country_code2, 14 | isp, 15 | response_code, 16 | response_message ): 17 | 18 | table = PrettyTable(['IP Address', 'IP Number (Int)', 'IP Type', 'Country', 'Country Code', 'ISP', 'HTTP Response Code', 'HTTP Response Msg']) 19 | table.add_row([ip, ip_number, ip_version, country_name, country_code2, isp, response_code, response_message]) 20 | return table 21 | 22 | def parse_output(payload: str) -> bool: 23 | 24 | # Payload is already returned as a serialized json object 25 | # so we just load it and parse 26 | decoded_dump = json.loads(payload) 27 | 28 | t = CreateTable( 29 | decoded_dump['ip'], 30 | decoded_dump['ip_number'], 31 | decoded_dump['ip_version'], 32 | decoded_dump['country_name'], 33 | decoded_dump['country_code2'], 34 | decoded_dump['isp'], 35 | decoded_dump['response_code'], 36 | decoded_dump['response_message'] 37 | ) 38 | 39 | print(t) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gippo 2 | Gippo is a python tool that uses the API of `iplocation.net` to retrieve information about a given IP address such as originating country, country code and ISP. 3 | The returned information is stored in a table for easy readibility. 4 | 5 | ```sh 6 | $ python3 main.py -i 8.8.8.8 7 | 8 | dBBBBb dBP dBBBBBb dBBBBBb dBBBBP 9 | dB' dB' dBP.BP 10 | dBBBB dBP dBBBP' dBBBP' dBP.BP 11 | dB' BB dBP dBP dBP dBP.BP 12 | dBBBBBB dBP dBP dBP dBBBBP @Kr0ff 13 | 14 | gippo - Retrieve information about a given IP address from "iplocation.net" 15 | 16 | +------------+-----------------+---------+--------------------------+--------------+------------+--------------------+-------------------+ 17 | | IP Address | IP Number (Int) | IP Type | Country | Country Code | ISP | HTTP Response Code | HTTP Response Msg | 18 | +------------+-----------------+---------+--------------------------+--------------+------------+--------------------+-------------------+ 19 | | 8.8.8.8 | 134744072 | 4 | United States of America | US | Google LLC | 200 | OK | 20 | +------------+-----------------+---------+--------------------------+--------------+------------+--------------------+-------------------+ 21 | ``` 22 | 23 | # Dependencies 24 | - argparse 25 | - prettytable 26 | - requests 27 | 28 | ```sh 29 | python3 -m pip install argparse prettytable requests 30 | ``` 31 | --------------------------------------------------------------------------------