Skip to content

Instantly share code, notes, and snippets.

@wwin3286tw
Forked from GermaniumSystem/pwnagotchi notes
Created March 16, 2021 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wwin3286tw/ce4cf7a4e9023ca5c82771074314c00e to your computer and use it in GitHub Desktop.
Save wwin3286tw/ce4cf7a4e9023ca5c82771074314c00e to your computer and use it in GitHub Desktop.
How to set up a pwnagotchi in 25* simple steps.
Preface:
I have no idea if any of this is the "right" way of doing it. This is just how I got my unit working.
Good luck.
WARNING: Do not use a V1 Waveshare display module with a stock pwnagotchi! The pwnagotchi expects a V2 module, and may irreparably damage a V1 module!
A V1 display module *can* work, but you must modify `waveshare.py` and `display.py` beforehand. For the time being, this is left as an exercise for the reader.
If you have already burnt a V1 display, try disconnecting it from the Pi and leaving it overnight. This may rejuvenate the display somewhat, but it will likely still display signs of damage.
Installation:
1. `dd` Raspbian Lite to an SD card.
2. `mount` the newly created `boot` and `rootfs` volumes on your computer.
3. Copy the contents of the git repo's `sdcard` directory to their respective volumes.
- See notes 1 and 2.
4. Replace `alpha` with a new name in `/etc/hostname`, `/etc/motd`, and `/etc/hosts` to rename the pwnagotchi.
5. Unmount the `boot` and `rootfs` volumes, put the SD card in the Pi, and plug the Pi int your computer.
6. Use the networking script from the git repo to share internet to the pwnagotchi.
- Make sure NetworkManager isn't fucking up your settings. It probably is.
7. SSH into the pwnagotchi with default creds. `ssh pi@10.0.0.2` password: raspberry
8. Expand the filesystem via `raspi-config`
- `Advanced Options` -> `Expand Filesystem`
- Reboot.
9. $`sudo apt update && sudo apt upgrade && sudo apt autoremove`
10. Install the Re4son kernel. https://null-byte.wonderhowto.com/how-to/enable-monitor-mode-packet-injection-raspberry-pi-0189378/
- Follow option 2.
- Reboot.
11. Copy `<re4son-kernel-dir>/tools/mon0up` to `/usr/bin/monstart`
12. Copy `<re4son-kernel-dir>/tools/mon0down` to `/usr/bin/monstop`
13. Set up the 2.13 inch e-paper module. https://www.waveshare.com/wiki/2.13inch_e-Paper_HAT
- DO NOT install `python3-numpy` via apt! See note 7.
- `Hardware/Software setup` tab.
- You can skip the `raspi-config` step. These settings are included in the pwnagotchi repo.
14. Install Go. https://golang.org/dl/
15. Create a temporary swap file.
- #`dd if=/dev/zero of=/root/tmpswap bs=1M count=1024 status=progress`
- #`mkswap /root/tmpswap`
- #`swapon /root/tmpswap`
- DO NOT SKIP THIS. Bad things will happen! See note 3.
16. Install bettercap from source. https://www.bettercap.org/installation/
17. Install bettercap's ui caplet. https://www.bettercap.org/usage/
- #`bettercap -eval "caplets.update; ui.update; q"`
18. Create `cpuusage` and `memusage` commands. See note 5.
- #`echo -e "#\!/bin/bash\ngrep 'cpu ' /proc/stat | awk '{usage=(\$2+\$4)*100/(\$2+\$4+\$5)} END {print usage \"%\"}'" > /usr/local/bin/cpuusage`
- #`chmod +x /usr/local/bin/cpuusage`
- #`echo -e "#\!/bin/bash\nfree | awk 'FNR == 3 {print \$3/(\$3+\$4)*100 \"%\"}'" > /usr/local/bin/memusage`
- #`chmod +x /usr/local/bin/memusage`
19. Install a ton of packages.
- #`apt install screen libopenmpi-dev libopenjp2-7 fonts-dejavu libatlas-base-dev tcpdump libjasper1 libilmbase23 libopenexr23 libgstreamer1.0-0 libavcodec58 libavformat58 libswscale5 libqtgui4 libqt4-test`
20. Install pwnagotchi's python requirements.
- #`pip3 install -r /root/pwnagotchi/scripts/requirements.txt`
- mpi4py will take a looooong time to install.
21. Fix the path to bettercap in both screenrc files.
- #`sed -i 's:/usr/bin/bettercap:/usr/local/bin/bettercap:' /root/pwnagotchi/data/screenrc.{manual,auto}`
22. Ensure all screen sessions are closed.
23. Launch pwnagotchi in auto mode via `sudo -H -u root /usr/bin/screen -dmS pwnagotchi -c /root/pwnagotchi/data/screenrc.auto`
24. Connect to the screen session via `sudo screen -x` and hope for the best. The pwnagotchi should come online and begin training after a few minutes.
25. Profit?
Notes:
1. The pwnagotchi defaults to a static IP of `10.0.0.2` with a gateway of `10.0.0.1`. This can be changed via `/etc/network/interfaces`
2. The provided files for `/boot/` enable SSH, USB Ethernet, and SPI.
3. Multiple things will fail if no extra swap is added. Some of these include pip installations. When they fail, it's usually a total PITA to fix. This extra swap is no longer required after installation.
4. I'm not 100% sure I set up the e-paper module right. The pwnagotchi doesn't complain anymore, but I don't have a working e-paper module to test with yet.
5. These commands are just used to display the CPU and RAM usage in the `screen` session. You can simply remove them from the screenrc files if you don't want to add the commands.
6. The pwnagotchi has two boot modes: auto and manual. If it is connected to a computer via the data port, it will start in manual mode. If it is powered via the power port, it will start in auto mode.
7. The version of numpy provided by Debian's `python3-numpy` package is too old. Allow pip to install it via the requirements file instead.
Updates:
19-09-21:
- Removed e-paper UI steps. Apparently my copy was just missing an entire directory - probably PEBKAC.
- Removed tensorflow installation steps. Tensorflow has since been added to requirements.txt
19-09-23:
- Added V2 vs V1 display module warning.
19-09-24:
- Added note about Debian's python3-numpy` package being too old.
- Fixed monstart and monstop paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment