diff --git a/pwnagotchi/plugins/default/internet-connection.py b/pwnagotchi/plugins/default/internet-connection.py new file mode 100644 index 00000000..9d01fcc9 --- /dev/null +++ b/pwnagotchi/plugins/default/internet-connection.py @@ -0,0 +1,47 @@ +import logging +import pwnagotchi.ui.components as components +import pwnagotchi.ui.view as view +import pwnagotchi.ui.fonts as fonts +import pwnagotchi.plugins as plugins +import pwnagotchi +import subprocess + + +class InternetConnectionPlugin(plugins.Plugin): + __author__ = 'adi1708 made by chatGPT' + __version__ = '1.0.0' + __license__ = 'GPL3' + __description__ = 'A plugin that displays the Internet connection status on the pwnagotchi display.' + __name__ = 'InternetConnectionPlugin' + __help__ = """ + A plugin that displays the Internet connection status on the pwnagotchi display. + """ + __dependencies__ = { + 'pip': ['scapy'] + } + __defaults__ = { + 'enabled': False, + } + + def on_loaded(self): + logging.info("Internet Connection Plugin loaded.") + + def on_ui_setup(self, ui): + with ui._lock: + # add a LabeledValue element to the UI with the given label and value + # the position and font can also be specified + ui.add_element('connection_status', components.LabeledValue(color=view.BLACK, label='Internet:', value='', + position=(0, 50), label_font=fonts.Small, + text_font=fonts.Small)) + + def on_ui_update(self, ui): + with ui._lock: + # check if there is an active Internet connection + try: + # use the 'ping' command to check if we can reach a well-known website + output = subprocess.check_output(['ping', '-c', '1', 'google.com']) + # if the command was successful, it means there is an active Internet connection + ui.set('connection_status', 'Connected') + except subprocess.CalledProcessError: + # if the command failed, it means there is no active Internet connection + ui.set('connection_status', 'Disconnected') diff --git a/pwnagotchi/plugins/default/wpa-sec.py b/pwnagotchi/plugins/default/wpa-sec.py index 6b6163b1..bb65db44 100644 --- a/pwnagotchi/plugins/default/wpa-sec.py +++ b/pwnagotchi/plugins/default/wpa-sec.py @@ -43,7 +43,6 @@ class WpaSec(plugins.Plugin): except requests.exceptions.RequestException as req_e: raise req_e - def _download_from_wpasec(self, output, timeout=30): """ Downloads the results from wpasec and safes them to output @@ -65,7 +64,6 @@ class WpaSec(plugins.Plugin): except OSError as os_e: raise os_e - def on_loaded(self): """ Gets called when the plugin gets loaded