├── LICENSE ├── README.md ├── images ├── images └── pwnagotchi_screen0.jpg ├── pwnagotchi-plugin └── pwnaflipper.py └── pwnagotchi └── dummydisplay.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 dev-null2019 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Connect the Pwnagotchi to the Flipper Zero - work in progress! 2 | 3 | ![Pwnagotchi Screen](images/pwnagotchi_screen0.jpg) 4 | 5 | The Raspberry Pi running the Pwnagotchi is connected over UART to the Flipper Zero. 6 | 7 | Currently my Pwnagotchi plugin uses the "Esp32 Camera" app on the flipper to show the Pwnagotchi screen. You need python3-serial installed on the pwnagotchi. I will develop a separate app in the future!
8 | You need to adjust the Ui on the Pwnagotchi - i have done this with a "dummydisplay" https://github.com/jayofelony/pwnagotchi-bookworm/pull/56/commits/418dbf21e330242416fa49d6c6792393eb5566c8
9 | You can find my dummydisplay.py in the folder pwnagotchi 10 | 11 | To do: 12 | - clean up the plugin code 13 | - write instructions 14 | - interact with the Pwnagotchi 15 | - write a Flipper application 16 | -------------------------------------------------------------------------------- /images/images: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /images/pwnagotchi_screen0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dev-null2019/pwnaflipper/163849509a0ace0e8e25f75d30102c15048bb71e/images/pwnagotchi_screen0.jpg -------------------------------------------------------------------------------- /pwnagotchi-plugin/pwnaflipper.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | import pwnagotchi.plugins as plugins 4 | from pwnagotchi.ui.components import LabeledValue 5 | from pwnagotchi.ui.view import BLACK 6 | import pwnagotchi.ui.fonts as fonts 7 | 8 | import serial 9 | from PIL import Image 10 | 11 | class pwnaflipper(plugins.Plugin): 12 | __author__ = 'Stefan Lehner' 13 | __version__ = '0.0.1' 14 | __license__ = 'MIT' 15 | __description__ = 'A plugin for communicating with the Flipper Zero' 16 | 17 | def __init__(self, port: str = "/dev/serial0", baud: int = 230400): 18 | # Create a Serial object to communicate with a serial port. 19 | 20 | self._port = port 21 | self._baud = baud 22 | 23 | try: 24 | self._serialConn = serial.Serial(port, baud) 25 | except: 26 | raise "Cannot bind to port ({}) with baud ({})".format(port, baud) 27 | 28 | # called when the plugin is loaded 29 | def on_loaded(self): 30 | logging.info("Pwnaflipper plugin loaded" % self.options) 31 | 32 | # called before the plugin is unloaded 33 | def on_unload(self, ui): 34 | self._serialConn.close() 35 | 36 | 37 | def on_ui_update(self, ui): 38 | logging.info("Updating screen") 39 | # Open the image file and convert it to black and white. 40 | img = Image.open('/var/tmp/pwnagotchi/pwnagotchi.png').convert('1') 41 | 42 | flipper_y = 0 43 | packed_pixels = 0 44 | pixelcount = -15 45 | 46 | # Iterating over each pixel of the image. 47 | for y in range(64): 48 | for x in range(128): 49 | pixel = img.getpixel((x, y)) 50 | if pixelcount < 8: 51 | if pixel > 127: 52 | packed_pixels |= (1 << (7 - pixelcount)) 53 | else: 54 | packed_pixels |= (0 << (7 - pixelcount)) 55 | else: 56 | self._serialConn.write(bytes([packed_pixels])) 57 | packed_pixels = 0 58 | pixelcount = 0 59 | if pixel > 127: 60 | packed_pixels |= (1 << (7 - pixelcount)) 61 | else: 62 | packed_pixels |= (0 << (7 - pixelcount)) 63 | pixelcount += 1 64 | # Print "Y:" for every new row. 65 | self._serialConn.write(b"Y:") 66 | # Send the row identifier as a byte. 67 | self._serialConn.write(bytes([flipper_y])) 68 | flipper_y += 1 69 | self._serialConn.flush() 70 | -------------------------------------------------------------------------------- /pwnagotchi/dummydisplay.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | import pwnagotchi.ui.fonts as fonts 4 | from pwnagotchi.ui.hw.base import DisplayImpl 5 | 6 | 7 | class DummyDisplay(DisplayImpl): 8 | def __init__(self, config): 9 | super(DummyDisplay, self).__init__(config, 'dummydisplay') 10 | 11 | def layout(self): 12 | fonts.setup(8, 6, 8, 18, 18, 8) 13 | self._layout['width'] = 128 14 | self._layout['height'] = 64 15 | self._layout['face'] = (0, 20) 16 | self._layout['name'] = (5, 10) 17 | self._layout['channel'] = (0, 0) 18 | self._layout['aps'] = (20, 0) 19 | self._layout['uptime'] = (73, 0) 20 | self._layout['line1'] = [0, 9, 128, 9] 21 | self._layout['line2'] = [0, 55, 128, 55] 22 | self._layout['friend_face'] = (0, 76) 23 | self._layout['friend_name'] = (40, 78) 24 | self._layout['shakes'] = (0, 55) 25 | self._layout['mode'] = (103, 55) 26 | self._layout['status'] = { 27 | 'pos': (64, 13), 28 | 'font': fonts.status_font(fonts.Small), 29 | 'max': 12 30 | } 31 | return self._layout 32 | 33 | def initialize(self): 34 | return 35 | 36 | def render(self, canvas): 37 | return 38 | 39 | def clear(self): 40 | return 41 | --------------------------------------------------------------------------------