Skip to content

Commit f935a17

Browse files
Importation de Iptool
1 parent 1483423 commit f935a17

File tree

10 files changed

+683
-0
lines changed

10 files changed

+683
-0
lines changed

Scripts/.DS_Store

6 KB
Binary file not shown.

Scripts/1-doublon.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import os
2+
import colorama
3+
import shutil
4+
import subprocess
5+
import sys
6+
7+
colorama.init()
8+
9+
CLEAR_SCREEN = "\033[2J"
10+
RED = "\033[31m"
11+
RESET = "\033[0m"
12+
BLUE = "\033[34m"
13+
CYAN = "\033[36m"
14+
GREEN = "\033[32m"
15+
BOLD = "\033[m"
16+
REVERSE = "\033[m"
17+
BLACK = "\033[30m"
18+
YELLOW = "\033[33m"
19+
MAGENTA = "\033[35m"
20+
CYAN = "\033[36m"
21+
WHITE = "\033[37m"
22+
23+
try:
24+
while True:
25+
print("\nQuel est votre choix ?")
26+
print("\n1) Supprimer les doublons de lignes d'un fichier texte")
27+
print("2) Retourner au menu principal")
28+
option = input("\nEntrez le numéro de l'option : ")
29+
option = option.strip()
30+
31+
if option == '1':
32+
# Demander à l'utilisateur de spécifier le chemin d'un fichier ou de le glisser-déposer dans le terminal
33+
print(YELLOW + "\nAttention : Les lignes en doublon seront effacées dans le fichier que vous allez insérer ici" + RESET)
34+
filepath = input("\nEntrez le chemin d'un fichier .txt ou faites-le glisser-déposer ici : ")
35+
filepath = filepath.strip()
36+
37+
# Vérifier si le chemin de fichier est valide
38+
if os.path.isfile(filepath) and filepath.endswith('.txt'):
39+
# Ouvrir le fichier d'entrée en mode lecture
40+
with open(filepath, "r") as input_file:
41+
# Lire toutes les lignes dans une liste et créer un ensemble (set) de lignes uniques
42+
unique_lines = set(input_file.readlines())
43+
# Ouvrir le fichier d'entrée en mode écriture pour effacer les doublons
44+
with open(filepath, "w") as output_file:
45+
# Écrire les lignes uniques dans le fichier en écrasant les doublons
46+
output_file.writelines(unique_lines)
47+
print(GREEN + "Les doublons de lignes ont été supprimés avec succès dans le fichier {}.".format(filepath) + RESET)
48+
break
49+
else:
50+
print("Le fichier n'existe pas ou n'est pas un fichier texte.")
51+
52+
elif option == '2':
53+
break
54+
55+
else:
56+
print(f"{RED}Choix invalide. Veuillez entrer un numéro valide.{RESET}\n")
57+
print("--------------------------------------------------------")
58+
59+
except KeyboardInterrupt:
60+
print("\nInterruption faite par l'utilisateur.")

Scripts/2-ipdudomaine.py

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
import sys
2+
import os
3+
import re
4+
import socket
5+
import binascii
6+
import time
7+
import json
8+
import random
9+
import threading
10+
import queue
11+
import pprint
12+
import urllib.parse
13+
import smtplib
14+
import telnetlib
15+
import os.path
16+
import hashlib
17+
import string
18+
import urllib.request
19+
import glob
20+
import sqlite3
21+
import argparse
22+
import marshal
23+
import base64
24+
import colorama
25+
import requests
26+
import subprocess
27+
import tkinter as tk
28+
from colorama import Fore, Back, init
29+
from email.mime.multipart import MIMEMultipart
30+
from email.mime.text import MIMEText
31+
from platform import system
32+
from queue import Queue
33+
from time import strftime
34+
from urllib.parse import urlparse
35+
from urllib.request import urlopen
36+
from tkinter import filedialog
37+
38+
39+
colorama.init()
40+
41+
CLEAR_SCREEN = "\033[2J"
42+
RED = "\033[31m"
43+
RESET = "\033[0m"
44+
BLUE = "\033[34m"
45+
CYAN = "\033[36m"
46+
GREEN = "\033[32m"
47+
BOLD = "\033[m"
48+
REVERSE = "\033[m"
49+
BLACK = "\033[30m"
50+
YELLOW = "\033[33m"
51+
MAGENTA = "\033[35m"
52+
CYAN = "\033[36m"
53+
WHITE = "\033[37m"
54+
55+
def logo():
56+
clear = "\x1b[0m"
57+
colors = [36]
58+
59+
x = """
60+
Attention : La liste des noms de domaines doit être sans http:// ou https//
61+
"""
62+
for N, line in enumerate(x.split("\n")):
63+
sys.stdout.write("\x1b[1;%dm%s%s\n" % (random.choice(colors), line, clear))
64+
time.sleep(0.05)
65+
66+
logo()
67+
68+
def get_IP(site):
69+
try:
70+
if "http://" not in site and "https://" not in site:
71+
IP1 = socket.gethostbyname(site)
72+
domain = socket.gethostbyaddr(IP1)[0]
73+
print("Domaine: " + BLUE + site + RESET + " | IP: " + GREEN + IP1 + RESET)
74+
open("ips.txt", "a").write(site + " " + IP1 + "\n")
75+
else:
76+
print(RED + "Erreur : Le domaine ne doit pas commencer par 'http://' ou 'https://'" + RESET)
77+
except:
78+
pass
79+
80+
def showIPsOnly():
81+
try:
82+
with open("ips.txt") as f:
83+
for line in f:
84+
line = line.strip()
85+
if line:
86+
ip = line.split()[1]
87+
print("IP: " + GREEN + ip + RESET)
88+
except:
89+
pass
90+
91+
def get_txt_file_path():
92+
root = tk.Tk()
93+
root.withdraw()
94+
file_path = filedialog.askopenfilename(filetypes=[("Text Files", "*.txt")])
95+
return file_path
96+
97+
try:
98+
while True:
99+
print("1) Entrez le nom de domaine")
100+
print("2) Entrez le chemin du fichier .txt contenant plusieurs noms de domaines ou glissez déposez le fichier")
101+
print("3) Lire le fichier contenant les domaines et IP obtenus")
102+
print("4) Lire le fichier contenant uniquement les IP obtenus")
103+
print("5) Retour au menu principal")
104+
choice = input("\nEntrez un choix: ")
105+
106+
if choice == "1":
107+
nam = input("Entrez le nom de domaine: ")
108+
get_IP(nam)
109+
elif choice == "2":
110+
while True:
111+
nam = input("Entrez le chemin d'un fichier .txt ou faites-le glisser-déposer ici : ")
112+
nam = nam.strip()
113+
if os.path.isfile(nam):
114+
with open(nam) as f:
115+
for i in f:
116+
get_IP(i.strip())
117+
break
118+
elif os.path.isfile(nam.strip('"')):
119+
with open(nam.strip('"')) as f:
120+
for i in f:
121+
get_IP(i.strip())
122+
break
123+
else:
124+
print(RED + "Erreur : Le chemin du fichier est incorrect." + RESET + " Veuillez entrer un nouveau chemin.")
125+
elif choice == "3":
126+
nam = "ips.txt"
127+
if not os.path.isfile(nam):
128+
print(RED + "Erreur : Le fichier est introuvable." + RESET)
129+
else:
130+
with open(nam) as f:
131+
for line in f:
132+
line = line.strip()
133+
if line:
134+
domain, ip = line.split()
135+
print("Domaine: " + BLUE + domain + RESET + " | IP: " + GREEN + ip + RESET)
136+
elif choice == "4":
137+
showIPsOnly()
138+
elif choice == "5":
139+
sys.exit()
140+
else:
141+
print(RED + "Choix invalide. Veuillez entrer un numéro valide." + RESET)
142+
143+
print("----------------------------")
144+
145+
except KeyboardInterrupt:
146+
print("\nInterruption faite par l'utilisateur.")
147+
sys.exit()

Scripts/3-verifliveip.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import socket
2+
import os
3+
import sys
4+
import subprocess
5+
from multiprocessing.dummy import Pool as ThreadPool
6+
7+
8+
red = '\033[91m'
9+
green = '\033[92m'
10+
white = '\033[00m'
11+
12+
try:
13+
while True:
14+
print("\n1) Vérifier l'IP pour un nom de domaine")
15+
print("2) Vérifier que les adresses IP sont en lignes à partir d'une liste d'adresses IP dans un fichier .txt")
16+
print("3) Revenir au menu principal")
17+
choice = input("\nEntrez votre choix : ")
18+
19+
if choice == '1':
20+
domain = input("Entrer le nom de domaine: ")
21+
try:
22+
ips = list(set(socket.gethostbyname_ex(domain)[2]))
23+
except:
24+
print("Impossible de résoudre le nom de domaine")
25+
continue
26+
elif choice == '2':
27+
file_path = input("Importer une liste de domaines à partir d'un fichier .txt: ")
28+
if not os.path.isfile(file_path):
29+
print(f"{file_path} n'existe pas")
30+
continue
31+
with open(file_path, 'r') as f:
32+
ips = f.read().splitlines()
33+
elif choice == '3':
34+
sys.exit()
35+
else:
36+
print(f"{RED}Choix invalide. Veuillez entrer un numéro valide.{RESET}\n")
37+
continue
38+
39+
def taz(ip):
40+
try:
41+
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
42+
sock.settimeout(5)
43+
result = sock.connect_ex((ip, 80))
44+
if result != 0:
45+
print(red + '[-] Ip hors ligne --> ' + ip + white)
46+
else:
47+
print(green + '[+] Ip en ligne --> ' + ip + white)
48+
with open("Result/LiveIps.txt", "a") as f:
49+
f.write(ip + "\n")
50+
except:
51+
pass
52+
53+
if 'ips' not in locals():
54+
continue
55+
56+
pool = ThreadPool(100)
57+
pool.map(taz, ips)
58+
pool.close()
59+
pool.join()
60+
print("Opération Terminée. Les résultats sont sauvegardés dans Result/LiveIps.txt")
61+
62+
except KeyboardInterrupt:
63+
print("\nInterruption faite par l'utilisateur.")

Scripts/4-scanportsip.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import socket
2+
import sys
3+
import subprocess
4+
import colorama
5+
import nmap
6+
7+
colorama.init()
8+
9+
CLEAR_SCREEN = "\033[2J"
10+
RED = "\033[31m"
11+
RESET = "\033[0m"
12+
GREEN = "\033[32m"
13+
YELLOW = "\033[33m"
14+
MAGENTA = "\033[35m"
15+
CYAN = "\033[36m"
16+
WHITE = "\033[37m"
17+
YELLOW = "\033[33m"
18+
19+
def get_service(port):
20+
nm = nmap.PortScanner()
21+
nm.scan(hosts=ip, ports=str(port), arguments='-sV')
22+
try:
23+
service = nm[ip]['tcp'][port]['name']
24+
except KeyError:
25+
service = "N/A"
26+
try:
27+
product = nm[ip]['tcp'][port]['product']
28+
except KeyError:
29+
product = "N/A"
30+
try:
31+
service_info = nm[ip]['tcp'][port]['extrainfo']
32+
except KeyError:
33+
service_info = "N/A"
34+
return service, product, service_info
35+
36+
while True:
37+
try:
38+
ip = input("Entrez une adresse IP : ")
39+
host_name = socket.gethostbyaddr(ip)[0]
40+
print(f"\nScan en cours pour l'adresse IP : {GREEN}{ip}{RESET} ({YELLOW}{host_name}{RESET})")
41+
42+
start_port = int(input("Entrez le port de début : "))
43+
end_port = int(input("Entrez le port de fin : "))
44+
45+
print("Scan en cours...")
46+
open_ports = []
47+
processes = []
48+
for port in range(start_port, end_port+1):
49+
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
50+
sock.settimeout(0.1)
51+
result = sock.connect_ex((ip, port))
52+
if result == 0:
53+
try:
54+
process = subprocess.check_output(f"lsof -i:{port}", shell=True).decode("utf-8").split("\n")[1].split()[0]
55+
except subprocess.CalledProcessError:
56+
process = "N/A"
57+
service, product, service_info = get_service(port)
58+
open_ports.append(port)
59+
print(f"Port {GREEN}{port}{RESET} ouvert {YELLOW}(TCP){RESET} : Service : {CYAN}{service}{RESET} Service Produit : {MAGENTA}{product}{RESET} Information sur le service : {YELLOW}{service_info}{RESET}")
60+
else:
61+
result_udp = sock.connect_ex((ip, port))
62+
if result_udp == 0:
63+
try:
64+
process = subprocess.check_output(f"lsof -i:{port}", shell=True).decode("utf-8").split("\n")[1].split()[0]
65+
except subprocess.CalledProcessError:
66+
process = "N/A"
67+
service, product, service_info = get_service(port)
68+
open_ports.append(port)
69+
print(f"Port {GREEN}{port}{RESET} ouvert {YELLOW}(UDP){RESET} : {CYAN}{service}{RESET} / {MAGENTA}{product}{RESET} / {YELLOW}{service_info}{RESET}")
70+
sock.close()
71+
72+
if len(open_ports) == 0:
73+
print("Aucun port ouvert trouvé.")
74+
else:
75+
print(f"\nFin du scan.\n\nTentative de récupération de l'OS utilisé...")
76+
77+
# Obtention de l'OS utilisé pour l'IP scannée
78+
try:
79+
output = subprocess.check_output(f"nmap -O {ip}", shell=True).decode("utf-8")
80+
os_used = output.split("OS details: ")[1].split("\n")[0]
81+
print(f"\n{MAGENTA}OS utilisé : {os_used}{RESET}")
82+
except (subprocess.CalledProcessError, IndexError):
83+
print(f"\n{RED}Impossible de déterminer l'OS utilisé.{RESET}")
84+
85+
# Affichage des choix de l'utilisateur
86+
response = input("\nQue voulez-vous faire ? \n1) Lancer le scan d'une autre adresse IP\n2) Retourner au menu principal\n\nQuel est votre choix ? ")
87+
if response == "1":
88+
continue
89+
elif response == "2":
90+
sys.exit()
91+
else:
92+
print(f"{RED}Choix invalide. Veuillez entrer un numéro valide.{RESET}\n")
93+
continue
94+
95+
except KeyboardInterrupt:
96+
print("\nInterruption faite par l'utilisateur.")
97+
sys.exit()
98+
except socket.herror:
99+
print(f"{RED}Erreur : adresse IP non valide ou machine inactive.{RESET}")
100+
continue

0 commit comments

Comments
 (0)