netspionage icon indicating copy to clipboard operation
netspionage copied to clipboard

Scanning for WiFi networks have common core issues due to hardcoded symbols

Open TotallyNotAHaxxer opened this issue 9 months ago • 0 comments

Decided to also try out the WiFi scanning option and to my suprise I was caught with an informal error when trying to start data on the interface. The following error occurred

Empty DataFrame
Columns: [SSID, RSSI, Channel, Encryption]
Index: []
Traceback (most recent call last):
  File "/home/totallynotahaxxer/netspionage/netspionage.py", line 6, in <module>
    from core import prompts
  File "/home/totallynotahaxxer/netspionage/core/__init__.py", line 1, in <module>
    from .prompts import *
  File "/home/totallynotahaxxer/netspionage/core/prompts.py", line 106, in <module>
    prompt_display()
  File "/home/totallynotahaxxer/netspionage/core/prompts.py", line 70, in prompt_display
    scanner_choice(resp, target, interface)
  File "/home/totallynotahaxxer/netspionage/core/scanner.py", line 22, in scanner_choice
    wifi_scanner()
  File "/home/totallynotahaxxer/netspionage/core/scanner.py", line 42, in wifi_scanner
    initiate_wifi_scan()
  File "/home/totallynotahaxxer/netspionage/core/scanner.py", line 104, in initiate_wifi_scan
    scapy.sniff(prn=extract_network_info, iface=interface)
  File "/usr/lib/python3/dist-packages/scapy/sendrecv.py", line 1036, in sniff
    sniffer._run(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/scapy/sendrecv.py", line 906, in _run
    sniff_sockets[L2socket(type=ETH_P_ALL, iface=iface,
  File "/usr/lib/python3/dist-packages/scapy/arch/linux.py", line 411, in __init__
Error for wireless request "Set Frequency" (8B04) :
    SET failed on device wlan0 ; No such device.
    set_promisc(self.ins, self.iface)
  File "/usr/lib/python3/dist-packages/scapy/arch/linux.py", line 147, in set_promisc
    mreq = struct.pack("IHH8s", get_if_index(iff), PACKET_MR_PROMISC, 0, b"")
  File "/usr/lib/python3/dist-packages/scapy/arch/linux.py", line 360, in get_if_index
    return int(struct.unpack("I", get_if(iff, SIOCGIFINDEX)[16:20])[0])
  File "/usr/lib/python3/dist-packages/scapy/arch/common.py", line 31, in get_if
    return ioctl(sck, cmd, struct.pack("16s16x", iff.encode("utf8")))
OSError: [Errno 19] No such device

Recreation

I figured this was just me being weird, so I decided to pop open airmon ( as instructed ) [typically I use other tools but it was just to recreate the error] and I started one of my interfaces. I then configured the script properly and got an issue still saying that I was trying to use wlan0 when the configuration file and other options all stated using the interface wlp6s0mon.

Further Fixing

I highly suggest that you do end up changing the hardcoded value that is used in the code file shown below.

scanner.py

import scapy.all as scapy
from scapy.layers.inet import IP, ICMP
from threading import Thread
import pandas
import socket
from core.print_output import print_output
import os
import time

# Wifi Scanner Configs
interface = "wlan0"
wifi_scan_timeout = 10
networks = pandas.DataFrame(columns=["BSSID", "SSID", "RSSI", "Channel", "Encryption"])
networks.set_index("BSSID", inplace=True)

def scanner_choice(choice, target, intf):
    interface = intf
    if choice == '1':
        network_scanner(target)
        return()
    elif choice == '2':
        wifi_scanner()
        return()
    elif choice == '3':
        port_scanner(target)
        return()
    else:
        exit()

# Port Scanner Configs
scan_start = 1
scan_end = 1025

Suggested Fix

When it comes to port scanning on networks, IoT devices will typically use ports like 5555 or 8888 or even other weird and wacky ports like 1532. It's highly suggested that you also allow users to customize the port range start and end. Instead of hardcoding values as executed in

scan_start = 1
scan_end = 1025

Sub Note: Port Scanning Suggestions

When you start scanning or ask for input, the suggestion or example is 192.168.1.1/24. This is a network range and as attempted in the script is not supported by the scanner itself. Currently, I run a network that uses Class A private IP addresses, so the range 10.0.0.1/24 would be my equivalent of 192.168.1.1/24. Generally speaking, this range does not work or is not supported! Definitely suggest changing recommendations!

TotallyNotAHaxxer avatar Sep 15 '23 04:09 TotallyNotAHaxxer