Above is a python script that scans wifi networks. Please explain each line of code. Write an explanatory note about the libraries used and their methods.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

  Above is a python script that scans wifi networks. Please explain each line of code. Write an explanatory note about the libraries used and their methods.

def print_all():
while True:
os. system ("clear")
print(networks)
time.sleep (0.5)
def change_channel ():
ch = 1
while True:
os. system (f"iwconfig (interface) channel (ch)")
# switch channel from 1 to 14 each 0.5s
ch = ch % 14 + 1
time.sleep (0.5)
if
паme
main":
==
# interface name, check using iwconfig
interface = "wlan@mon"
# 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=change_channel)
channel_changer.daemon = True
channel_changer.start ()
# start sniffing
sniff (prn=callback, iface-interface)
Transcribed Image Text:def print_all(): while True: os. system ("clear") print(networks) time.sleep (0.5) def change_channel (): ch = 1 while True: os. system (f"iwconfig (interface) channel (ch)") # switch channel from 1 to 14 each 0.5s ch = ch % 14 + 1 time.sleep (0.5) if паme main": == # interface name, check using iwconfig interface = "wlan@mon" # 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=change_channel) channel_changer.daemon = True channel_changer.start () # start sniffing sniff (prn=callback, iface-interface)
from scapy.all import
from threading import Thread
import pandas
import time
import os
# initialize the networks dataframe that will contain all access points nearby
networks = pandas. DataFrame (columns=["BSSID", "SSID", "dBm_Signal", "Channel", "Crypto"])
# set the index BSSID (MAC address of the AP)
networks. set index ("BSSID", inplace=True)
def callback (packet):
if packet. haslayer (Dot1lBeacon):
# extract the MAC address of the network
bssid = packet [Dotl1].addr2
# get the name of it
ssid = packet[Dotl1Elt].info.decode ()
try:
dbm_signal = packet. dBm_AntSignal
except:
dbm_signal = "N/A"
# extract network stats
stats = packet [Dotl1Beacon].network_stats()
# get the channel of the AP
channel = stats.get ("channel")
# get the crypto
crypto = stats.get ("crypto")
networks. loc [bssid] = (ssid, dbm_signal, channel, crypto)
Transcribed Image Text:from scapy.all import from threading import Thread import pandas import time import os # initialize the networks dataframe that will contain all access points nearby networks = pandas. DataFrame (columns=["BSSID", "SSID", "dBm_Signal", "Channel", "Crypto"]) # set the index BSSID (MAC address of the AP) networks. set index ("BSSID", inplace=True) def callback (packet): if packet. haslayer (Dot1lBeacon): # extract the MAC address of the network bssid = packet [Dotl1].addr2 # get the name of it ssid = packet[Dotl1Elt].info.decode () try: dbm_signal = packet. dBm_AntSignal except: dbm_signal = "N/A" # extract network stats stats = packet [Dotl1Beacon].network_stats() # get the channel of the AP channel = stats.get ("channel") # get the crypto crypto = stats.get ("crypto") networks. loc [bssid] = (ssid, dbm_signal, channel, crypto)
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY