-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Uptime stops updating and APs stop scanning once bettercap fails #125
Comments
After a few days of playing around with this more, I've come to a few more conclusions which I'll summarize:
With all of this, I took another crack at seeing if I could get the device to recover from going blind after bettercap dies, and so far it has seemed promising. Before I made my latest changes, my pwnagotchi would only last around an hour or so (2 hours tops if I was lucky) before resetting due to being blind for 50 epochs. Currently though, my pwnagotchi has been running over 14 hours and is still hitting APs it comes across, though after sitting in the same spot for this long, it truly is starting to run out of APs to hit now. This is after bettercap has died and restarted numerous times as well, with only two or three instances of the AI being considered blind during this time; and even then, it was only for 1 epoch before it came back and was scanning again. I forked the project and put my changes in there to make it easier to see what I actually did: here To summarize those changes:
Outside of this change, I only made one other change to my system, which I just did for preference; I don't think it has any bearing on the actual code change. |
I want to preface this by saying I literally just started working with this a day ago. I by no means fully understand it, but felt it may have been worthwhile to report here in case it's unknown, or at the very least, someone who has more knowledge on this can see it and do what may be appropriate here.
Describe the bug
After the pwnagotchi has been running for a little while (time can vary greatly: sometimes 5 minutes, other times 15 - 30 minutes, usually the latter), the uptime on the top right stops changing.
It also appeared that once this happens, the unit stopped playing with the APs around me. I understand eventually it stops once there's no new ones around, but it seemed to be correlated so that once the uptime stopped, so did the actual AP scanning.
From my testing, I believe this is related to something going wrong with bettercap, resulting in certain processing tasks to stop functioning.
To Reproduce
Steps to reproduce the behavior (I apologize I have no real specific steps):
Expected behavior
I would expect the uptime to keep updating and the unit to keep scanning until it has truly exhausted itself off the current available APs.
Screenshots
No screenshots, but see additional context below for more info
Environment:
Additional context
Once I looked into this a little more, I started to play around with it to see if I could find what's going on (if this was intended, if I configured it wrong, etc).
I determined that the UI is getting updated by
agent.py
, so I started by added logging inagent.py
in the_update_uptime
method to just print every time it fires. I noticed that once the uptime stopped updating on the unit, that logging was no longer getting printed as well. Right after the logging stopped, there were a bunch of log messages relating to bettercap not being able to connect:This went on for a little bit and once those messages stopped, all I saw were the AI log messages about new epochs happening and it adjusting the settings, but nothing at all was actually happening between those messages being printed. It was just cycling epochs without doing anything else.
The
_update_uptime
method gets called alongside a few other methods in a separate thread in a while loop every 1 second (_fetch_stats
method), so my hunch was that maybe whatever happens with bettercap throws an exception and ends up killing the thread.I then added a try-catch around the method calls in
_fetch_stats
and let it go again. About 30 minutes in, I noticed the following in my log:The "FETCH_STATS ERR" lines are mine of course.
This went on for a little bit (15 - 20 seconds or so) where it printed these errors, but then seemed to stop as it recovered and was able to connect to bettercap again. Once that happened, my logging from
_update_uptime
resumed, and the uptime began updating once again.I believe the actual error in this scenario originates from the call to
session
in the_fetch_stats
method.Update:
While testing more with my changes mentioned above, I've noticed that it always recovers as expected for uptime, however AP scanning seems to still stop after bettercap dies for a little bit. I'm unsure exactly what is going on there as it requires more digging, but figured it would be worth mentioning since it seems like it's in the same vein and was related to my original issue. I had originally thought the change I made above fixed this as well, but that is not the case
The text was updated successfully, but these errors were encountered: