aluminum-ice / pwnagotchi

(⌐■_■) - Deep Reinforcement Learning instrumenting bettercap for WiFi pwning.
https://pwnagotchi.ai/
Other
769 stars 55 forks source link

[BUG] Empty environment variable PWN_RELEASE #86

Closed jalxp closed 11 months ago

jalxp commented 11 months ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Allow auto-update to run.
  2. Try to connect to web-ui

Expected behavior web-ui should be available.

Screenshots N/A

Environment (please complete the following information):

Additional context After having my Pwnagotchi automatically updated to v.1.8.2 I noticed I could no longer access my bt-tether/web ui, so I checked the output of systemctl status pwnagotchi, which gives me this:

ExecStart=/usr/bin/pwnagotchi-launcher (code=exited, status=1/FAILURE)

I then launched the launcher manually with sudo /usr/bin/pwnagotchi-launcher, where I got this error:

Traceback (most recent call last):
  File "/usr/local/bin/pwnagotchi", line 9, in <module>
    import pwnagotchi
  File "/usr/local/lib/python3.7/dist-packages/pwnagotchi/__init__.py", line 8, in <module>
    from pwnagotchi._version import __version__
  File "/usr/local/lib/python3.7/dist-packages/pwnagotchi/_version.py", line 3, in <module>
    __version__ = os.environ["PWN_RELEASE"]
  File "/usr/lib/python3.7/os.py", line 678, in __getitem__
    raise KeyError(key) from None
KeyError: 'PWN_RELEASE'

Not sure where PWN_RELEASE environment variable should be defined, but echo $PWN_RELEASE was empty. As a quick workaround, I've hardcoded the version number on the _version.py file, and all is good.

jalxp commented 11 months ago

Same as https://github.com/aluminum-ice/pwnagotchi/issues/85

jalxp commented 11 months ago

Check https://github.com/aluminum-ice/pwnagotchi/commit/1db620dac63c6fcf7bacb1c9adcb4417919ef810 & https://github.com/aluminum-ice/pwnagotchi/commit/05fef287b33d5f77a521841080c04a509051067d

We never actually define the os.environ["PWN_VERSION"] = 1.8.2 anywhere. I also noticed that the regex only worked because it was actually finding a match in the commented line of the old version of _version.py file, not sure if this was expected or not.

I.e. https://github.com/aluminum-ice/pwnagotchi/commit/05fef287b33d5f77a521841080c04a509051067d made the changes in https://github.com/aluminum-ice/pwnagotchi/commit/1db620dac63c6fcf7bacb1c9adcb4417919ef810 stop working since the comment was gone so no match on the regex expression anymore.

aluminum-ice commented 11 months ago

Ah I made changes to enable the GitHub action to fully compile the image using just the input variable versus having to update _version.py to match the action input variable. That automated the build and release. I didn't consider that this would cause a problem at run-time where 1.8.2 isn't actually defined anywhere.

Thank you for the helpful bug report and for digging into the problem. I'll fix this and release 1.8.3.

jalxp commented 11 months ago

It's a pleasure to help in the project, I already noticed I said something wrong tho! Because I confused the PWN_VERSION & PWN_RELEASE variables with each other. The Makefile change is also broken because of the removal of the comment in the _version.py file it seems.

Either way, I'm glad to help!

bicurico commented 11 months ago

Hi,

Just went through the same issue... Took a while to land here and another while to understand how to fix it.

For those as dumb as I, here is the step by step instruction:

1) ssh pi@10.0.0.2 -> password is "raspberry" 2) cd /usr/local/lib/python3.7/dist-packages/pwnagotchi 3) sudo nano _version.p 4) edit the version line to be: version = "1.8.2" 5) CTRL+X 6) YES 7) ENTER --> file is now saved 8) sudo reboot now 9) wait 1 minute or so 10) ssh pi@10.0.0.2, enter password 11) sudo reboot now 12) wait 1 minute or so --> open browser: 10.0.0.2:8080

Enjoy!

Thanks a lot for this fork!

hevnsnt commented 11 months ago

Just in case someone sees this, there are a few mistakes in bicurico's instructions above. I have fixed them down here (all credit to him though, that fixed mine)

aluminum-ice commented 11 months ago

Fixed in release v1.8.3