jayofelony / pwnagotchi

(⌐■_■) - Deep Reinforcement Learning instrumenting bettercap for WiFi pwning.
Other
867 stars 106 forks source link

Language cannot be set to Japanese. #194

Closed mendoitarou closed 1 month ago

mendoitarou commented 1 month ago

Hallo,

Running latest image v2.8.9(32bit) on Raspberry Pi zero WH with waveshare V4

Display - https://www.waveshare.com/2.13inch-e-paper-hat.htm Got a V4 sticker on the bottom

Nothing on the display.

Also, webui is not working.

I'm getting some kind of Python error, but I don't understand what it is.

Please help.

The following commands returned the following logs.

Command

sudo systemctl stop pwnagotchi && sudo pwnagotchi --debug

Log

pi@pwnagotchi:/etc/pwnagotchi $ sudo systemctl stop pwnagotchi && sudo pwnagotchi --debug
DEBUG:root:[FS] Daemonized...
[2024-03-12 01:26:47,928] [DEBUG] [FS] Daemonized...
DEBUG:root:[FS] Syncing /var/tmp/pwnagotchi -> /run/pwnagotchi/disk/pwnagotchi
[2024-03-12 01:26:47,945] [DEBUG] [FS] Syncing /var/tmp/pwnagotchi -> /run/pwnagotchi/disk/pwnagotchi
DEBUG:root:loading plugins from /usr/local/lib/python3.9/dist-packages/pwnagotchi/plugins/default - enabled: ['grid', 'auto-update', 'fix_services', 'session-stats', 'webcfg']
[2024-03-12 01:26:48,247] [DEBUG] loading plugins from /usr/local/lib/python3.9/dist-packages/pwnagotchi/plugins/default - enabled: ['grid', 'auto-update', 'fix_services', 'session-stats', 'webcfg']
DEBUG:root:loading /usr/local/lib/python3.9/dist-packages/pwnagotchi/plugins/default/auto-update.py
[2024-03-12 01:26:48,258] [DEBUG] loading /usr/local/lib/python3.9/dist-packages/pwnagotchi/plugins/default/auto-update.py
DEBUG:root:loaded plugin auto-update as <auto-update.AutoUpdate object at 0xb49d8eb0>
[2024-03-12 01:26:48,267] [DEBUG] loaded plugin auto-update as <auto-update.AutoUpdate object at 0xb49d8eb0>
DEBUG:root:loading /usr/local/lib/python3.9/dist-packages/pwnagotchi/plugins/default/webcfg.py
[2024-03-12 01:26:48,273] [DEBUG] loading /usr/local/lib/python3.9/dist-packages/pwnagotchi/plugins/default/webcfg.py
DEBUG:root:loaded plugin webcfg as <webcfg.WebConfig object at 0xb4a021c0>
[2024-03-12 01:26:48,281] [DEBUG] loaded plugin webcfg as <webcfg.WebConfig object at 0xb4a021c0>
DEBUG:root:loading /usr/local/lib/python3.9/dist-packages/pwnagotchi/plugins/default/session-stats.py
[2024-03-12 01:26:48,287] [DEBUG] loading /usr/local/lib/python3.9/dist-packages/pwnagotchi/plugins/default/session-stats.py
DEBUG:root:loaded plugin session-stats as <session-stats.SessionStats object at 0xb4a024c0>
[2024-03-12 01:26:48,298] [DEBUG] loaded plugin session-stats as <session-stats.SessionStats object at 0xb4a024c0>
DEBUG:root:loading /usr/local/lib/python3.9/dist-packages/pwnagotchi/plugins/default/fix_services.py
[2024-03-12 01:26:48,305] [DEBUG] loading /usr/local/lib/python3.9/dist-packages/pwnagotchi/plugins/default/fix_services.py
DEBUG:root:loaded plugin fix_services as <fix_services.FixServices object at 0xb4a02838>
[2024-03-12 01:26:48,334] [DEBUG] loaded plugin fix_services as <fix_services.FixServices object at 0xb4a02838>
DEBUG:root:loading /usr/local/lib/python3.9/dist-packages/pwnagotchi/plugins/default/grid.py
[2024-03-12 01:26:48,341] [DEBUG] loading /usr/local/lib/python3.9/dist-packages/pwnagotchi/plugins/default/grid.py
DEBUG:root:loaded plugin grid as <grid.Grid object at 0xb4a029b8>
[2024-03-12 01:26:48,350] [DEBUG] loaded plugin grid as <grid.Grid object at 0xb4a029b8>
DEBUG:root:loading plugins from /usr/local/share/pwnagotchi/custom-plugins/ - enabled: ['grid', 'auto-update', 'fix_services', 'session-stats', 'webcfg']
[2024-03-12 01:26:48,355] [DEBUG] loading plugins from /usr/local/share/pwnagotchi/custom-plugins/ - enabled: ['grid', 'auto-update', 'fix_services', 'session-stats', 'webcfg']
INFO:root:webcfg: Plugin loaded.
[2024-03-12 01:26:48,372] [INFO] webcfg: Plugin loaded.
INFO:root:[update] plugin loaded.
INFO:root:grid plugin loaded.
INFO:root:Session-stats plugin loaded.
INFO:root:[Fix_Services] plugin loaded.
[2024-03-12 01:26:48,377] [INFO] grid plugin loaded.
[2024-03-12 01:26:48,374] [INFO] [Fix_Services] plugin loaded.
[2024-03-12 01:26:48,380] [INFO] Session-stats plugin loaded.
[2024-03-12 01:26:48,376] [INFO] [update] plugin loaded.
Traceback (most recent call last):
  File "/usr/local/bin/pwnagotchi", line 337, in <module>
    pwnagotchi_cli()
  File "/usr/local/bin/pwnagotchi", line 316, in pwnagotchi_cli
    display = Display(config=config, state={'name': '%s>' % pwnagotchi.name()})
  File "/usr/local/lib/python3.9/dist-packages/pwnagotchi/ui/display.py", line 12, in __init__
    super(Display, self).__init__(config, hw.display_for(config), state)
  File "/usr/local/lib/python3.9/dist-packages/pwnagotchi/ui/hw/__init__.py", line 185, in display_for
    return WaveshareV3(config)
  File "/usr/local/lib/python3.9/dist-packages/pwnagotchi/ui/hw/waveshare2in13_V3.py", line 9, in __init__
    super(WaveshareV3, self).__init__(config, 'waveshare_3')
  File "/usr/local/lib/python3.9/dist-packages/pwnagotchi/ui/hw/base.py", line 28, in __init__
    'font': fonts.status_font(fonts.Medium),
  File "/usr/local/lib/python3.9/dist-packages/pwnagotchi/ui/fonts.py", line 27, in status_font
    return ImageFont.truetype(STATUS_FONT_NAME, size=old_font.size + SIZE_OFFSET)
  File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 852, in truetype
    return freetype(font)
  File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 849, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 209, in __init__
    self.font = core.getfont(
OSError: cannot open resource

Config

/etc/pwnagotchi/config.toml

main.name = "pwnagotchi"
main.lang = "jp"
ui.font.name = "fonts-japanese-gothic"
ui.font.size_offset = 1

# I don't want to regret the SSID, so I'm replacing it with a default setting
main.whitelist = [
  "EXAMPLE_NETWORK",
  "ANOTHER_EXAMPLE_NETWORK",
  "fo:od:ba:be:fo:od",
  "fo:od:ba"
]

main.plugins.grid.enabled = true
main.plugins.grid.report = true

# I don't want to regret the SSID, so I'm replacing it with a default setting
main.plugins.grid.exclude = [
  "EXAMPLE_NETWORK",
  "ANOTHER_EXAMPLE_NETWORK",
  "fo:od:ba:be:fo:od",
  "fo:od:ba"
]

ui.display.enabled = true
ui.display.type = "waveshare_4"
ui.fps = 1
ui.display.color = "black"

Thanks!

mendoitarou commented 1 month ago

Calmly looking at the Python error, I found the cause.

The cause appears to be fonts.

In order to use Japanese, I changed the font to the one described on the website I referred to, but that seems to have been a bad idea.

Since it can be used in the original pwnagotchi?, I will change the content of the issue to ‘Japanese cannot be used’.

(Maybe I will pull request the code to support Japanese).

mendoitarou commented 1 month ago

The reason it could not be set to Japanese was that the configurations were incorrect.

It is ja, not jp.

However, it does not seem to be enough.

The font does not support Japanese, so it becomes a tofu (□).

In the next step, we installed and configured a font that supports Japanese.

How to

Install the IPA font.

Download the IPA fonts from the official page.

Transfer the downloaded, zipped file to the RaspberryPi using scp or similar.

Unzip the file using the unzip command.

(Example: unzip IPAexfont00401.zip)

Move the directory created by the unzip to /usr/share/fonts/truetype/.

(Example: mv IPAexfont00401 /usr/share/fonts/truetype/)

Run the following command to update the font cache.

sudo fc-cache -fv

Specify ‘ipaexg’ as the font in config.toml. (This is called a gothic font.) (Example ui.font.name = "ipaexg")

This allows you to support the Japanese language.

supplementary information

However, some texts had not yet been translated into Japanese.

I am going to translate the texts that are not yet in Japanese and make a pull request.

(The text so far has been translated from Japanese to English using the DeepL translation tool.)

mendoitarou commented 1 month ago

Close the issue, as the problem has been self-resolved.