WLAN-Pi / wlanpi-profiler

Wi-Fi client capabilities analyzer tool built for the WLAN Pi
BSD 3-Clause "New" or "Revised" License
25 stars 8 forks source link

Character Encoding Issue Prevents Profiler From Starting #75

Closed nimbo78 closed 2 years ago

nimbo78 commented 2 years ago

profiler -i wlxa09f1038f9e2 --noAP 2021-10-29 17:24:23,490 [WARNING] setup_config: can not find config at /etc/wlanpi-profiler/config.ini 2021-10-29 17:24:23,800 [WARNING] interface: wlxa09f1038f9e2 operating state is down when we expect up

Starting profiler in listen only mode:
 - Listening for association frames with wlxa09f1038f9e2 on channel 36
 - Results are saved locally and printed to screen

Instructions:
 - Associate your Wi-Fi client to any AP on channel 36
 - We should passively detect the association request

2021-10-29 17:24:23,802 [WARNING] start: beacon process not started because user requested listen only mode Process sniffer: Traceback (most recent call last): File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap self.run() File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run self._target(*self._args, *self._kwargs) File "/root/.local/pipx/venvs/profiler/lib/python3.8/site-packages/profiler/fakeap.py", line 341, in init sniff( File "/root/.local/pipx/venvs/profiler/lib/python3.8/site-packages/scapy/sendrecv.py", line 1263, in sniff sniffer._run(args, **kwargs) File "/root/.local/pipx/venvs/profiler/lib/python3.8/site-packages/scapy/sendrecv.py", line 1210, in _run session.on_packet_received(p) File "/root/.local/pipx/venvs/profiler/lib/python3.8/site-packages/scapy/sessions.py", line 108, in on_packet_received result = self.prn(pkt) File "/root/.local/pipx/venvs/profiler/lib/python3.8/site-packages/profiler/fakeap.py", line 354, in received_frame ssid = packet[Dot11Elt].info.decode() UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc6 in position 1: invalid continuation byte

nimbo78 commented 2 years ago

wlanpi@wlanpi:~$ sudo profiler -i wlan0 -c 36 --hostname_ssid --11r --11ax


Starting Profiler

SSID: wlanpi Channel: 36 Interface: wlan0 Results: http://10.25.218.78/profiler/

#################################################################################################### Instructions:

2021-10-29 15:05:06,422 [INFO] start: start interface prep... 2021-10-29 15:05:07,741 [INFO] start: done prep interface... 2021-10-29 15:05:07,742 [INFO] start: starting beacon process 2021-10-29 15:05:07,754 [INFO] start: starting sniffer process 2021-10-29 15:05:07,795 [INFO] start: starting profiler process 2021-10-29 15:05:07,967 [INFO] fakeap.py: starting beacon transmissions Process sniffer: Traceback (most recent call last): File "/usr/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap self.run() File "/usr/lib/python3.7/multiprocessing/process.py", line 99, in run self._target(*self._args, *self._kwargs) File "/opt/wlanpi/pipx/venvs/profiler2/lib/python3.7/site-packages/profiler2/fakeap.py", line 206, in init filter=self.bpf_filter, File "/opt/wlanpi/pipx/venvs/profiler2/lib/python3.7/site-packages/scapy/sendrecv.py", line 1036, in sniff sniffer._run(args, **kwargs) File "/opt/wlanpi/pipx/venvs/profiler2/lib/python3.7/site-packages/scapy/sendrecv.py", line 989, in _run session.on_packet_received(p) File "/opt/wlanpi/pipx/venvs/profiler2/lib/python3.7/site-packages/scapy/sessions.py", line 82, in on_packet_received result = self.prn(pkt) File "/opt/wlanpi/pipx/venvs/profiler2/lib/python3.7/site-packages/profiler2/fakeap.py", line 215, in received_frame ssid = packet[Dot11Elt].info.decode() UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc6 in position 1: invalid continuation byte

joshschmelzle commented 2 years ago

@nimbo78 thanks for the bug report. I've seen this error before, it looks like perhaps I need to fix something.

Could you run with the --logging debug like profiler -i wlxa09f1038f9e2 --noAP --logging debug and paste in the output here?

nimbo78 commented 2 years ago

@joshschmelzle `wlanpi@wlanpi:~$ sudo profiler -i wlan0 -c 36 --hostname_ssid --11r --11ax --logging debug [sudo] password for wlanpi: 2021-10-29 15:10:45,121 [DEBUG] start: profiler2 version 1.0.5 2021-10-29 15:10:45,122 [DEBUG] start: python platform version is 3.7.3 2021-10-29 15:10:45,123 [DEBUG] start: scapy version is 2.4.4 2021-10-29 15:10:45,123 [DEBUG] start: args: Namespace(channel=36, clean=False, config='/etc/profiler2/config.ini', files=False, files_path='/var/www/html/profiler', ft_disabled=False, ft_enabled=True, he_disabled=False, he_enabled=True, hostname_ssid=True, interface='wlan0', listen_only=False, logging='debug', no_interface_prep=False, oui_update=False, pcap_analysis=None, pytest=False, ssid=None, yes=False) 2021-10-29 15:10:45,134 [DEBUG] check_interface: wlan0 is in discovered interfaces: [['wlan0']] 2021-10-29 15:10:45,136 [DEBUG] start: config {'GENERAL': {'channel': 36, 'ssid': 'wlanpi', 'interface': 'wlan0', 'ft_disabled': False, 'he_disabled': False, 'listen_only': False, 'hostname_ssid': False, 'files_path': '/var/www/html/profiler'}} 2021-10-29 15:10:45,152 [DEBUG] start: profiler2.manager pid 9213


Starting Profiler

SSID: wlanpi Channel: 36 Interface: wlan0 Results: http://10.25.218.78/profiler/

#################################################################################################### Instructions:

2021-10-29 15:10:45,206 [INFO] start: start interface prep... 2021-10-29 15:10:45,237 [DEBUG] prep_interface: driver: mt76x2u, mac: 8c:88:2d:00:23:75 2021-10-29 15:10:45,268 [DEBUG] prep_interface: reg domain: ['country US: DFS-FCC'] 2021-10-29 15:10:46,539 [INFO] start: done prep interface... 2021-10-29 15:10:46,540 [INFO] start: starting beacon process 2021-10-29 15:10:46,554 [INFO] start: starting sniffer process 2021-10-29 15:10:46,592 [DEBUG] fakeap.py: beacon pid: 9272; parent pid: 9213 2021-10-29 15:10:46,597 [INFO] start: starting profiler process 2021-10-29 15:10:46,603 [DEBUG] fakeap.py: sniffer 9273; parent pid: 9213 2021-10-29 15:10:46,614 [DEBUG] fakeap.py: <socket.socket fd=9, family=AddressFamily.AF_PACKET, type=SocketKind.SOCK_RAW, proto=768, laddr=('wlan0', 3, 0, 803, b'\x8c\x88-\x00#u')> 2021-10-29 15:10:46,627 [DEBUG] fakeap.py: <socket.socket fd=10, family=AddressFamily.AF_PACKET, type=SocketKind.SOCK_RAW, proto=768, laddr=('wlan0', 3, 0, 803, b'\x8c\x88-\x00#u')> 2021-10-29 15:10:46,650 [DEBUG] profiler.py: profiler pid: 9274; parent pid: 9213 2021-10-29 15:10:46,767 [INFO] fakeap.py: starting beacon transmissions 2021-10-29 15:10:46,789 [DEBUG] asyncio: Using selector: EpollSelector Process sniffer: Traceback (most recent call last): File "/usr/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap self.run() File "/usr/lib/python3.7/multiprocessing/process.py", line 99, in run self._target(*self._args, *self._kwargs) File "/opt/wlanpi/pipx/venvs/profiler2/lib/python3.7/site-packages/profiler2/fakeap.py", line 206, in init filter=self.bpf_filter, File "/opt/wlanpi/pipx/venvs/profiler2/lib/python3.7/site-packages/scapy/sendrecv.py", line 1036, in sniff sniffer._run(args, **kwargs) File "/opt/wlanpi/pipx/venvs/profiler2/lib/python3.7/site-packages/scapy/sendrecv.py", line 989, in _run session.on_packet_received(p) File "/opt/wlanpi/pipx/venvs/profiler2/lib/python3.7/site-packages/scapy/sessions.py", line 82, in on_packet_received result = self.prn(pkt) File "/opt/wlanpi/pipx/venvs/profiler2/lib/python3.7/site-packages/profiler2/fakeap.py", line 215, in received_frame ssid = packet[Dot11Elt].info.decode() UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc6 in position 1: invalid continuation byte`

joshschmelzle commented 2 years ago

There is a newer version, but the code for received_frame() between 1.0.5 and 1.0.6 has minimal changes, only been improved for listen only mode. I think there might be something on the air in your environment which is breaking this code. Would you mind gathering a pcap on channel 36 and sending it to me at josh@joshschmelzle.com? It looks like this error happens as soon as you start the profiler, so I should only need a few seconds of data.

nimbo78 commented 2 years ago

@joshschmelzle I can try to collect a dump on Monday, I will not be in the office where these networks exists, earlier than Monday

joshschmelzle commented 2 years ago

I may have just been able to reproduce, I made a silly mistake earlier when trying to reproduce. I will work on a fix that hopefully you can test on Monday.

joshschmelzle commented 2 years ago

In my testing, this issue may be fixed in 88ef9b6c5fc272c2fe00cedf8d021fd7512ba290 which I authored a few hours ago.

@nimbo78 when you are able to, can you try upgrading profiler on your WLAN Pi with the instructions at https://github.com/WLAN-Pi/wlanpi-profiler/blob/main/UPGRADING_WITH_PIPX.md and report the results?

nimbo78 commented 2 years ago

@joshschmelzle after upgrade seems now it works well.

also found this:

$ sudo profiler  --oui_update
2021-11-01 08:05:32,932 [INFO] update_manuf: manuf file is located at /opt/wlanpi/pipx/venvs/profiler/lib/python3.7/site-packages/manuf/manuf
2021-11-01 08:05:32,933 [INFO] update_manuf: manuf file last modified at: Sun Oct 31 15:32:31 2021
2021-11-01 08:05:32,934 [INFO] update_manuf: running 'sudo manuf --update'
Traceback (most recent call last):
  File "/opt/wlanpi/pipx/bin/profiler", line 8, in <module>
    sys.exit(main())
  File "/opt/wlanpi/pipx/venvs/profiler/lib/python3.7/site-packages/profiler/__main__.py", line 27, in main
    manager.start(args)
  File "/opt/wlanpi/pipx/venvs/profiler/lib/python3.7/site-packages/profiler/manager.py", line 78, in start
    sys.exit(0) if helpers.update_manuf() else sys.exit(-1)
  File "/opt/wlanpi/pipx/venvs/profiler/lib/python3.7/site-packages/profiler/helpers.py", line 441, in update_manuf
    cp = run_cli_cmd(["sudo", f"{sys.prefix}/bin/manuf", "--update"])
  File "/opt/wlanpi/pipx/venvs/profiler/lib/python3.7/site-packages/profiler/helpers.py", line 52, in run_cli_cmd
    capture_output=True,
  File "/usr/lib/python3.7/subprocess.py", line 487, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['sudo', '/opt/wlanpi/pipx/venvs/profiler/bin/manuf', '--update']' returned non-zero exit status 1.
joshschmelzle commented 2 years ago

@nimbo thank you for testing and confirming the changes. I've opened a new issue for the --oui_update topic and am closing this one.