-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathWhatsOSINT.py
More file actions
86 lines (70 loc) · 2.49 KB
/
WhatsOSINT.py
File metadata and controls
86 lines (70 loc) · 2.49 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#BY: HACK UNDERWAY
import os
import requests
import json
from dotenv import load_dotenv
from colorama import Fore, Style, init
# Inicializar Colorama
init(autoreset=True)
# Cargar las variables de entorno desde el archivo .env
load_dotenv()
# Clave de API y host desde el archivo .env
api_key = os.getenv('RAPIDAPI_KEY')
api_host = os.getenv('RAPIDAPI_HOST')
# Función para imprimir el JSON con formato y colores
def imprimir_json_coloreado(data, nivel=0):
indent = " " * nivel
if isinstance(data, dict):
for key, value in data.items():
print(f"{indent}{Fore.CYAN}{key}{Style.RESET_ALL}: ", end="")
imprimir_json_coloreado(value, nivel + 1)
elif isinstance(data, list):
for item in data:
imprimir_json_coloreado(item, nivel)
else:
print(f"{Fore.YELLOW}{data}{Style.RESET_ALL}")
# Función para consultar datos de WhatsApp
def consultar_numero_whatsapp(numero_telefono):
url = f"https://{api_host}/number/{numero_telefono}"
headers = {
"x-rapidapi-key": api_key,
"x-rapidapi-host": api_host
}
try:
# Realizar la solicitud GET a la API
response = requests.get(url, headers=headers)
# Verificar si la solicitud fue exitosa
response.raise_for_status()
# Obtener la respuesta en formato JSON
datos = response.json()
# Imprimir el JSON formateado y coloreado
imprimir_json_coloreado(datos)
except requests.exceptions.HTTPError as http_err:
print(f"{Fore.RED}Error HTTP: {http_err}{Style.RESET_ALL}")
except requests.exceptions.RequestException as req_err:
print(f"{Fore.RED}Error en la solicitud: {req_err}{Style.RESET_ALL}")
except json.JSONDecodeError:
print(f"{Fore.RED}Error al procesar la respuesta JSON.{Style.RESET_ALL}")
except Exception as err:
print(f"{Fore.RED}Ocurrió un error: {err}{Style.RESET_ALL}")
def main():
# Banner verde
print(Fore.GREEN + """
__i
|---|
|[_]|
|:::|
|:::|
`\\ \\
\\_=_\\
Consulta de datos de número de WhatsApp
""" + Style.RESET_ALL)
numero = input("Introduce el número de teléfono (con código de país): ")
# Validar si se ingresó un número
if not numero.strip():
print("Debe ingresar un número de teléfono válido.")
return
# Consultar datos del número
consultar_numero_whatsapp(numero)
if __name__ == "__main__":
main()