Skip to content

Commit 92e40f6

Browse files
committed
add seeing hidden wifi networks tutorial
1 parent c9e90ba commit 92e40f6

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
1717
- [How to Make a SYN Flooding Attack in Python](https://www.thepythoncode.com/article/syn-flooding-attack-using-scapy-in-python). ([code](scapy/syn-flood))
1818
- [How to Inject Code into HTTP Responses in the Network in Python](https://www.thepythoncode.com/article/injecting-code-to-html-in-a-network-scapy-python). ([code](scapy/http-code-injector/))
1919
- [How to Perform IP Address Spoofing in Python](https://thepythoncode.com/article/make-an-ip-spoofer-in-python-using-scapy). ([code](scapy/ip-spoofer))
20+
- [How to See Hidden Wi-Fi Networks in Python](https://thepythoncode.com/article/uncovering-hidden-ssids-with-scapy-in-python). ([code](scapy/uncover-hidden-wifis))
2021
- [Writing a Keylogger in Python from Scratch](https://www.thepythoncode.com/article/write-a-keylogger-python). ([code](ethical-hacking/keylogger))
2122
- [Making a Port Scanner using sockets in Python](https://www.thepythoncode.com/article/make-port-scanner-python). ([code](ethical-hacking/port_scanner))
2223
- [How to Create a Reverse Shell in Python](https://www.thepythoncode.com/article/create-reverse-shell-python). ([code](ethical-hacking/reverse_shell))

scapy/uncover-hidden-wifis/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# [How to See Hidden Wi-Fi Networks in Python](https://thepythoncode.com/article/uncovering-hidden-ssids-with-scapy-in-python)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
scapy
2+
colorama
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Operating system functions.
2+
import os
3+
# Import all functions from scapy library.
4+
from scapy.all import *
5+
# Import Fore from colorama for colored console output, and init for colorama initialization.
6+
from colorama import Fore, init
7+
# Initialize colorama
8+
init()
9+
10+
# Set to store unique SSIDs.
11+
seen_ssids = set()
12+
13+
14+
# Function to set the wireless adapter to monitor mode.
15+
def set_monitor_mode(interface):
16+
# Bring the interface down.
17+
os.system(f'ifconfig {interface} down')
18+
# Set the mode to monitor.
19+
os.system(f'iwconfig {interface} mode monitor')
20+
# Bring the interface back up.
21+
os.system(f'ifconfig {interface} up')
22+
23+
24+
# Function to process Wi-Fi packets.
25+
def process_wifi_packet(packet):
26+
# Check if the packet is a Probe Request, Probe Response, or Association Request.
27+
if packet.haslayer(Dot11ProbeReq) or packet.haslayer(Dot11ProbeResp) or packet.haslayer(Dot11AssoReq):
28+
# Extract SSID and BSSID from the packet.
29+
ssid = packet.info.decode('utf-8', errors='ignore')
30+
bssid = packet.addr3
31+
32+
# Check if the SSID is not empty and not in the set of seen SSIDs, and if the BSSID is not the broadcast/multicast address.
33+
if ssid and ssid not in seen_ssids and bssid.lower() != 'ff:ff:ff:ff:ff:ff':
34+
# Add the SSID to the set.
35+
seen_ssids.add(ssid)
36+
# Print the identified SSID and BSSID in green.
37+
print(f"{Fore.GREEN}[+] SSID: {ssid} ----> BSSID: {bssid}")
38+
39+
40+
# Main function.
41+
def main():
42+
# Define the wireless interface.
43+
wireless_interface = 'wlan0'
44+
45+
# Set the wireless adapter to monitor mode.
46+
set_monitor_mode(wireless_interface)
47+
48+
# Print a message indicating that sniffing is starting on the specified interface in magenta.
49+
print(f"{Fore.MAGENTA}[+] Sniffing on interface: {wireless_interface}")
50+
51+
# Start sniffing Wi-Fi packets on the specified interface, calling process_wifi_packet for each packet, and disabling packet storage
52+
sniff(iface=wireless_interface, prn=process_wifi_packet, store=0)
53+
54+
55+
# Check if the script is being run as the main program.
56+
if __name__ == "__main__":
57+
# Call the main function.
58+
main()

0 commit comments

Comments
 (0)