-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwifi-scanner.py
81 lines (65 loc) · 3.53 KB
/
wifi-scanner.py
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
from scapy.all import *
from threading import Thread
import pandas
import time
import os
#initializing an array to store the data
access_points = pandas.DataFrame(columns=["BSSID", "SSID", "dBm_Signal", "Channel", "Security"])
#For the entire dataset, we fix the BSSID column as the index as they are unique
access_points.set_index("BSSID", inplace=True)
#extracting all the data from the packet
def data_extraction(packet):
#checking if it is a beacon frame
if packet.haslayer(Dot11Beacon):
#extracting MAC
bssid = packet[Dot11].addr2
#extracting SSID and decoding from Hex to Human Readable format
ssid = packet[Dot11Elt].info.decode()
#extracting signal strength
try:
dBm_Signal = packet.dBm_AntSignal
except:
dBm_Signal = "N/A"
#extracting stats, channel and security details
stats = packet[Dot11Beacon].network_stats()
channel = stats.get("channel")
security = stats.get("crypto")
#storing the obtained data into an dataframe
access_points.loc[bssid] = (ssid, dBm_Signal, channel, security)
#a function to print all data
def print_all():
while True:
os.system("clear")
print('''
██╗ ██╗██╗███████╗██╗ ███████╗ ██████╗ █████╗ ███╗ ██╗███╗ ██╗███████╗██████╗
██║ ██║██║██╔════╝██║ ██╔════╝██╔════╝██╔══██╗████╗ ██║████╗ ██║██╔════╝██╔══██╗
██║ █╗ ██║██║█████╗ ██║ ███████╗██║ ███████║██╔██╗ ██║██╔██╗ ██║█████╗ ██████╔╝
██║███╗██║██║██╔══╝ ██║ ╚════██║██║ ██╔══██║██║╚██╗██║██║╚██╗██║██╔══╝ ██╔══██╗
╚███╔███╔╝██║██║ ██║ ███████║╚██████╗██║ ██║██║ ╚████║██║ ╚████║███████╗██║ ██║
╚══╝╚══╝ ╚═╝╚═╝ ╚═╝ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝
Author: ManuA Version: 1.0
=====================================================================================
''')
print(access_points)
time.sleep(0.5)
#function to change channel
def channel_change():
channel = 1
while True:
os.system(f"iwconfig {interface} channel {ch}")
ch = ch % 14 + 1
time.sleep(0.5)
#main thread
if __name__ == "__main__":
# interface name, check using iwconfig
interface = "wlan0"
# start the thread that prints all the networks
printer = Thread(target=print_all)
printer.daemon = True
printer.start()
# start the channel changer
channel_changer = Thread(target=channel_change)
channel_changer.daemon = True
channel_changer.start()
# start sniffing
sniff(prn=data_extraction, iface=interface)