-
Notifications
You must be signed in to change notification settings - Fork 8
/
ip_info.py
executable file
·44 lines (38 loc) · 1.36 KB
/
ip_info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
Title: profiler
Author: Mădălin Dogaru
Discord: techblade.
Date: 25-03-2023
Version: v0.1
License: GPLv3
Description: A Red Teaming tool focused on profiling the target.
"""
import requests
import json
from termcolor import colored
class IPInfo:
def __init__(self, output_handle):
self.output_handle = output_handle
def get_ip_info(self, ip):
response = requests.get(f"http://ip-api.com/json/{ip}")
data = json.loads(response.content)
if data["status"] == "success":
green_ip = colored(ip, "green")
cyan_country = colored(data['country'], "light_cyan")
white_city = colored(data['city'], "white")
dark_region = colored(data['regionName'], "dark_grey")
result = f"{green_ip},{cyan_country},{white_city},{dark_region}"
return result
else:
print(colored(f"Failed to retrieve information for IP: {ip}", "red"))
return None
def process_ip_list(self, input_file):
with open(input_file, "r") as ip_file:
for line in ip_file:
ip = line.strip()
result = self.get_ip_info(ip)
if result:
print(result)
if self.output_handle:
self.output_handle.write(result + "\n")
self.output_handle.flush()