I've been building my scripts using Raspberry Pi Zero W. It's been great - but it's pretty slow.
Lucky for me, the new Raspberry Pi Zero 2 came out not too long ago.
So I took a stab at getting my OLED Python scripts from my Kali P4wnP1 ALOA to also work on my new RPi 0 2 running Raspberry Pi OS.
I thought I should make my scripts cross-distro compatible, at least (works on Kali Linux, Raspberry Pi OS).
Here's how it went:
First I booted up Raspberry Pi OS on my Pi 0 2.
Update the OS
Then I ran a sudo apt-get update and and upgrade.
Install OLED Drivers & Examples
After that, I installed the sh1106 drivers to get the OLED screen working.
Then I install luma.examples from Github.
Install NeoFetch (Optional)
I downloaded and installed NeoFetch to give us a nice hardware-inspection tool:
git clone https://github.com/dylanaraps/neofetch.git
After I launched NeoFetch, I could verify that the device I'm using is a Raspberry Pi Zero 2 with 4 CPU cores (sweet!).
Within a minute or two, I was displaying an OLED demo script.
Here's the command to run a luma.oled script on the 1.3" OLED screen for Raspberry Pi:
python3 ScriptNameHere.py -i spi --display sh1106
I'm currently at the step where I get my WiFi scripts working on Raspberry Pi OS (since there's no P4wnp1_cli to bank off of).
- Run wifi-wrap.py
- See what breaks
- Add a RaspberryPi-OS-friendly Connect to WiFi command to replace the p4wnp1_cli command
- Run wifi-wrap.py contents using crontab or another auto-start mechanism for Raspberry Pi OS
Checklist / Progress Converting P4wnSolo to RaspberryPi OS
The WiFi scan script actually only partially worked after transferring to Raspberry Pi OS.
It only would scan 1 WiFi network.
So I googled it (found this StackExchange thread) and turns out Raspberry Pi OS requires "sudo" before the command to return more than 1 WiFi network.
Here's the command that works:
sudo iwlist wlan0 scan
You can try it in RaspberryPi OS with/without the "sudo" and see the results for yourself if you'd like.
I added "sudo" before the "iwlist" command within the wifi-scan.py file and BOOM - it was now fixed.
(SEEMS TO WORK FINE) wifi-askreconnect.py
The wifi-disp.py script appears just fine, counts down from 5, and should work okay in wifi-wrap.py.
I don't want to press Reconnect right now, so the WiFi device remains open while I fix the other scripts.
(SEEMS TO WORK FINE) wifi-disp.py
The "select WiFi network" screen didn't appear until I ran wifi-askreconnect.py and selected "No". This is by design, and indicates that wifi-disp.py is working properly. Onward.
Attempting the password-entry screen resulted in an error that FontAwesome is not installed.
ModuleNotFoundError: No module named 'fontawesome'
Fortunately, this is a super simple fix. See the exact commands to install FontAwesome.
On Raspberry Pi Zero 2, both pypandoc and fontawesome install super fast.
Time to re-run wifi-pw-skiptest.py!
Doh! I didn't change the "prefix" variable I set to show the scripts where all the support TXT files are located. Here's the error:
PermissionError: [Errno 13] Permission denied: '/root/BeBoXGui/ssid.txt'
So I go in and change the "prefix" variable to '/home/blah/whatever' (I actually added a new line and commented out the old line this time):
# Init variables
prefix = '/home/pi/p4wnsolo/' #RaspberryPiOS
#prefix = '/root/BeBoXGui/' #Kali
Let's run this sh*z again.
It worked! .. kind of. Lol.
The script displays the WiFi password input screen - but apparently it thinks the name of the WiFi network is "Yes".
I can tell you for sure that there are no WiFi networks around named yes.
So for some reason, it misread a file or read the wrong file.
For now I'll assume that the back-end functionality of this script works (as far as taking the user input and sending it to a TXT file).
And we continue on!
The wifi-chek.py scripts starts off with the (expected) error that it can't find the support files.
Once again, I add a new line to tell it where the files are at on Raspberry Pi OS.
One again, I just change the "prefix" variable to reflect the support files location in RaspberryPiOS.
And it works!
All scripts seem to work fine enough to attempt running them all back-to-back using wifi-wrap.py
Time to give that a spin:
Ok, so the "reconnect" didn't work (and now I know why - because the Reconnect feature relies on the P4wnP1_cli command - which doesn't exist in Raspberry Pi OS). But the script's feature to auto-select the "Yes, Reconnect" menu option after 5 seconds worked!
So after selecting "Yes" (reconnect), the script tries the Reconnect command unsuccessfully.
This also explains why the Connect feature doesn't work (I knew these wouldn't work, but forgot to change them.
It's good to see I'm getting the errors I expected, at least, as opposed to errors I didn't expect.
The next order of business is to change/add the RaspberryPi OS equivalent of the P4wnP1_cli command to connect RPi Zero 2 to WiFi.
Note: The entire script set (especially the password-input screen) work MUCH better on Raspberry Pi Zero 2 (vs. Raspberry Pi Zero W). Crazy speed difference - it's snappy, way more responsive, and the button presses fly through menus / scrolling through the alphabet! Great success! Very nice! I like.
Works (after changing the "prefix" variable)!
The screen refreshes are also faster & more fluid.
Use the P4wnP1 install guide to install P4wnP1 on RaspberryPi OS
Add explicit UTF8 encoding at the top of each script, so people can run them on MacOS too without encoding issues.
How to update a line in a file using Python (use for updating wpa_supplicant.conf in Raspberry Pi OS)
Use a pre-made script from Github to take a PIL screenshot using Python (pyscreeze, pyscreenshot, python-mss)
Continue developing latest version of wifi-dash.py (latest version is on RPi 0 running Kali P4wnP1 ALOA)
(DONE) Make a script that creates/overwrites wpa_supplicant.conf and fills in the WiFi Network and Password for us
I made this new script that creates or opens /etc/wpa_supplicant/wpa_supplicant.conf, populates it with all the necessary text, and fills in whatever SSID and PSK you desire.
The purpose is the have P4wnSolo modify the wpa_supplicant file in Raspberry Pi OS. Then run a command to reload / reconnect the wpa_supplicant "service".
NOTE: The script must be launched using "sudo", since it accesses the system-protected wpa_supplicant.conf file.
Even though I don't think the script needs it, this guide is great for replacing a string of text in a file.
The wifi-supp.py file is nearly finished.
I need to add the following code to connect Raspberry Pi using our WiFi password and get an IP address:
sudo wpa_supplicant -B -iwlan0 -c/etc/wpa_supplicant.conf -Dwext
sudo dhclient wlan0
Example wpa_supplicant.conf File for Raspberry Pi
More To Do
Move the root folder of p4wnsolo to ~/p4wnsolo/
This will make it so Kali or RPi OS will have the same root folder.
Merge the 2 branches (RPi02 & RPiOS --- RPi0W & P4wnP1 ALOA)
- Copy dash to RPiOS
- Or copy all RPiOS files to ALOA
The result will be 1 branch:
- Works on Kali and RPiOS
- Has dashboard
Check out Starting AP and Client Mode Simultaneously
curl https://raw.githubusercontent.com/lukicdarkoo/rpi-wifi/master/configure | bash -s -- -a MyAP myappass -c WifiSSID wifipass
How to Install nmcli:
pip install nmcli