diff --git a/IpDefanger/docs/README.md b/IpDefanger/docs/README.md new file mode 100644 index 00000000..ad407042 --- /dev/null +++ b/IpDefanger/docs/README.md @@ -0,0 +1,42 @@ +
+ +

Ip Defanger

+
+

This project allows you to defang some ip informations, using ip-api.com, it was created with CustomTkinter and:

+ + +### The Project Preview +
+ + +
+ +### Tools ๐Ÿ› ๏ธ +Was used the next softwares: +- Python +- Libraries: + - CustomTkinter + - Tkinter + - requests + - ipaddress + + +### How to run + +```bash +# Clone the project repository +git clone https://github.com/angelo-francisco/Ip-Defanger.git + +# Acess the venv(can be diff. in other OS) +./venv/Scripts/Activate + +# Run the project +python cd/main.py +``` + +## License ๐Ÿ”‘ + +The license of the project is [MIT](https://opensource.org/license/mit) + +
+Made by ร‚ngelo Francisco ๐Ÿ––. \ No newline at end of file diff --git a/IpDefanger/requirements.txt b/IpDefanger/requirements.txt new file mode 100644 index 00000000..045ecee8 Binary files /dev/null and b/IpDefanger/requirements.txt differ diff --git a/IpDefanger/src/assets/imgs/app_preview.png b/IpDefanger/src/assets/imgs/app_preview.png new file mode 100644 index 00000000..aee961fe Binary files /dev/null and b/IpDefanger/src/assets/imgs/app_preview.png differ diff --git a/IpDefanger/src/assets/imgs/app_preview2.png b/IpDefanger/src/assets/imgs/app_preview2.png new file mode 100644 index 00000000..1592cae6 Binary files /dev/null and b/IpDefanger/src/assets/imgs/app_preview2.png differ diff --git a/IpDefanger/src/assets/imgs/icon.ico b/IpDefanger/src/assets/imgs/icon.ico new file mode 100644 index 00000000..9ddb9cc6 Binary files /dev/null and b/IpDefanger/src/assets/imgs/icon.ico differ diff --git a/IpDefanger/src/assets/imgs/icon.png b/IpDefanger/src/assets/imgs/icon.png new file mode 100644 index 00000000..c373a380 Binary files /dev/null and b/IpDefanger/src/assets/imgs/icon.png differ diff --git a/IpDefanger/src/main.py b/IpDefanger/src/main.py new file mode 100644 index 00000000..5e22d42e --- /dev/null +++ b/IpDefanger/src/main.py @@ -0,0 +1,79 @@ +import sys +import os +import customtkinter as ctk +import requests as rq +from utils.ipValidator import ipValidate +from utils.timezone_to_time import timeZoneToTime +from tkinter import messagebox + +BASE_DIR = os.path.abspath(os.curdir) +ICONBITMAP = os.path.join(BASE_DIR, "assets/imgs/icon.ico/") + +sys.path.append(BASE_DIR) + +ZeroDivisionError + +def ipDefanger(ip: str): + if ipValidate(ip): + request = rq.get(f"http://ip-api.com/json/{ip}") + request = request.json() + + if request['status'] == "success": + windowIpInfo = ctk.CTkToplevel(window) + windowIpInfo.title('Ip Defanger Details') + windowIpInfo.geometry('350x330') + windowIpInfo.iconbitmap(ICONBITMAP) + + title = ctk.CTkLabel(windowIpInfo, text='Ip Details', font=("Arial", 28, "bold")) + title.pack(pady=20) + + country = ctk.CTkLabel(windowIpInfo, text=f"Country: {request['country']}", font=("Arial", 15)) + country.pack(anchor="w", padx=20) + + countryCode = ctk.CTkLabel(windowIpInfo, text=f"Country Code: {request['countryCode']}", font=("Arial", 15)) + countryCode.pack(anchor="w", padx=20) + + region = ctk.CTkLabel(windowIpInfo, text=f"region: {request['regionName']}", font=("Arial", 15)) + region.pack(anchor="w", padx=20) + + city = ctk.CTkLabel(windowIpInfo, text=f"City: {request['city']}", font=("Arial", 15)) + city.pack(anchor="w", padx=20) + + lat = ctk.CTkLabel(windowIpInfo, text=f"Lat: {request['lat']}", font=("Arial", 15)) + lat.pack(anchor="w", padx=20) + + lon = ctk.CTkLabel(windowIpInfo, text=f"City: {request['lon']}", font=("Arial", 15)) + lon.pack(anchor="w", padx=20) + + timezone = ctk.CTkLabel(windowIpInfo, text=f"Timezone: {request['timezone']}", font=("Arial", 15)) + timezone.pack(anchor="w", padx=20) + + time = ctk.CTkLabel(windowIpInfo, text=f"Time: {timeZoneToTime(request['timezone'])}", font=("Arial", 15)) + time.pack(anchor="w", padx=20) + + window.mainloop() + else: + messagebox.showerror(title='Ip Defanger Error', message=request['message']) + else: + messagebox.showerror(title='Ip Defanger Error', message="This address is not a valid IP") + + +window = ctk.CTk() +window.title("Ip Defanger") +window.geometry("400x100") +window.iconbitmap(ICONBITMAP) + +ip_entry = ctk.StringVar() +ip_entry = ctk.CTkEntry(window, placeholder_text="Write the ip here", width=300) +ip_entry.pack(pady=10) + +button = ctk.CTkButton( + window, + width=300, + height=30, + text="Track IP", + command=lambda: ipDefanger(ip=ip_entry.get()), +) +button.pack(pady=1) + +window.mainloop() diff --git a/IpDefanger/src/utils/__pycache__/ipValidator.cpython-312.pyc b/IpDefanger/src/utils/__pycache__/ipValidator.cpython-312.pyc new file mode 100644 index 00000000..e017aa4b Binary files /dev/null and b/IpDefanger/src/utils/__pycache__/ipValidator.cpython-312.pyc differ diff --git a/IpDefanger/src/utils/__pycache__/timezone_to_time.cpython-312.pyc b/IpDefanger/src/utils/__pycache__/timezone_to_time.cpython-312.pyc new file mode 100644 index 00000000..05706038 Binary files /dev/null and b/IpDefanger/src/utils/__pycache__/timezone_to_time.cpython-312.pyc differ diff --git a/IpDefanger/src/utils/ipValidator.py b/IpDefanger/src/utils/ipValidator.py new file mode 100644 index 00000000..b3f59baa --- /dev/null +++ b/IpDefanger/src/utils/ipValidator.py @@ -0,0 +1,14 @@ +def ipValidate(ip: str) -> bool: + """ + Gets an ip: returns True if ip is valid, and False else. + """ + + from ipaddress import ip_address + + try: + assert ip_address(ip) + except: + return False + return True + + diff --git a/IpDefanger/src/utils/timezone_to_time.py b/IpDefanger/src/utils/timezone_to_time.py new file mode 100644 index 00000000..27dcebf6 --- /dev/null +++ b/IpDefanger/src/utils/timezone_to_time.py @@ -0,0 +1,11 @@ +def timeZoneToTime(timezone): + """ + Returns the time of some timezone + """ + + import pytz + import datetime + + tz = pytz.timezone(timezone) + time = datetime.datetime.now(tz) + return time.strftime("%Y-%m-%d %H:%M:%S %Z%z") \ No newline at end of file diff --git a/README.md b/README.md index e86d05e7..412fd3c5 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ This repository has the following Projects. - [Youtube Searching Script](https://github.com/Shahrayar123/Python-Projects/tree/master/Youtube%20Searching%20Script) - [pokemone_battle](https://github.com/Shahrayar123/Python-Projects/tree/master/pokemone_battle.py) - [Text-to-Speech](https://github.com/Shahrayar123/Python-Projects/tree/master/Text-to-Speech) - +- [Ip-Defanger](https://github.com/Shahrayar123/Python-Projects/tree/master/IpDefanger) ## Contribution