Il y a des idées qui surgissent sans prévenir, souvent à la croisée de la curiosité et de l’envie de repousser les limites. Un soir, alors que je réfléchissais à l’immensité d’Internet, une question m’a traversé l’esprit : et si je scannais toutes les adresses IPv4 publiques de la planète ?
Un défi un peu fou, mais irrésistible pour tout passionné de réseau et de cybersécurité.
L’immensité d’IPv4 : des chiffres qui donnent le vertige
Avant de me lancer, il fallait mesurer l’ampleur de la tâche. L’espace IPv4, ce sont des adresses sous forme de quatre octets, chacun variant de 0 à 255.
Un rapide calcul :
\(256^4 = 4\,294\,967\,296\)
Soit plus de 4 milliards d’adresses à tester.
C’est vertigineux, mais finalement bien peu comparé à l’infini d’IPv6.
Concevoir un scanner efficace : le choix du multithreading
Face à cette immensité, il fallait une approche rapide et efficace.
J’ai alors décidé d’écrire un script Python, utilisant le multithreading pour paralléliser les tâches et accélérer le scan.
L’idée : distribuer les adresses à tester entre plusieurs threads, chacun travaillant en simultané.
import requests, threading, queue, time
from requests.packages.urllib3.exceptions import InsecureRequestWarning
from colorama import init, Fore, Style
init()
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
# Fonction qui va scanner les adresses IP
def ip_scan(q):
while not q.empty():
ip = q.get()
url = f"http://{ip}"
try:
response = requests.head(url, verify=False, timeout=1)
print(Fore.GREEN + f"{response} - {url}" + Fore.GREEN)
file = open("ip-list.txt", "a")
file.write(url + "\n")
file.close()
except:
print(Fore.RED + f"<Response [404]> - {url}" + Fore.RED)
# Création de la file d'attente pour stocker les adresses IP à scanner
q = queue.Queue()
# Ajout des adresses IP à la file d'attente
for i in range(256):
for j in range(256):
for k in range(256):
for l in range(256):
ip = f"{i}.{j}.{k}.{l}"
print(Fore.YELLOW + f"File d'attente : {ip}")
q.put(ip)
# Création des threads pour exécuter la fonction ip_scan
threads = []
for i in range(10):
t = threading.Thread(target=ip_scan, args=(q,))
t.daemon = True
threads.append(t)
# Démarrage des threads
for t in threads:
t.start()
# Attente de la fin de l'exécution des threads
while not q.empty():
time.sleep(1)
# Fin du programme
print("Tous les threads ont terminé.")
Astuce : Installez les dépendances nécessaires avant d’exécuter le script
pip install requests colorama
Objectif : détecter les serveurs web
Pour ce projet, je me suis limité à la détection des serveurs web accessibles sur le port 80 (HTTP).
L’idée : construire une liste d’adresses IP valides, c’est-à-dire celles qui répondent à une requête HTTP.
Première étape : un test sur une plage restreinte
Avant de lancer le scan global, il fallait tester le concept sur une plage d’adresses plus réduite.
J’ai choisi une plage appartenant à Telecom Italia S.p.A. : 213.82.0.0 à 213.82.255.255.
# Adresses IP avec la range spécifique pour le test
for i in range(256):
for j in range(256):
ip = f"213.82.{i}.{j}"
print(Fore.YELLOW + f"File d'attente : {ip}")
q.put(ip)
Après près de deux heures d’exécution, le script m’a renvoyé une liste de 659 IPs hébergeant un serveur web, sur environ 65 000 testées.
Voici un extrait du résultat :
http://213.82.0.75
http://213.82.0.78
http://213.82.0.76
http://213.82.0.77
http://213.82.0.74
http://213.82.0.165
http://213.82.0.173
http://213.82.0.174
http://213.82.1.228
http://213.82.2.227
http://213.82.3.10
http://213.82.3.11
http://213.82.3.69
http://213.82.3.114
http://213.82.3.222
http://213.82.6.3
http://213.82.6.13
http://213.82.6.85
http://213.82.6.86
http://213.82.6.194
http://213.82.7.110
http://213.82.9.146
http://213.82.9.147
http://213.82.9.148
http://213.82.9.157
http://213.82.9.158
http://213.82.10.9
http://213.82.10.116
http://213.82.10.131
http://213.82.10.135
http://213.82.10.133
http://213.82.10.137
http://213.82.10.140
http://213.82.10.142
http://213.82.12.10
http://213.82.12.11
http://213.82.12.12
http://213.82.12.14
http://213.82.12.99
http://213.82.12.101
http://213.82.12.102
http://213.82.12.126
http://213.82.12.165
http://213.82.12.171
http://213.82.12.196
http://213.82.12.197
http://213.82.12.200
http://213.82.12.202
http://213.82.12.203
http://213.82.12.204
http://213.82.13.34
http://213.82.14.68
http://213.82.14.69
http://213.82.14.72
http://213.82.14.74
http://213.82.14.75
http://213.82.14.92
http://213.82.14.174
http://213.82.16.70
http://213.82.16.68
http://213.82.16.71
http://213.82.16.72
http://213.82.16.73
http://213.82.16.74
http://213.82.16.77
http://213.82.16.76
http://213.82.16.80
http://213.82.16.83
http://213.82.16.87
http://213.82.16.90
http://213.82.16.97
http://213.82.17.198
http://213.82.17.200
http://213.82.17.201
http://213.82.17.203
http://213.82.17.207
http://213.82.17.208
http://213.82.17.204
http://213.82.17.221
http://213.82.18.130
http://213.82.18.131
http://213.82.18.134
http://213.82.18.136
http://213.82.18.137
http://213.82.19.58
http://213.82.19.59
http://213.82.19.60
http://213.82.19.118
http://213.82.19.130
http://213.82.19.186
http://213.82.20.2
http://213.82.20.5
http://213.82.20.10
http://213.82.20.108
http://213.82.20.110
http://213.82.21.4
http://213.82.21.3
http://213.82.21.34
http://213.82.21.100
http://213.82.21.101
http://213.82.21.154
http://213.82.21.155
http://213.82.21.167
http://213.82.21.168
http://213.82.21.184
http://213.82.21.183
http://213.82.21.189
http://213.82.21.188
http://213.82.22.72
http://213.82.24.246
http://213.82.24.254
http://213.82.24.252
http://213.82.24.253
http://213.82.25.166
http://213.82.25.168
http://213.82.25.169
http://213.82.26.75
http://213.82.26.81
http://213.82.26.154
http://213.82.27.134
http://213.82.28.26
http://213.82.28.48
http://213.82.28.78
http://213.82.29.26
http://213.82.29.34
http://213.82.29.81
http://213.82.29.99
http://213.82.29.105
http://213.82.29.104
http://213.82.29.194
http://213.82.30.114
http://213.82.30.145
http://213.82.30.173
http://213.82.30.174
http://213.82.30.175
http://213.82.30.189
http://213.82.30.230
http://213.82.31.17
http://213.82.31.202
http://213.82.31.214
http://213.82.35.20
http://213.82.35.162
http://213.82.35.178
http://213.82.37.58
http://213.82.38.226
http://213.82.38.236
http://213.82.38.239
http://213.82.39.68
http://213.82.39.69
http://213.82.39.70
http://213.82.39.226
http://213.82.40.201
http://213.82.40.219
http://213.82.40.221
http://213.82.41.169
http://213.82.43.10
http://213.82.43.147
http://213.82.44.66
http://213.82.44.146
http://213.82.44.147
http://213.82.44.238
http://213.82.45.108
http://213.82.45.110
http://213.82.45.132
http://213.82.45.135
http://213.82.45.136
http://213.82.45.137
http://213.82.46.60
http://213.82.46.154
http://213.82.46.173
http://213.82.46.224
http://213.82.47.2
http://213.82.47.202
http://213.82.49.50
http://213.82.49.233
http://213.82.49.234
http://213.82.49.235
http://213.82.49.241
http://213.82.50.26
http://213.82.50.180
http://213.82.52.158
http://213.82.52.170
http://213.82.52.180
http://213.82.53.194
http://213.82.54.102
http://213.82.54.106
http://213.82.54.162
http://213.82.54.174
http://213.82.54.225
http://213.82.54.231
http://213.82.59.50
http://213.82.59.199
http://213.82.60.26
http://213.82.61.233
http://213.82.61.238
http://213.82.62.62
http://213.82.62.169
http://213.82.62.170
http://213.82.63.42
http://213.82.63.94
http://213.82.64.20
http://213.82.64.19
http://213.82.64.66
http://213.82.64.67
http://213.82.64.68
http://213.82.64.69
http://213.82.64.70
http://213.82.64.204
http://213.82.66.26
http://213.82.66.66
http://213.82.66.142
http://213.82.66.253
http://213.82.67.12
http://213.82.67.13
http://213.82.67.149
http://213.82.68.186
http://213.82.68.250
http://213.82.69.21
http://213.82.69.132
http://213.82.69.150
http://213.82.69.210
http://213.82.70.90
http://213.82.70.214
http://213.82.70.222
http://213.82.74.4
http://213.82.74.2
http://213.82.74.3
http://213.82.74.28
http://213.82.74.27
http://213.82.74.138
http://213.82.74.196
http://213.82.76.142
http://213.82.78.162
http://213.82.79.133
http://213.82.79.137
http://213.82.79.139
http://213.82.79.234
http://213.82.80.12
http://213.82.80.20
http://213.82.80.21
http://213.82.80.233
http://213.82.81.41
http://213.82.82.70
http://213.82.82.74
http://213.82.82.83
http://213.82.82.105
http://213.82.82.111
http://213.82.84.166
http://213.82.85.147
http://213.82.85.149
http://213.82.85.155
http://213.82.86.30
http://213.82.86.138
http://213.82.87.6
http://213.82.87.10
http://213.82.87.76
http://213.82.87.77
http://213.82.87.206
http://213.82.88.2
http://213.82.88.82
http://213.82.88.122
http://213.82.88.181
http://213.82.88.183
http://213.82.88.218
http://213.82.89.35
http://213.82.89.36
http://213.82.89.37
http://213.82.89.42
http://213.82.89.194
http://213.82.90.14
http://213.82.91.10
http://213.82.91.11
http://213.82.91.13
http://213.82.92.50
http://213.82.93.201
http://213.82.93.205
http://213.82.93.207
http://213.82.93.211
http://213.82.94.19
http://213.82.94.20
http://213.82.94.29
http://213.82.94.58
http://213.82.94.129
http://213.82.97.3
http://213.82.97.106
http://213.82.99.83
http://213.82.99.90
http://213.82.99.92
http://213.82.99.93
http://213.82.99.91
http://213.82.100.22
http://213.82.100.129
http://213.82.100.162
http://213.82.102.102
http://213.82.102.130
http://213.82.102.148
http://213.82.102.169
http://213.82.102.226
http://213.82.102.249
http://213.82.105.2
http://213.82.106.35
http://213.82.106.126
http://213.82.107.18
http://213.82.107.59
http://213.82.107.62
http://213.82.107.68
http://213.82.107.69
http://213.82.107.66
http://213.82.107.133
http://213.82.107.134
http://213.82.107.170
http://213.82.107.246
http://213.82.109.44
http://213.82.109.45
http://213.82.110.243
http://213.82.110.244
http://213.82.111.68
http://213.82.111.67
http://213.82.114.106
http://213.82.114.221
http://213.82.114.220
http://213.82.114.222
http://213.82.115.13
http://213.82.117.58
http://213.82.117.106
http://213.82.120.18
http://213.82.120.70
http://213.82.120.79
http://213.82.120.104
http://213.82.120.108
http://213.82.120.116
http://213.82.120.117
http://213.82.120.118
http://213.82.120.126
http://213.82.120.130
http://213.82.120.182
http://213.82.121.97
http://213.82.121.99
http://213.82.122.26
http://213.82.123.19
http://213.82.123.58
http://213.82.123.122
http://213.82.123.124
http://213.82.123.140
http://213.82.126.153
http://213.82.126.159
http://213.82.128.106
http://213.82.128.137
http://213.82.128.210
http://213.82.128.218
http://213.82.129.205
http://213.82.132.5
http://213.82.132.162
http://213.82.132.222
http://213.82.135.34
http://213.82.135.208
http://213.82.136.26
http://213.82.136.74
http://213.82.142.74
http://213.82.142.133
http://213.82.142.229
http://213.82.142.245
http://213.82.143.122
http://213.82.143.234
http://213.82.143.233
http://213.82.143.235
http://213.82.143.254
http://213.82.144.68
http://213.82.144.254
http://213.82.145.210
http://213.82.145.211
http://213.82.146.85
http://213.82.146.225
http://213.82.147.163
http://213.82.149.10
http://213.82.149.26
http://213.82.149.133
http://213.82.149.173
http://213.82.149.172
http://213.82.149.170
http://213.82.150.54
http://213.82.150.96
http://213.82.150.97
http://213.82.150.98
http://213.82.150.99
http://213.82.151.37
http://213.82.151.43
http://213.82.151.142
http://213.82.152.230
http://213.82.153.147
http://213.82.153.219
http://213.82.153.249
http://213.82.153.250
http://213.82.154.69
http://213.82.154.218
http://213.82.155.50
http://213.82.158.3
http://213.82.158.30
http://213.82.159.202
http://213.82.159.203
http://213.82.159.219
http://213.82.162.201
http://213.82.162.207
http://213.82.162.209
http://213.82.162.211
http://213.82.163.70
http://213.82.163.122
http://213.82.163.125
http://213.82.163.138
http://213.82.163.142
http://213.82.165.66
http://213.82.165.67
http://213.82.165.70
http://213.82.165.187
http://213.82.165.222
http://213.82.165.229
http://213.82.168.43
http://213.82.168.42
http://213.82.168.44
http://213.82.168.45
http://213.82.168.46
http://213.82.171.146
http://213.82.171.150
http://213.82.171.151
http://213.82.171.152
http://213.82.172.82
http://213.82.172.84
http://213.82.172.101
http://213.82.172.105
http://213.82.172.106
http://213.82.172.108
http://213.82.172.109
http://213.82.172.110
http://213.82.172.133
http://213.82.172.141
http://213.82.172.142
http://213.82.173.50
http://213.82.174.94
http://213.82.174.142
http://213.82.174.202
http://213.82.174.226
http://213.82.174.246
http://213.82.175.158
http://213.82.176.33
http://213.82.176.35
http://213.82.176.46
http://213.82.176.186
http://213.82.176.188
http://213.82.176.215
http://213.82.176.230
http://213.82.176.234
http://213.82.177.180
http://213.82.177.179
http://213.82.177.182
http://213.82.177.250
http://213.82.178.51
http://213.82.178.59
http://213.82.178.60
http://213.82.178.62
http://213.82.178.61
http://213.82.178.78
http://213.82.178.98
http://213.82.178.147
http://213.82.178.152
http://213.82.178.153
http://213.82.178.154
http://213.82.178.156
http://213.82.178.194
http://213.82.178.198
http://213.82.178.199
http://213.82.178.205
http://213.82.178.250
http://213.82.179.9
http://213.82.179.68
http://213.82.179.124
http://213.82.179.164
http://213.82.179.180
http://213.82.179.222
http://213.82.179.226
http://213.82.181.209
http://213.82.183.153
http://213.82.183.203
http://213.82.184.10
http://213.82.186.73
http://213.82.186.74
http://213.82.186.80
http://213.82.186.81
http://213.82.186.82
http://213.82.189.174
http://213.82.191.61
http://213.82.191.62
http://213.82.191.90
http://213.82.191.198
http://213.82.191.254
http://213.82.192.166
http://213.82.194.18
http://213.82.194.23
http://213.82.195.54
http://213.82.195.66
http://213.82.195.114
http://213.82.195.160
http://213.82.195.161
http://213.82.195.227
http://213.82.195.229
http://213.82.195.230
http://213.82.197.70
http://213.82.197.230
http://213.82.199.2
http://213.82.199.121
http://213.82.199.127
http://213.82.202.98
http://213.82.202.186
http://213.82.204.250
http://213.82.205.11
http://213.82.205.13
http://213.82.205.170
http://213.82.207.82
http://213.82.207.88
http://213.82.207.89
http://213.82.207.90
http://213.82.207.91
http://213.82.207.254
http://213.82.211.44
http://213.82.214.242
http://213.82.215.22
http://213.82.215.243
http://213.82.216.229
http://213.82.216.234
http://213.82.216.236
http://213.82.216.241
http://213.82.217.74
http://213.82.217.94
http://213.82.217.117
http://213.82.217.205
http://213.82.218.226
http://213.82.219.52
http://213.82.219.50
http://213.82.219.86
http://213.82.219.84
http://213.82.219.130
http://213.82.219.131
http://213.82.219.132
http://213.82.219.133
http://213.82.219.139
http://213.82.219.203
http://213.82.219.204
http://213.82.219.206
http://213.82.219.205
http://213.82.219.250
http://213.82.219.249
http://213.82.220.201
http://213.82.220.202
http://213.82.220.212
http://213.82.220.215
http://213.82.220.217
http://213.82.220.216
http://213.82.220.218
http://213.82.220.219
http://213.82.220.220
http://213.82.220.221
http://213.82.220.222
http://213.82.220.223
http://213.82.220.224
http://213.82.220.225
http://213.82.220.226
http://213.82.220.227
http://213.82.220.228
http://213.82.220.229
http://213.82.220.230
http://213.82.220.232
http://213.82.220.233
http://213.82.220.234
http://213.82.220.236
http://213.82.220.237
http://213.82.220.238
http://213.82.220.239
http://213.82.220.240
http://213.82.220.241
http://213.82.220.242
http://213.82.220.243
http://213.82.220.244
http://213.82.220.245
http://213.82.220.246
http://213.82.220.248
http://213.82.220.247
http://213.82.220.249
http://213.82.221.106
http://213.82.221.107
http://213.82.221.108
http://213.82.221.110
http://213.82.222.145
http://213.82.224.134
http://213.82.224.181
http://213.82.224.182
http://213.82.225.132
http://213.82.225.133
http://213.82.225.134
http://213.82.225.139
http://213.82.226.21
http://213.82.226.177
http://213.82.226.212
http://213.82.227.19
http://213.82.227.50
http://213.82.227.188
http://213.82.229.34
http://213.82.229.36
http://213.82.230.145
http://213.82.231.220
http://213.82.231.222
http://213.82.232.90
http://213.82.232.91
http://213.82.232.93
http://213.82.233.6
http://213.82.233.25
http://213.82.233.90
http://213.82.233.174
http://213.82.235.142
http://213.82.237.4
http://213.82.237.5
http://213.82.237.42
http://213.82.237.233
http://213.82.237.234
http://213.82.237.238
http://213.82.237.237
http://213.82.238.134
http://213.82.239.114
http://213.82.239.155
http://213.82.239.156
http://213.82.239.182
http://213.82.241.1
http://213.82.243.85
http://213.82.244.75
http://213.82.244.77
http://213.82.244.206
http://213.82.244.205
http://213.82.246.98
http://213.82.246.158
http://213.82.247.42
http://213.82.248.130
http://213.82.248.250
http://213.82.249.210
http://213.82.249.218
http://213.82.249.219
http://213.82.249.220
http://213.82.249.221
http://213.82.249.222
http://213.82.249.236
http://213.82.249.235
http://213.82.249.237
http://213.82.251.35
http://213.82.251.37
http://213.82.251.36
http://213.82.254.19
http://213.82.254.20
http://213.82.254.27
http://213.82.254.70
http://213.82.254.122
http://213.82.254.130
http://213.82.254.195
Vers le scan global : l’aventure commence
Fort de ce premier succès, j’ai décidé de passer à la vitesse supérieure : scanner la totalité de l’espace IPv4, de 0.0.0.0 à 255.255.255.255, cette fois sur un VPS Oracle.
# Adresses IP avec la range de toute la planète
for i in range(256):
for j in range(256):
for k in range(256):
for l in range(256):
ip = f"{i}.{j}.{k}.{l}"
print(Fore.YELLOW + f"File d'attente : {ip}")
q.put(ip)
J’ai lancé le scan, prêt à monitorer la progression sur plusieurs jours, tout en surveillant la charge du serveur.
Les limites du réel : la RAM comme talon d’Achille
Mais la réalité technique a vite rattrapé l’expérience : la RAM du VPS a saturé bien avant la fin du scan global.
Impossible d’aller au bout du processus sans revoir l’optimisation du script ou investir dans une machine plus puissante.
Bilan et réflexions
Même si le scan global n’a pas pu aboutir, l’expérience fut riche d’enseignements.
Elle m’a permis de mieux comprendre l’ampleur d’un scan massif, la gestion des ressources système, l’importance du multithreading, et les limites imposées par l’infrastructure.
Ce projet m’a aussi rappelé que derrière chaque adresse IP, il y a potentiellement un service, une histoire, une vulnérabilité ou une opportunité.
Note importante
Ce projet de cybersécurité a été mené dans un cadre strictement éducatif, pour promouvoir la sensibilisation à la sécurité informatique.
Scanner des réseaux publics sans autorisation peut être illégal ou contraire à l’éthique. Restez toujours dans un cadre légal et responsable.
Update : Les résultats du scan global ne seront finalement pas publiés, suite à un souci d’optimisation de la RAM du VPS qui a été saturée. L’aventure continue…