Skip to content

Add IpDefanger #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions IpDefanger/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<div align="center">
<img src="../src/assets/imgs/icon.ico" style="width: 50px;height: 50px" />
<h1>Ip Defanger</h1>
</div>
<p align="center">This project allows you to defang some ip informations, using ip-api.com, it was created with CustomTkinter and: </p>


### The Project Preview
<div align="center">
<img src="../src/assets/imgs/app_preview.png" width="300">
<img src="../src/assets/imgs/app_preview2.png" width="300">
</div>

### 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)

<hr>
Made by Ângelo Francisco 🖖.
Binary file added IpDefanger/requirements.txt
Binary file not shown.
Binary file added IpDefanger/src/assets/imgs/app_preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IpDefanger/src/assets/imgs/app_preview2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IpDefanger/src/assets/imgs/icon.ico
Binary file not shown.
Binary file added IpDefanger/src/assets/imgs/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions IpDefanger/src/main.py
Original file line number Diff line number Diff line change
@@ -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()
Binary file not shown.
Binary file not shown.
14 changes: 14 additions & 0 deletions IpDefanger/src/utils/ipValidator.py
Original file line number Diff line number Diff line change
@@ -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


11 changes: 11 additions & 0 deletions IpDefanger/src/utils/timezone_to_time.py
Original file line number Diff line number Diff line change
@@ -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")
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down