100 Commits

Author SHA1 Message Date
Simone Margaritelli
2d7b6b54fe releasing v1.0.1 2019-10-19 18:56:03 +02:00
Simone Margaritelli
b3aa5bc2c1 fix: bumped pwngrid to 1.8.1 2019-10-19 18:43:16 +02:00
Simone Margaritelli
10cba6872a fix: fixed travis-ci regexp 2019-10-19 17:26:03 +02:00
Simone Margaritelli
b213f9f214 releasing v1.0.0 2019-10-19 17:22:34 +02:00
evilsocket
fa72a53129 Merge pull request #330 from python273/patch-2
Fix waveshare v1 layout: status pos
2019-10-19 12:07:03 +02:00
Kirill
49f7c652c7 Fix waveshare v1 layout: status pos 2019-10-19 12:53:46 +03:00
evilsocket
9c78e16c1b Merge pull request #328 from szymex73/polish-lang
Add polish translation
2019-10-19 10:10:43 +02:00
evilsocket
22ebc09c9d Merge pull request #329 from ggiraudon/master
Adding support for Waveshare LCD Hat (ST7789 chip)
2019-10-19 10:08:41 +02:00
root
0ea67cb97f Adding support for Waveshare LCD Hat (ST7789 chip) 2019-10-19 04:49:38 +01:00
Szymon Borecki
2324423cab Add polish translation files
Signed-off-by: Szymon Borecki <szymex73@gmail.com>
2019-10-19 00:55:48 +02:00
evilsocket
be2cd8293f Merge pull request #326 from dadav/fix/gast-version
need old gast version
2019-10-18 21:23:41 +02:00
dadav
86cbe01081 need old gast version 2019-10-18 20:31:10 +02:00
Simone Margaritelli
eea4feee71 new: bump pwngrid binary to 1.8.0 2019-10-18 19:51:07 +02:00
evilsocket
cff487008c Merge pull request #325 from dadav/fix/bt-dbus-bug
Fix str comparison and add sleep
2019-10-18 19:35:27 +02:00
dadav
6cecca67a4 Fix str comparison and add sleep 2019-10-18 19:20:25 +02:00
Simone Margaritelli
fb4d46d71a fix: fixed Invalid cross-device link error 2019-10-18 17:43:45 +02:00
Simone Margaritelli
e220a869e0 new: user config is now copied from /boot/config.yml 2019-10-18 16:34:58 +02:00
Simone Margaritelli
f4a59549fa fix: update process will be reflash based for a while 2019-10-18 15:58:53 +02:00
Simone Margaritelli
a058d2e00d fix: removed deprecated script 2019-10-18 15:57:40 +02:00
Simone Margaritelli
8c73e32853 fix: handling corrupted log lines (fixes #321) 2019-10-18 10:30:27 +02:00
evilsocket
eeee4bdd3c Merge pull request #314 from ChipWolf/patch-1
Only show ui complication if you have unread pwnmail
2019-10-18 09:45:10 +02:00
evilsocket
1ddf020ba8 Merge pull request #318 from colossus700/colossus700-patch-1
Fix LM75B import error for Papirus Screens
2019-10-18 09:44:32 +02:00
evilsocket
e992834b37 Merge pull request #316 from spees/master
Minor fixes to the UI to prevent overlap
2019-10-18 09:43:59 +02:00
colossus700
55bac8a8b9 Update epd.py
Fixed LM75B import error
2019-10-17 19:03:04 -04:00
Chip Wolf ‮
61a6b77a52 Only show ui complication if you have unread pwnmail 2019-10-17 23:09:49 +01:00
spees
0aa4f95235 Made the memtemp plugin usable and added to default.yml
Signed-off-by: spees <speeskonijn@gmail.com>
2019-10-17 23:55:11 +02:00
Simone Margaritelli
95b871aade releasing v1.0.0RC5 2019-10-17 22:02:53 +02:00
Simone Margaritelli
7b05f10c6f pwngrid 1.7.6 2019-10-17 21:56:12 +02:00
spees
299bd9a5ca Moved APs status to prevent overlap with channel status on inky screens
Signed-off-by: spees <speeskonijn@gmail.com>
2019-10-17 20:10:43 +02:00
spees
10688ca7b0 Moved BT status to prevent overlap with last recon total APS
Signed-off-by: spees <speeskonijn@gmail.com>
2019-10-17 20:07:56 +02:00
evilsocket
6b1bca7cb2 Merge pull request #312 from wytshadow/master
added jp translation
2019-10-17 14:01:18 +02:00
Simone Margaritelli
79688305fd fix: fixed reboot procedure (fixes #313) 2019-10-17 13:42:05 +02:00
evilsocket
13b1fb6d14 Merge pull request #298 from dadav/fix/cool-smilie
Fix the weird looking COOL-face
2019-10-17 13:38:43 +02:00
dadav
8a1aad1a99 changed left and right faces 2019-10-17 13:05:47 +02:00
wytshadow
aeb6536959 added jp translation 2019-10-16 15:09:46 -06:00
Simone Margaritelli
970b6922b7 fix: if -> elif typo (fixes #310) 2019-10-16 17:20:48 +02:00
Simone Margaritelli
18dd71b989 💔 2019-10-16 16:37:42 +02:00
evilsocket
256ccab05c Merge pull request #306 from ciara1234/irish-lang
Adding Irish translations
2019-10-16 14:34:49 +02:00
evilsocket
0aa80d2307 Merge pull request #307 from dadav/fix/improve_bt
Fix/improve bt
2019-10-16 14:34:30 +02:00
dadav
5987f93009 Refracture code 2019-10-16 09:41:47 +02:00
dadav
ebeb22081b Improve logging and add already_connected check 2019-10-16 09:28:29 +02:00
Ciara Brennan
f97b106858 Irish translations
Signed-off-by: Ciara Brennan <ciara.brennan@gmail.com>
2019-10-15 23:52:08 +01:00
evilsocket
c449c77ef9 Merge pull request #304 from deveth0/master
Print effective merged config
2019-10-15 18:17:38 +02:00
amuthmann
a05ea2f48a Merge branch 'master' of github.com:deveth0/pwnagotchi 2019-10-15 17:47:38 +02:00
amuthmann
beb2fedf02 Print effective merged config
Signed-off-by: deveth0 <github@dev-eth0.de>
2019-10-15 17:47:08 +02:00
amuthmann
1936c309f0 Print effective merge config 2019-10-15 17:43:32 +02:00
Simone Margaritelli
ee3fb285be misc: small fix or general refactoring i did not bother commenting 2019-10-15 13:19:30 +02:00
Simone Margaritelli
aa60a369a9 fix: fix for bug mentioned in 13d68c7c24\#commitcomment-35504643 2019-10-15 13:17:26 +02:00
Simone Margaritelli
0e9f9c0f2e fix: fixed typos due to old configuration paths (fixes #300) 2019-10-15 12:05:06 +02:00
Simone Margaritelli
6645c80db3 misc: small fix or general refactoring i did not bother commenting 2019-10-15 11:56:49 +02:00
Simone Margaritelli
13d68c7c24 misc: attempted refactoring of the display support in something less shitty 2019-10-15 11:50:09 +02:00
Simone Margaritelli
df33d20cb2 fix: refactored oledhat layout 2019-10-15 10:45:03 +02:00
Simone Margaritelli
f3eb208c6a fix: refactored papirus layout 2019-10-15 10:42:08 +02:00
Simone Margaritelli
ae5ca2a05e fix: refactored inkyphat layout 2019-10-15 10:37:40 +02:00
evilsocket
a9b9c6677e Merge pull request #296 from systemik/master
Fix for layout.py to handle oledhat
2019-10-15 10:25:43 +02:00
dadav
f85d80d3fd Use the coolest face for the cool emotion 2019-10-14 22:43:12 +02:00
Administrator
4be54cf3ee Fix layout issues 2019-10-14 21:08:07 +02:00
Administrator
c8953d4654 Fix few errors with OledHat 2019-10-14 20:41:41 +02:00
Simone Margaritelli
26ff5c95f2 Merge branch 'master' of github.com:evilsocket/pwnagotchi 2019-10-14 20:20:07 +02:00
Simone Margaritelli
2f0f0edab0 pwngrid 1.7.5 2019-10-14 20:20:00 +02:00
evilsocket
b81c80cf99 Merge pull request #294 from dadav/fix/wpa-sec-cookie
Fix/wpa sec cookie
2019-10-14 20:05:44 +02:00
dadav
baf20a9ac8 Fix url 2019-10-14 19:58:47 +02:00
dadav
280ca22261 Change header to cookie 2019-10-14 19:57:04 +02:00
Simone Margaritelli
277dbd5a16 misc: small fix or general refactoring i did not bother commenting 2019-10-14 19:48:33 +02:00
Simone Margaritelli
5b29f65042 misc: small fix or general refactoring i did not bother commenting 2019-10-14 19:35:49 +02:00
Simone Margaritelli
9f66d7ab96 misc: small fix or general refactoring i did not bother commenting 2019-10-14 19:32:40 +02:00
Simone Margaritelli
9625cf1122 misc: small fix or general refactoring i did not bother commenting 2019-10-14 19:26:23 +02:00
Simone Margaritelli
6b42e48dff misc: refactored ui layout code 2019-10-14 19:21:46 +02:00
evilsocket
d814de75ab Merge pull request #292 from systemik/master
Add support for waveshare oledhat display.
2019-10-14 18:46:28 +02:00
evilsocket
35b442f941 Merge pull request #293 from pcotret/patch-1
Added missing words for the french PO file
2019-10-14 18:42:35 +02:00
Pascal Cotret
0f2ad47c17 Added missing words for the french PO file 2019-10-14 18:25:22 +02:00
Administrator
748dbea13e Fix bug. Line misplaced in the code to init the display. 2019-10-14 18:19:53 +02:00
Administrator
b66f1b66e5 Add oledhat in the default.yml options for ui 2019-10-14 16:41:09 +02:00
Simone Margaritelli
1642663c84 fix: added explicit path for pwngrid client token 2019-10-14 16:40:29 +02:00
Administrator
54a8fd81a5 Initial commit Waveshare OledHat
Add support for Waveshare Oled Hat
Change view.py to have more variable to support more types of screen in the future
2019-10-14 16:38:57 +02:00
Simone Margaritelli
2fe7ac0a71 misc: small fix or general refactoring i did not bother commenting 2019-10-14 16:18:33 +02:00
Simone Margaritelli
4b563398f4 misc: small fix or general refactoring i did not bother commenting 2019-10-14 16:18:07 +02:00
Simone Margaritelli
84be7c0d34 misc: small fix or general refactoring i did not bother commenting 2019-10-14 16:16:59 +02:00
Simone Margaritelli
82bf9b9853 misc: small fix or general refactoring i did not bother commenting 2019-10-14 14:38:24 +02:00
evilsocket
d9d38e7a1e Merge pull request #290 from beliver17/patch-1
Update README.md
2019-10-14 13:17:26 +02:00
beliver17
5b78a13e95 Update README.md 2019-10-14 16:00:05 +05:30
Simone Margaritelli
a8a0f842a3 new: saving unit's fingerprint to /etc/pwnagotchi/fingerprint for easy access 2019-10-14 11:36:42 +02:00
evilsocket
f8a28d375b Merge pull request #276 from dipsylala/master
Inkyphat subclass to incorporate timing changes.
2019-10-14 10:43:39 +02:00
evilsocket
cfa8a02abc Merge pull request #279 from dadav/feature/auto-pairing-bt
Add auto-pair and internet-sharing
2019-10-14 10:42:34 +02:00
evilsocket
e32be6ff27 Merge pull request #285 from cdiemel/plugin.on-callback
on_unfiltered_ap_list() for plugins
2019-10-14 10:42:11 +02:00
evilsocket
ab74395602 Merge pull request #288 from charlesrocket/RU
Fix RU
2019-10-14 10:39:51 +02:00
evilsocket
b7a806c8ad Merge pull request #282 from dadav/feature/migrate-to-statusfile
Migrate to statusfile
2019-10-14 10:38:46 +02:00
-k
e146a87b44 RU locale edits 2019-10-13 22:20:53 -07:00
Casey Diemel
dfb4bcaf21 added on_loaded function
Signed-off-by: Casey Diemel <diemelcw@gmail.com>
2019-10-13 18:13:25 -04:00
Casey Diemel
9aca3a3a5b added example for testing
Signed-off-by: Casey Diemel <diemelcw@gmail.com>
2019-10-13 17:53:18 -04:00
Casey Diemel
d15f8c18b5 updated function call
Signed-off-by: Casey Diemel <diemelcw@gmail.com>
2019-10-13 17:52:41 -04:00
dadav
87a3fb5f0c Migrate to statusfile 2019-10-13 22:39:03 +02:00
dadav
8b366ca736 Add auto-pair and internet-sharing 2019-10-13 21:26:53 +02:00
Casey Diemel
2bbcc36f2a added unfiltered ap list call back
Signed-off-by: Casey Diemel <diemelcw@gmail.com>
2019-10-13 13:57:45 -04:00
Casey Diemel
308746a7de removed plugin.on() return value as is not needed
Signed-off-by: Casey Diemel <diemelcw@gmail.com>
2019-10-13 13:54:22 -04:00
Casey Diemel
d648f7cdf5 Merge branch 'master' into plugin.on-callback
bring the current branch up to evilsocket/pwnagotchi
Signed Off: Casey Diemel <diemelcw@gmail.com>
2019-10-13 13:45:11 -04:00
Dispsylala
5a53670133 Merge remote-tracking branch 'upstream/master' 2019-10-13 18:16:10 +01:00
Dispsylala
e9899dda94 Overrides default inky library to change timings on black rendering 2019-10-13 17:40:58 +01:00
Dispsylala
f0c5ad4b74 Overrides default inky library to change timings on black rendering 2019-10-13 17:18:27 +01:00
Casey Diemel
3773f96901 Updated on() to allow return values
modified line 21

added line 22-23

Signed-off-by: Casey Diemel <diemelcw@gmail.com>
2019-10-12 16:49:52 -04:00
68 changed files with 2096 additions and 940 deletions

View File

@@ -3,7 +3,6 @@ maintainers:
- caquino
- dadav
- justin-p
- hexwaxwing
features:
- comments

View File

@@ -20,7 +20,7 @@ deploy:
repo: evilsocket/pwnagotchi
branches:
only:
- "/^v[0-9]+\\.[0-9]+\\.[0-9]+[A-Za-z0-9]+?$/"
- "/^v[0-9]+\\.[0-9]+\\.[0-9]+[A-Za-z0-9]*$/"
cache:
apt: true
before_script:

View File

@@ -1,7 +1,7 @@
PWN_HOSTNAME=pwnagotchi
PWN_VERSION=master
all: install image clean
all: clean install image
install:
curl https://releases.hashicorp.com/packer/1.3.5/packer_1.3.5_linux_amd64.zip -o /tmp/packer.zip

View File

@@ -11,30 +11,20 @@
</p>
</p>
[Pwnagotchi](https://twitter.com/pwnagotchi) is an [A2C](https://hackernoon.com/intuitive-rl-intro-to-advantage-actor-critic-a2c-4ff545978752)-based "AI" leveraging [bettercap](https://www.bettercap.org/) that learns from its surrounding WiFi environment in order to maximize the crackable WPA key material it captures (either passively, or by performing deauthentication and association attacks). This material is collected as PCAP files containing any form of handshake supported by [hashcat](https://hashcat.net/hashcat/), including [PMKIDs](https://www.evilsocket.net/2019/02/13/Pwning-WiFi-networks-with-bettercap-and-the-PMKID-client-less-attack/),
[Pwnagotchi](https://pwnagotchi.ai/) is an [A2C](https://hackernoon.com/intuitive-rl-intro-to-advantage-actor-critic-a2c-4ff545978752)-based "AI" leveraging [bettercap](https://www.bettercap.org/) that learns from its surrounding WiFi environment to maximize the crackable WPA key material it captures (either passively, or by performing authentication and association attacks). This material is collected as PCAP files containing any form of handshake supported by [hashcat](https://hashcat.net/hashcat/), including [PMKIDs](https://www.evilsocket.net/2019/02/13/Pwning-WiFi-networks-with-bettercap-and-the-PMKID-client-less-attack/),
full and half WPA handshakes.
![ui](https://i.imgur.com/c7xh4hN.png)
Instead of merely playing [Super Mario or Atari games](https://becominghuman.ai/getting-mario-back-into-the-gym-setting-up-super-mario-bros-in-openais-gym-8e39a96c1e41?gi=c4b66c3d5ced) like most reinforcement learning based "AI" *(yawn)*, Pwnagotchi tunes [its own parameters](https://github.com/evilsocket/pwnagotchi/blob/master/pwnagotchi/defaults.yml#L73) over time to **get better at pwning WiFi things** in the environments you expose it to.
Instead of merely playing [Super Mario or Atari games](https://becominghuman.ai/getting-mario-back-into-the-gym-setting-up-super-mario-bros-in-openais-gym-8e39a96c1e41?gi=c4b66c3d5ced) like most reinforcement learning-based "AI" *(yawn)*, Pwnagotchi tunes [its parameters](https://github.com/evilsocket/pwnagotchi/blob/master/pwnagotchi/defaults.yml#L73) over time to **get better at pwning WiFi things to** in the environments you expose it to.
More specifically, Pwnagotchi is using an [LSTM with MLP feature extractor](https://stable-baselines.readthedocs.io/en/master/modules/policies.html#stable_baselines.common.policies.MlpLstmPolicy) as its policy network for the [A2C agent](https://stable-baselines.readthedocs.io/en/master/modules/a2c.html). If you're unfamiliar with A2C, here is [a very good introductory explanation](https://hackernoon.com/intuitive-rl-intro-to-advantage-actor-critic-a2c-4ff545978752) (in comic form!) of the basic principles behind how Pwnagotchi learns. (You can read more about how Pwnagotchi learns in the [Usage](https://www.pwnagotchi.ai/usage/#training-the-ai) doc.)
**Keep in mind:** Unlike the usual RL simulations, Pwnagotchi actually learns over time. Time for a Pwnagotchi is measured in epochs; a single epoch can last from a few seconds to minutes, depending on how many access points and client stations are visible. Do not expect your Pwnagotchi to perform amazingly well at the very beginning, as it will be [exploring](https://hackernoon.com/intuitive-rl-intro-to-advantage-actor-critic-a2c-4ff545978752) several combinations of [key parameters](https://www.pwnagotchi.ai/usage/#training-the-ai) to determine ideal adjustments for pwning the particular environment you are exposing it to during its beginning epochs ... but **definitely listen to your Pwnagotchi when it tells you it's bored!** Bring it into novel WiFi environments with you and have it observe new networks and capture new handshakes—and you'll see. :)
**Keep in mind:** Unlike the usual RL simulations, Pwnagotchi learns over time. Time for a Pwnagotchi is measured in epochs; a single epoch can last from a few seconds to minutes, depending on how many access points and client stations are visible. Do not expect your Pwnagotchi to perform amazingly well at the very beginning, as it will be [exploring](https://hackernoon.com/intuitive-rl-intro-to-advantage-actor-critic-a2c-4ff545978752) several combinations of [key parameters](https://www.pwnagotchi.ai/usage/#training-the-ai) to determine ideal adjustments for pwning the particular environment you are exposing it to during its beginning epochs ... but ** listen to your Pwnagotchi when it tells you it's boring!** Bring it into novel WiFi environments with you and have it observe new networks and capture new handshakes—and you'll see. :)
Multiple units within close physical proximity can "talk" to each other, advertising their own presence to each other by broadcasting custom information elements using a parasite protocol I've built on top of the existing dot11 standard. Over time, two or more units trained together will learn to cooperate upon detecting each other's presence by dividing the available channels among them for optimal pwnage.
## Why does Pwnagotchi exist?
For hackers to learn reinforcement learning, WiFi networking, and have an excuse to get out for more walks. Also? **It's cute as f---**.
**In case you're curious about the name:** *Pwnagotchi* is a portmanteau of *pwn* (which we shouldn't have to explain if you are interested in this project :kissing_heart:) and *-gotchi*. It is a nostalgic reference made in homage to a very popular children's toy from the 1990s called the [Tamagotchi](https://en.wikipedia.org/wiki/Tamagotchi). The Tamagotchi (たまごっち, derived from *tamago* (たまご) "egg" + *uotchi* (ウオッチ) "watch") is a cultural touchstone for many Millennial hackers as a formative electronic toy from our collective childhoods. Were you lucky enough to possess a Tamagotchi as a kid? Well, with your Pwnagotchi, you too can enjoy the nostalgic delight of being strangely emotionally attached to a handheld automata *yet again!* Except, this time around...you get to #HackThePlanet. >:D
Multiple units within close physical proximity can "talk" to each other, advertising their presence to each other by broadcasting custom information elements using a parasite protocol I've built on top of the existing dot11 standard. Over time, two or more units trained together will learn to cooperate upon detecting each other's presence by dividing the available channels among them for optimal pwnage.
## Documentation
---
:warning: **THE FOLLOWING DOCUMENTATION IS BEING PREPARED FOR THE v1.0 RELEASE OF PWNAGOTCHI. Since this effort is an active (and unstable) work-in-progress, the docs displayed here are in various stages of [in]completion. There will be dead links and placeholders throughout as we are still building things out in preparation for the v1.0 release.** :warning:
**IMPORTANT NOTE:** If you'd like to alphatest Pwnagotchi and are trying to get yours up and running while the project is still very unstable, please understand that the documentation here may not reflect what is currently implemented. If you have questions, ask the community of alphatesters in the [official Pwnagotchi Slack](https://pwnagotchi.herokuapp.com). The Pwnagotchi dev team is entirely focused on the v1.0 release and will NOT be providing support for alphatesters trying to get their Pwnagotchis working in the meantime. All technical support during this period of development is being provided by your fellow alphatesters in the Slack (thanks, everybody! :heart:).
https://www.pwnagotchi.ai

View File

@@ -37,7 +37,7 @@ if __name__ == '__main__':
keypair = KeyPair(view=display)
agent = Agent(view=display, config=config, keypair=keypair)
logging.info("%s@%s (v%s)" % (pwnagotchi.name(), agent._keypair.fingerprint, pwnagotchi.version))
logging.info("%s@%s (v%s)" % (pwnagotchi.name(), agent.fingerprint(), pwnagotchi.version))
for _, plugin in plugins.loaded.items():
logging.debug("plugin '%s' v%s loaded from %s" % (plugin.__name__, plugin.__version__, plugin.__file__))

View File

@@ -34,7 +34,7 @@
url: "https://github.com/bettercap/bettercap/releases/download/v2.25/bettercap_linux_armv6l_2.25.zip"
ui: "https://github.com/bettercap/ui/releases/download/v1.3.0/ui.zip"
pwngrid:
url: "https://github.com/evilsocket/pwngrid/releases/download/v1.7.3/pwngrid_linux_armv6l_1.7.3.zip"
url: "https://github.com/evilsocket/pwngrid/releases/download/v1.8.1/pwngrid_linux_armhf_v1.8.1.zip"
apt:
hold:
- firmware-atheros
@@ -379,7 +379,7 @@
copy:
dest: /etc/pwnagotchi/config.yml
content: |
# Add your configuration overrides on this file any configuration changes done to defaults.yml will be lost!
# Add your configuration overrides on this file any configuration changes done to default.yml will be lost!
# Example:
#
# ui:
@@ -461,7 +461,7 @@
If you want to change my configuration, use /etc/pwnagotchi/config.yml
All the configuration options can be found on /etc/pwnagotchi/defaults.yml,
All the configuration options can be found on /etc/pwnagotchi/default.yml,
but don't change this file because I will recreate it every time I'm restarted!
I'm managed by systemd. Here are some basic commands.
@@ -502,7 +502,7 @@
[Service]
Type=simple
PermissionsStartOnly=true
ExecStart=/usr/bin/pwngrid -keys /etc/pwnagotchi -address 127.0.0.1:8666 -wait -log /var/log/pwngrid-peer.log -iface mon0
ExecStart=/usr/bin/pwngrid -keys /etc/pwnagotchi -address 127.0.0.1:8666 -client-token /root/.api-enrollment.json -wait -log /var/log/pwngrid-peer.log -iface mon0
Restart=always
RestartSec=30

View File

@@ -4,7 +4,7 @@ import logging
import time
import pwnagotchi.ui.view as view
version = '1.0.0RC4'
version = '1.0.1'
_name = None
@@ -65,3 +65,9 @@ def shutdown():
time.sleep(5)
os.system("sync")
os.system("halt")
def reboot():
logging.warning("rebooting ...")
os.system("sync")
os.system("shutdown -r now")

View File

@@ -190,6 +190,7 @@ class Agent(Client, AsyncAdvertiser, AsyncTrainer):
aps = []
try:
s = self.session()
plugins.on("unfiltered_ap_list", self, s['wifi']['aps'])
for ap in s['wifi']['aps']:
if ap['hostname'] not in whitelist:
if self._filter_included(ap):
@@ -480,9 +481,7 @@ class Agent(Client, AsyncAdvertiser, AsyncTrainer):
def _reboot(self):
self.set_rebooting()
self._save_recovery_data()
logging.warning("rebooting the system ...")
os.system("/usr/bin/sync")
os.system("/usr/sbin/shutdown -r now")
pwnagotchi.reboot()
def next_epoch(self):
was_stale = self.is_stale()

View File

@@ -17,10 +17,6 @@ main:
report: false # don't report pwned networks by default!
exclude: # do not report the following networks (accepts both ESSIDs and BSSIDs)
- YourHomeNetworkHere
auto-update:
enabled: false
system: false # set to true to also enable system updates via apt
interval: 1 # every day
auto-backup:
enabled: false
interval: 1 # every day
@@ -73,6 +69,9 @@ main:
ip: '192.168.44.44' # ip from which your pwnagotchi should be reachable
netmask: 24
interval: 1 # check every x minutes for device
share_internet: false
memtemp: # Display memory usage and cpu temperature on screen
enabled: false
# monitor interface to use
iface: mon0
# command to run to bring the mon interface up in case it's not up already
@@ -168,7 +167,7 @@ ui:
display:
enabled: true
rotation: 180
# Possible options inkyphat/inky, papirus/papi, waveshare_1/ws_1 or waveshare_2/ws_2
# Possible options inkyphat/inky, papirus/papi, waveshare_1/ws_1 or waveshare_2/ws_2, oledhat
type: 'waveshare_2'
# Possible options red/yellow/black (black used for monocromatic displays)
color: 'black'

View File

@@ -16,6 +16,7 @@ class KeyPair(object):
self.priv_key = None
self.pub_path = "%s.pub" % self.priv_path
self.pub_key = None
self.fingerprint_path = os.path.join(path, "fingerprint")
self._view = view
if not os.path.exists(self.path):
@@ -46,6 +47,9 @@ class KeyPair(object):
self.pub_key_pem_b64 = base64.b64encode(pem_ascii).decode("ascii")
self.fingerprint = hashlib.sha256(pem_ascii).hexdigest()
with open(self.fingerprint_path, 'w+t') as fp:
fp.write(self.fingerprint)
# no exception, keys loaded correctly.
self._view.on_starting()
return

View File

@@ -192,19 +192,19 @@ msgstr ""
"#pwnlog #pwnlife #hacktheplanet #skynet"
msgid "hours"
msgstr ""
msgstr "heures"
msgid "minutes"
msgstr ""
msgstr "minutes"
msgid "seconds"
msgstr ""
msgstr "secondes"
msgid "hour"
msgstr ""
msgstr "heure"
msgid "minute"
msgstr ""
msgstr "minute"
msgid "second"
msgstr ""
msgstr "seconde"

Binary file not shown.

View File

@@ -0,0 +1,215 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-10-09 17:42+0200\n"
"PO-Revision-Date: 2019-10-15 23:46+0100\n"
"Language: ga\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Last-Translator: \n"
"Language-Team: \n"
"X-Generator: Poedit 2.2.4\n"
msgid "ZzzzZZzzzzZzzz"
msgstr ""
msgid "Hi, I'm Pwnagotchi! Starting ..."
msgstr "Dia Duit, Pwnagotchi is ainm dom! Ag tosú ..."
msgid "New day, new hunt, new pwns!"
msgstr "Lá nua, seilg nua, pwns nua!"
msgid "Hack the Planet!"
msgstr "Haic An Phláinéid!"
msgid "AI ready."
msgstr "AI réidh."
msgid "The neural network is ready."
msgstr "Tá an líonra néarach réidh."
#, python-brace-format
msgid "Hey, channel {channel} is free! Your AP will say thanks."
msgstr "Hé, tá cainéal {channel} ar fail! Déarfaidh do PR go raibh maith agat."
msgid "I'm bored ..."
msgstr "Tá leadrán orm ..."
msgid "Let's go for a walk!"
msgstr "Siúil liom, le do thoil!"
msgid "This is the best day of my life!"
msgstr "Tá sé an lá is fearr i mo shaol!"
msgid "Shitty day :/"
msgstr "Tá lá damanta agam :/"
msgid "I'm extremely bored ..."
msgstr "Tá mé ag dul as mo mheabhair le leadrán ..."
msgid "I'm very sad ..."
msgstr "Ta brón an domhain orm ..."
msgid "I'm sad"
msgstr "Tá brón orm"
msgid "I'm living the life!"
msgstr "Tá an saol ar a thoil agam!"
msgid "I pwn therefore I am."
msgstr "Déanaim pwnáil, dá bhrí sin táim ann."
msgid "So many networks!!!"
msgstr "Gréasáin - Tá an iliomad acu ann!!!"
msgid "I'm having so much fun!"
msgstr "Tá craic iontach agam!"
msgid "My crime is that of curiosity ..."
msgstr "Ní haon pheaca é bheith fiosrach ..."
#, python-brace-format
msgid "Hello {name}! Nice to meet you. {name}"
msgstr "Dia Duit {name}! Is deas bualadh leat. {name}"
#, python-brace-format
msgid "Unit {name} is nearby! {name}"
msgstr "Aonad {name} in aice láimhe! {name}"
#, python-brace-format
msgid "Uhm ... goodbye {name}"
msgstr "Uhm... slán leat {name}"
#, python-brace-format
msgid "{name} is gone ..."
msgstr "Tá {name} imithe ..."
#, python-brace-format
msgid "Whoops ... {name} is gone."
msgstr "Hoips … Tá {name} imithe."
#, python-brace-format
msgid "{name} missed!"
msgstr "Chaill mé ar {name}!"
msgid "Missed!"
msgstr "Chaill mé é sin !"
msgid "Nobody wants to play with me ..."
msgstr "Níl aon duine ag iarraidh imirt liom ..."
msgid "I feel so alone ..."
msgstr "Tá uaigneas an domhain orm ..."
msgid "Where's everybody?!"
msgstr "Cá bhfuil gach duine?!"
#, python-brace-format
msgid "Napping for {secs}s ..."
msgstr "Néal a chodladh ar {secs}s ..."
msgid "Zzzzz"
msgstr ""
#, python-brace-format
msgid "ZzzZzzz ({secs}s)"
msgstr ""
msgid "Good night."
msgstr "Oíche mhaith."
msgid "Zzz"
msgstr ""
#, python-brace-format
msgid "Waiting for {secs}s ..."
msgstr "Fan ar {secs}s ..."
#, python-brace-format
msgid "Looking around ({secs}s)"
msgstr "Ag amharc uaim ar ({secs}s)"
#, python-brace-format
msgid "Hey {what} let's be friends!"
msgstr "Hé {what} déanaimis síocháin!"
#, python-brace-format
msgid "Associating to {what}"
msgstr "Ag coinneáil le {what}"
#, python-brace-format
msgid "Yo {what}!"
msgstr "Hé {what}!"
#, python-brace-format
msgid "Just decided that {mac} needs no WiFi!"
msgstr "Tá cinneadh déanta agam. Níl {mac} sin de dhíth air WiFi!"
#, python-brace-format
msgid "Deauthenticating {mac}"
msgstr "Bain fíordheimhniúde {mac}"
#, python-brace-format
msgid "Kickbanning {mac}!"
msgstr "Chiceáil mé agus cosc mé ar {mac}!"
#, python-brace-format
msgid "Cool, we got {num} new handshake{plural}!"
msgstr "Go hiontach, fuaireamar {num} handshake{plural}!"
msgid "Ops, something went wrong ... Rebooting ..."
msgstr "Hoips...Tháinig ainghléas éigin..."
#, python-brace-format
msgid "Kicked {num} stations\n"
msgstr "{num} stáisiún kick\n"
#, python-brace-format
msgid "Made {num} new friends\n"
msgstr "Rinne mé {num} cairde nua\n"
#, python-brace-format
msgid "Got {num} handshakes\n"
msgstr "Fuair me {num} cumarsáid thionscantach\n"
msgid "Met 1 peer"
msgstr "Bhuail mé piara amháin"
#, python-brace-format
msgid "Met {num} peers"
msgstr "Bhuail me {num} piara"
#, python-brace-format
msgid ""
"I've been pwning for {duration} and kicked {deauthed} clients! I've also met "
"{associated} new friends and ate {handshakes} handshakes! #pwnagotchi "
"#pwnlog #pwnlife #hacktheplanet #skynet"
msgstr ""
"Bhí me ag pwnáil ar {duration} agus chiceáil me ar {deauthed} cliaint! Chomh "
"maith, bhuail me {associated} cairde nua and d'ith mé {handshakes}! "
"#pwnagotchi #pwnlog #pwnlife #hacktheplanet #skynet"
msgid "hours"
msgstr "uair on chloig"
msgid "minutes"
msgstr "nóiméad"
msgid "seconds"
msgstr "soicind"
msgid "hour"
msgstr "uair an chloig"
msgid "minute"
msgstr "nóiméad"
msgid "second"
msgstr "soicind"

Binary file not shown.

View File

@@ -0,0 +1,212 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR 24534649+wytshadow@users.noreply.github.com, 2019.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: 0.0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-10-16 15:05+0200\n"
"PO-Revision-Date: 2019-10-16 15:05+0200\n"
"Last-Translator: wytshadow <24534649+wytshadow@users.noreply.github.com>\n"
"Language-Team: pwnagotchi <24534649+wytshadow@users.noreply.github.com>\n"
"Language: jp\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "ZzzzZZzzzzZzzz"
msgstr "すやすや〜"
msgid "Hi, I'm Pwnagotchi! Starting ..."
msgstr "こんにちは、ポウナゴッチです!始めている。。。"
msgid "New day, new hunt, new pwns!"
msgstr ""
msgid "Hack the Planet!"
msgstr "ハックザプラネット!"
msgid "AI ready."
msgstr "人工知能の準備ができました。"
msgid "The neural network is ready."
msgstr "ニューラルネットワークの準備ができました。"
#, python-brace-format
msgid "Hey, channel {channel} is free! Your AP will say thanks."
msgstr "ねえ、チャンネル{channel}は無料です! キミのAPは感謝を言います。"
msgid "I'm bored ..."
msgstr "退屈です。。。"
msgid "Let's go for a walk!"
msgstr "散歩に行きましょう!"
msgid "This is the best day of my life!"
msgstr "今日は私の人生で最高の日です!"
msgid "Shitty day :/"
msgstr ""
msgid "I'm extremely bored ..."
msgstr "とても退屈です。"
msgid "I'm very sad ..."
msgstr "とても悲しいです。。。"
msgid "I'm sad"
msgstr "悲しいです。"
msgid "I'm living the life!"
msgstr "人生を生きている!"
msgid "I pwn therefore I am."
msgstr ""
msgid "So many networks!!!"
msgstr "たくさんネットワークがある!!!"
msgid "I'm having so much fun!"
msgstr "とても楽しんでいます!"
msgid "My crime is that of curiosity ..."
msgstr ""
#, python-brace-format
msgid "Hello {name}! Nice to meet you. {name}"
msgstr "こんにちは{name}!初めまして。{name}"
#, python-brace-format
msgid "Unit {name} is nearby! {name}"
msgstr ""
#, python-brace-format
msgid "Uhm ... goodbye {name}"
msgstr "ええと。。。さようなら{name}"
#, python-brace-format
msgid "{name} is gone ..."
msgstr "{name}がなくなった。。。"
#, python-brace-format
msgid "Whoops ... {name} is gone."
msgstr "おっと。。。{name}がなくなった。"
#, python-brace-format
msgid "{name} missed!"
msgstr "{name}逃した!"
msgid "Missed!"
msgstr "逃した!"
msgid "Nobody wants to play with me ..."
msgstr "誰も僕と一緒にプレーしたくない。。。"
msgid "I feel so alone ..."
msgstr "僕は孤独を感じる。。。"
msgid "Where's everybody?!"
msgstr "みんなどこ?!"
#, python-brace-format
msgid "Napping for {secs}s ..."
msgstr "{secs}寝ている。"
msgid "Zzzzz"
msgstr "すや〜"
#, python-brace-format
msgid "ZzzZzzz ({secs}s)"
msgstr "すやすや〜 ({secs})"
msgid "Good night."
msgstr "お休みなさい。"
msgid "Zzz"
msgstr "す〜"
#, python-brace-format
msgid "Waiting for {secs}s ..."
msgstr "{secs}を待っている。。。"
#, python-brace-format
msgid "Looking around ({secs}s)"
msgstr "{secs}を探している。"
#, python-brace-format
msgid "Hey {what} let's be friends!"
msgstr "ちょっと{what}友だちになりましょう!"
#, python-brace-format
msgid "Associating to {what}"
msgstr ""
#, python-brace-format
msgid "Yo {what}!"
msgstr "よー{what}!"
#, python-brace-format
msgid "Just decided that {mac} needs no WiFi!"
msgstr ""
#, python-brace-format
msgid "Deauthenticating {mac}"
msgstr ""
#, python-brace-format
msgid "Kickbanning {mac}!"
msgstr ""
#, python-brace-format
msgid "Cool, we got {num} new handshake{plural}!"
msgstr "よし、{num}新しいハンドシェイクがある!"
msgid "Ops, something went wrong ... Rebooting ..."
msgstr "おっと!何かが間違っていた。。。リブートしている。。。"
#, python-brace-format
msgid "Kicked {num} stations\n"
msgstr ""
#, python-brace-format
msgid "Made {num} new friends\n"
msgstr "{num}人の新しい友達を作りました\n"
#, python-brace-format
msgid "Got {num} handshakes\n"
msgstr "{num}ハンドシェイクがある。\n"
msgid "Met 1 peer"
msgstr "1人の仲間を会いました。"
#, python-brace-format
msgid "Met {num} peers"
msgstr "{num}人の仲間を会いました。"
#, python-brace-format
msgid ""
"I've been pwning for {duration} and kicked {deauthed} clients! I've also met "
"{associated} new friends and ate {handshakes} handshakes! #pwnagotchi "
"#pwnlog #pwnlife #hacktheplanet #skynet"
msgstr ""
msgid "hours"
msgstr "時間"
msgid "minutes"
msgstr "分"
msgid "seconds"
msgstr "秒"
msgid "hour"
msgstr "時間"
msgid "minute"
msgstr "分"
msgid "second"
msgstr "秒"

Binary file not shown.

View File

@@ -0,0 +1,215 @@
# Polish voice data for pwnagotchi.
# Copyright (C) 2019
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR szymex73 <szymex73@gmail.com>, 2019.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: 0.0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-10-09 17:42+0200\n"
"PO-Revision-Date: 2019-10-09 17:42+0200\n"
"Last-Translator: szymex73 <szymex73@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: polish\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "ZzzzZZzzzzZzzz"
msgstr "ZzzzZZzzzzZzzz"
msgid "Hi, I'm Pwnagotchi! Starting ..."
msgstr "Hej, jestem Pwnagotchi! Uruchamianie ..."
msgid "New day, new hunt, new pwns!"
msgstr "Nowy dzień, nowe łowy, nowe pwny!"
msgid "Hack the Planet!"
msgstr "Hakujmy planetę!"
msgid "AI ready."
msgstr "SI gotowa."
msgid "The neural network is ready."
msgstr "Sieć neuronowa jest gotowa."
#, python-brace-format
msgid "Hey, channel {channel} is free! Your AP will say thanks."
msgstr "Hej, kanał {channel} jest wolny! Twój AP mi podziękuje."
msgid "I'm bored ..."
msgstr "Nudzi mi się ..."
msgid "Let's go for a walk!"
msgstr "Chodźmy na spacer!"
msgid "This is the best day of my life!"
msgstr "To jest najlepszy dzień w moim życiu!"
msgid "Shitty day :/"
msgstr "Ten dzień jest do dupy :/"
msgid "I'm extremely bored ..."
msgstr "Straaaasznie się nudzę ..."
msgid "I'm very sad ..."
msgstr "Jest mi bardzo smutno ..."
msgid "I'm sad"
msgstr "Jest mi smutno"
msgid "I'm living the life!"
msgstr "Cieszę się życiem!"
msgid "I pwn therefore I am."
msgstr "Pwnuje więc jestem."
msgid "So many networks!!!"
msgstr "Jak dużo sieci!!!"
msgid "I'm having so much fun!"
msgstr "Ale jest super!"
msgid "My crime is that of curiosity ..."
msgstr "Moją zbrodnią jest ciekawość ..."
#, python-brace-format
msgid "Hello {name}! Nice to meet you. {name}"
msgstr "Cześć {name}! Miło cię poznać. {name}"
#, python-brace-format
msgid "Unit {name} is nearby! {name}"
msgstr "Jednostka {name} jest niedaleko! {name}"
#, python-brace-format
msgid "Uhm ... goodbye {name}"
msgstr "Umm ... żegnaj {name}"
#, python-brace-format
msgid "{name} is gone ..."
msgstr "{name} zniknął ..."
#, python-brace-format
msgid "Whoops ... {name} is gone."
msgstr "Ups ... {name} zniknął."
#, python-brace-format
msgid "{name} missed!"
msgstr "{name} przeoczył!"
msgid "Missed!"
msgstr "Spóźniony!"
msgid "Nobody wants to play with me ..."
msgstr "Nikt się nie chce ze mną bawić ..."
msgid "I feel so alone ..."
msgstr "Czuję się tak samotnie ..."
msgid "Where's everybody?!"
msgstr "Gdzie są wszyscy?!"
#, python-brace-format
msgid "Napping for {secs}s ..."
msgstr "Zdrzemnę się przez {secs}s ..."
msgid "Zzzzz"
msgstr "Zzzzz"
#, python-brace-format
msgid "ZzzZzzz ({secs}s)"
msgstr "ZzzZzzz ({secs}s)"
msgid "Good night."
msgstr "Dobranoc."
msgid "Zzz"
msgstr "Zzz"
#, python-brace-format
msgid "Waiting for {secs}s ..."
msgstr "Czekam {secs}s ..."
#, python-brace-format
msgid "Looking around ({secs}s)"
msgstr "Rozglądam się ({secs}s)"
#, python-brace-format
msgid "Hey {what} let's be friends!"
msgstr "Hej {what}, zostańmy przyjaciółmi!"
#, python-brace-format
msgid "Associating to {what}"
msgstr "Łączenie się z {what}"
#, python-brace-format
msgid "Yo {what}!"
msgstr "Ej {what}!"
#, python-brace-format
msgid "Just decided that {mac} needs no WiFi!"
msgstr "Według mnie {mac} nie potrzebuje WiFi!"
#, python-brace-format
msgid "Deauthenticating {mac}"
msgstr "Rozłączam {mac}"
#, python-brace-format
msgid "Kickbanning {mac}!"
msgstr "Banowanie {mac}!"
#, python-brace-format
msgid "Cool, we got {num} new handshake{plural}!"
msgstr "Super, zdobylismy {num} handshake{plural}!"
msgid "Ops, something went wrong ... Rebooting ..."
msgstr "Ups, coś się stało ... Restartuję ..."
#, python-brace-format
msgid "Kicked {num} stations\n"
msgstr "Wyrzucono {num} stacji\n"
#, python-brace-format
msgid "Made {num} new friends\n"
msgstr "Zdobyto {num} przyjaciół\n"
#, python-brace-format
msgid "Got {num} handshakes\n"
msgstr "Zdobyto {num} handshakow\n"
msgid "Met 1 peer"
msgstr "Spotkano 1 kolegę"
#, python-brace-format
msgid "Met {num} peers"
msgstr "Spotkano {num} kolegów"
#, python-brace-format
msgid ""
"I've been pwning for {duration} and kicked {deauthed} clients! I've also met "
"{associated} new friends and ate {handshakes} handshakes! #pwnagotchi "
"#pwnlog #pwnlife #hacktheplanet #skynet"
msgstr ""
"Pwnowalem przez {duration} i wyrzuciłem {deauthed} klientów! Spotkałem także "
"{associated} nowych przyjaciół i zjadłem {handshakes} handshaków! #pwnagotchi "
"#pwnlog #pwnlife #hacktheplanet #skynet"
msgid "hours"
msgstr "godzin"
msgid "minutes"
msgstr "minut"
msgid "seconds"
msgstr "sekund"
msgid "hour"
msgstr "godzina"
msgid "minute"
msgstr "minuta"
msgid "second"
msgstr "sekunda"

View File

@@ -29,10 +29,10 @@ msgid "New day, new hunt, new pwns!"
msgstr "Новый день, новая охота, новые взломы!"
msgid "Hack the Planet!"
msgstr "Взломаем всю планету!"
msgstr "Хак зе планет!"
msgid "AI ready."
msgstr "Искусственный интеллект готов."
msgstr "AI готов."
msgid "The neural network is ready."
msgstr "Нейронная сеть готова."
@@ -48,7 +48,7 @@ msgid "Let's go for a walk!"
msgstr "Пойдем прогуляемся!"
msgid "This is the best day of my life!"
msgstr "Это лучший день в моей жизни!"
msgstr "Лучший день в моей жизни!"
msgid "Shitty day :/"
msgstr "Дерьмовый день :/"
@@ -63,19 +63,19 @@ msgid "I'm sad"
msgstr "Мне грустно"
msgid "I'm living the life!"
msgstr "Я живу своей жизнью!"
msgstr "Угараю по полной!"
msgid "I pwn therefore I am."
msgstr "Я взламываю, поэтому я существую."
msgid "So many networks!!!"
msgstr "Так, много сетей!!!"
msgstr "Так много сетей!!!"
msgid "I'm having so much fun!"
msgstr "Мне так весело!"
msgid "My crime is that of curiosity ..."
msgstr "Моё преступление - это любопытство …"
msgstr "Моe преступление - это любопытство …"
#, python-brace-format
msgid "Hello {name}! Nice to meet you. {name}"
@@ -105,7 +105,7 @@ msgid "Missed!"
msgstr "Промахнулся!"
msgid "Nobody wants to play with me ..."
msgstr "Никто не хочет играть со мной "
msgstr "Никто не хочет со мной играть ..."
msgid "I feel so alone ..."
msgstr "Мне так одиноко …"

View File

@@ -2,6 +2,7 @@ import hashlib
import time
import re
import os
import logging
from datetime import datetime
from pwnagotchi.voice import Voice
@@ -87,6 +88,8 @@ class LastSession(object):
parts = line.split(']')
if len(parts) < 2:
continue
try:
line_timestamp = parts[0].strip('[')
line = ']'.join(parts[1:])
stopped_at = self._parse_datetime(line_timestamp)
@@ -142,6 +145,8 @@ class LastSession(object):
cache[pubkey] = self.last_peer
else:
cache[pubkey].adv['pwnd_tot'] = pwnd_tot
except Exception as e:
logging.error("error parsing line '%s': %s" % (line, e))
if started_at is not None:
self.duration = stopped_at - started_at

View File

@@ -29,6 +29,9 @@ class AsyncAdvertiser(object):
self._peers = {}
self._closest_peer = None
def fingerprint(self):
return self._keypair.fingerprint
def _update_advertisement(self, s):
self._advertisement['pwnd_run'] = len(self._handshakes)
self._advertisement['pwnd_tot'] = utils.total_unique_handshakes(self._config['bettercap']['handshakes'])

View File

@@ -1,60 +0,0 @@
__author__ = 'evilsocket@gmail.com'
__version__ = '1.0.0'
__name__ = 'auto-update'
__license__ = 'GPL3'
__description__ = 'This plugin performs an "apt update && apt upgrade" when internet is availaible.'
import logging
import subprocess
from pwnagotchi.utils import StatusFile
OPTIONS = dict()
READY = False
STATUS = StatusFile('/root/.auto-update')
def on_loaded():
global READY
if 'interval' not in OPTIONS or ('interval' in OPTIONS and OPTIONS['interval'] is None):
logging.error("auto-update: Interval is not set.")
return
READY = True
def run(cmd):
return subprocess.Popen(cmd, shell=True, stdin=None, stdout=open("/dev/null", "w"), stderr=None,
executable="/bin/bash")
def on_internet_available(agent):
global STATUS
if READY:
if STATUS.newer_then_days(OPTIONS['interval']):
return
display = agent.view()
try:
display.set('status', 'Updating ...')
display.update()
logging.info("auto-update: updating pwnagotchi ...")
run('pip3 install --upgrade --upgrade-strategy only-if-needed pwnagotchi').wait()
if OPTIONS['system']:
logging.info("auto-update: updating packages index ...")
run('apt update -y').wait()
logging.info("auto-update: updating packages ...")
run('apt upgrade -y').wait()
logging.info("auto-update: complete.")
STATUS.update()
except Exception as e:
logging.exception("auto-update ERROR")
display.set('status', 'Updated!')
display.update()

View File

@@ -132,7 +132,7 @@ class BTNap:
device = ifaces.get(BTNap.IFACE_DEV)
if device is None:
continue
if device['Address'] == device_address and path.startswith(path_prefix):
if str(device['Address']) == device_address and path.startswith(path_prefix):
obj = bus.get_object(BTNap.IFACE_BASE, path)
return dbus.Interface(obj, BTNap.IFACE_DEV)
raise BTError('Bluetooth device not found')
@@ -154,7 +154,40 @@ class BTNap:
return None
def wait_for_device(self, timeout=30):
def is_connected(self):
"""
Check if already connected
"""
bt_dev = self.power(True)
if not bt_dev:
return False
try:
dev_remote = BTNap.find_device(self._mac, bt_dev)
return bool(BTNap.prop_get(dev_remote, 'Connected'))
except BTError:
pass
return False
def is_paired(self):
"""
Check if already connected
"""
bt_dev = self.power(True)
if not bt_dev:
return False
try:
dev_remote = BTNap.find_device(self._mac, bt_dev)
return bool(BTNap.prop_get(dev_remote, 'Paired'))
except BTError:
pass
return False
def wait_for_device(self, timeout=15):
"""
Wait for device
@@ -165,21 +198,35 @@ class BTNap:
if not bt_dev:
return None
try:
bt_dev.StartDiscovery()
except Exception:
# can fail with org.bluez.Error.NotReady / org.bluez.Error.Failed
# TODO: add loop?
pass
dev_remote = None
# could be set to 0, so check if > -1
while timeout > -1:
try:
dev_remote = BTNap.find_device(self._mac, bt_dev)
logging.debug('Using remote device (addr: %s): %s',
BTNap.prop_get(dev_remote, 'Address'), dev_remote.object_path )
return dev_remote
break
except BTError:
pass
time.sleep(1)
timeout -= 1
# Device not found :(
return None
try:
bt_dev.StopDiscovery()
except Exception:
# can fail with org.bluez.Error.NotReady / org.bluez.Error.Failed / org.bluez.Error.NotAuthorized
pass
return dev_remote
def connect(self, reconnect=False):
@@ -189,19 +236,19 @@ class BTNap:
return True if connected; False if failed
"""
# power up devices
bt_dev = self.power(True)
if not bt_dev:
return False
# check if device is close
dev_remote = self.wait_for_device()
if not dev_remote:
return False
#wait_iter = lambda: time.sleep(3600)
# signal.signal(signal.SIGTERM, lambda sig,frm: sys.exit(0))
try:
dev_remote.Pair()
logging.info('BT-TETHER: Successful paired with device ;)')
time.sleep(10) # wait for bnep0
except Exception:
# can fail because of AlreadyExists etc.
pass
try:
dev_remote.ConnectProfile('nap')
@@ -347,6 +394,18 @@ class IfaceWrapper:
return False
@staticmethod
def set_route(addr):
process = subprocess.Popen(f"ip route replace default via {addr}", shell=True, stdin=None,
stdout=open("/dev/null", "w"), stderr=None, executable="/bin/bash")
process.wait()
if process.returncode > 0:
return False
return True
def on_loaded():
"""
@@ -355,7 +414,7 @@ def on_loaded():
global READY
global INTERVAL
for opt in ['mac', 'ip', 'netmask', 'interval']:
for opt in ['share_internet', 'mac', 'ip', 'netmask', 'interval']:
if opt not in OPTIONS or (opt in OPTIONS and OPTIONS[opt] is None):
logging.error("BT-TET: Pleace specify the %s in your config.yml.", opt)
return
@@ -384,25 +443,54 @@ def on_ui_update(ui):
INTERVAL.update()
bt = BTNap(OPTIONS['mac'])
if bt.connect():
btnap_iface = IfaceWrapper('bnep0')
logging.debug('BT-TETHER: Check if already connected and paired')
if bt.is_connected() and bt.is_paired():
logging.debug('BT-TETHER: Already connected and paired')
ui.set('bluetooth', 'CON')
else:
logging.debug('BT-TETHER: Try to connect to mac')
if bt.connect():
logging.info('BT-TETHER: Successfuly connected')
else:
logging.error('BT-TETHER: Could not connect')
ui.set('bluetooth', 'NF')
return
btnap_iface = IfaceWrapper('bnep0')
logging.debug('BT-TETHER: Check interface')
if btnap_iface.exists():
logging.debug('BT-TETHER: Interface found')
# check ip
addr = f"{OPTIONS['ip']}/{OPTIONS['netmask']}"
logging.debug('BT-TETHER: Try to set ADDR to interface')
if not btnap_iface.set_addr(addr):
ui.set('bluetooth', 'ERR1')
logging.error("Could not set ip of bnep0 to %s", addr)
logging.error("BT-TETHER: Could not set ip of bnep0 to %s", addr)
return
else:
logging.debug('BT-TETHER: Set ADDR to interface')
# change route if sharking
if OPTIONS['share_internet']:
logging.debug('BT-TETHER: Set routing and change resolv.conf')
IfaceWrapper.set_route(".".join(OPTIONS['ip'].split('.')[:-1] + ['1'])) # im not proud about that
# fix resolv.conf; dns over https ftw!
with open('/etc/resolv.conf', 'r+') as resolv:
nameserver = resolv.read()
if 'nameserver 9.9.9.9' not in nameserver:
logging.info('BT-TETHER: Added nameserver')
resolv.seek(0)
resolv.write(nameserver + 'nameserver 9.9.9.9\n')
ui.set('bluetooth', 'CON')
else:
logging.error('BT-TETHER: bnep0 not found')
ui.set('bluetooth', 'ERR2')
else:
ui.set('bluetooth', 'NF')
def on_ui_setup(ui):
ui.add_element('bluetooth', LabeledValue(color=BLACK, label='BT', value='-', position=(ui.width() / 2 - 30, 0),
ui.add_element('bluetooth', LabeledValue(color=BLACK, label='BT', value='-', position=(ui.width() / 2 - 15, 0),
label_font=fonts.Bold, text_font=fonts.Medium))

View File

@@ -65,7 +65,7 @@ def is_excluded(what):
def on_ui_update(ui):
new_value = ' %d (%d)' % (UNREAD_MESSAGES, TOTAL_MESSAGES)
if not ui.has_element('mailbox') and TOTAL_MESSAGES > 0:
if not ui.has_element('mailbox') and UNREAD_MESSAGES > 0:
if ui.is_inky():
pos = (80, 0)
else:

View File

@@ -2,8 +2,19 @@
#
# totalmem usedmem freemem cputemp
#
###############################################################
#
# Updated 18-10-2019 by spees <speeskonijn@gmail.com>
# - Changed the place where the data was displayed on screen
# - Made the data a bit more compact and easier to read
# - removed the label so we wont waste screen space
# - Updated version to 1.0.1
#
###############################################################
__author__ = 'https://github.com/xenDE'
__version__ = '1.0.0'
__version__ = '1.0.1'
__name__ = 'memtemp'
__license__ = 'GPL3'
__description__ = 'A plugin that will add a memory and temperature indicator'
@@ -31,9 +42,9 @@ class MEMTEMP:
def get_temp(self):
try:
temp = os.popen('/opt/vc/bin/vcgencmd measure_temp').readlines()[0].split('=')[1].replace("\n", '').replace("'","")
return 'cpu:' + temp
return 't:' + temp
except:
return 'cpu:0.0C'
return 't:-'
# cpu:37.4C
def get_mem_info(self):
@@ -42,9 +53,9 @@ class MEMTEMP:
# total, used, free = map(int, os.popen('free -t -m').readlines()[-1].split()[1:])
# without Swap, only real memory:
total, used, free = map(int, os.popen('free -t -m').readlines()[-3].split()[1:4])
return "tm:"+str(total)+" um:"+str(used)+" fm:"+str(free)
return "\nT:"+str(total)+"M U:"+str(used)+"M\nF:"+str(free)+"M"
except:
return "tm:0 um:0 fm:0"
return "\nT:- U:-\nF:- "
# tm:532 um:82 fm:353
@@ -57,7 +68,7 @@ def on_loaded():
def on_ui_setup(ui):
ui.add_element('memtemp', LabeledValue(color=BLACK, label='SYS', value='tm:0 um:0 fm:0 0.0C', position=(0, ui.height()-28),
ui.add_element('memtemp', LabeledValue(color=BLACK, label='', value='\nT:- U:-\nF:- -', position=(ui.width() / 2 + 17, ui.height() / 2),
label_font=fonts.Bold, text_font=fonts.Medium))
@@ -66,3 +77,4 @@ def on_ui_update(ui):
ui.set('memtemp', "%s %s" % (memtemp.get_mem_info(), memtemp.get_temp()))
memtemp.refresh_ts_last = time.time()

View File

@@ -1,5 +1,5 @@
__author__ = 'zenzen san'
__version__ = '1.0.0'
__version__ = '2.0.0'
__name__ = 'net-pos'
__license__ = 'GPL3'
__description__ = """Saves a json file with the access points with more signal
@@ -11,33 +11,24 @@ import logging
import json
import os
import requests
from pwnagotchi.utils import StatusFile
MOZILLA_API_URL = 'https://location.services.mozilla.com/v1/geolocate?key={api}'
ALREADY_SAVED = None
SKIP = None
REPORT = StatusFile('/root/.net_pos_saved', data_format='json')
SKIP = list()
READY = False
OPTIONS = {}
OPTIONS = dict()
def on_loaded():
global ALREADY_SAVED
global SKIP
global READY
SKIP = list()
if 'api_key' not in OPTIONS or ('api_key' in OPTIONS and OPTIONS['api_key'] is None):
logging.error("NET-POS: api_key isn't set. Can't use mozilla's api.")
return
try:
with open('/root/.net_pos_saved', 'r') as f:
ALREADY_SAVED = f.read().splitlines()
except OSError:
logging.warning('NET-POS: No net-pos-file found.')
ALREADY_SAVED = []
READY = True
logging.info("net-pos plugin loaded.")
def _append_saved(path):
@@ -55,20 +46,22 @@ def _append_saved(path):
def on_internet_available(agent):
global SKIP
global REPORT
if READY:
config = agent.config()
display = agent.view()
reported = REPORT.data_field_or('reported', default=list())
handshake_dir = config['bettercap']['handshakes']
all_files = os.listdir(handshake_dir)
all_np_files = [os.path.join(handshake_dir, filename)
for filename in all_files
if filename.endswith('.net-pos.json')]
new_np_files = set(all_np_files) - set(ALREADY_SAVED) - set(SKIP)
new_np_files = set(all_np_files) - set(reported) - set(SKIP)
if new_np_files:
logging.info("NET-POS: Found {num} new net-pos files. Fetching positions ...", len(new_np_files))
logging.info("NET-POS: Found %d new net-pos files. Fetching positions ...", len(new_np_files))
display.set('status', f"Found {len(new_np_files)} new net-pos files. Fetching positions ...")
display.update(force=True)
for idx, np_file in enumerate(new_np_files):
@@ -76,8 +69,8 @@ def on_internet_available(agent):
geo_file = np_file.replace('.net-pos.json', '.geo.json')
if os.path.exists(geo_file):
# got already the position
ALREADY_SAVED.append(np_file)
_append_saved(np_file)
reported.append(np_file)
REPORT.update(data={'reported': reported})
continue
try:
@@ -85,18 +78,21 @@ def on_internet_available(agent):
except requests.exceptions.RequestException as req_e:
logging.error("NET-POS: %s", req_e)
SKIP += np_file
continue
except json.JSONDecodeError as js_e:
logging.error("NET-POS: %s", js_e)
SKIP += np_file
continue
except OSError as os_e:
logging.error("NET-POS: %s", os_e)
SKIP += np_file
continue
with open(geo_file, 'w+t') as sf:
json.dump(geo_data, sf)
ALREADY_SAVED.append(np_file)
_append_saved(np_file)
reported.append(np_file)
REPORT.update(data={'reported': reported})
display.set('status', f"Fetching positions ({idx+1}/{len(new_np_files)})")
display.update(force=True)
@@ -108,15 +104,15 @@ def on_handshake(agent, filename, access_point, client_station):
logging.info("NET-POS: Saving net-location to %s", netpos_filename)
try:
with open(netpos_filename, 'w+t') as fp:
json.dump(netpos, fp)
with open(netpos_filename, 'w+t') as net_pos_file:
json.dump(netpos, net_pos_file)
except OSError as os_e:
logging.error("NET-POS: %s", os_e)
def _get_netpos(agent):
aps = agent.get_access_points()
netpos = {}
netpos = dict()
netpos['wifiAccessPoints'] = list()
# 6 seems a good number to save a wifi networks location
for access_point in sorted(aps, key=lambda i: i['rssi'], reverse=True)[:6]:

View File

@@ -1,5 +1,5 @@
__author__ = '33197631+dadav@users.noreply.github.com'
__version__ = '1.0.0'
__version__ = '2.0.0'
__name__ = 'onlinehashcrack'
__license__ = 'GPL3'
__description__ = 'This plugin automatically uploades handshakes to https://onlinehashcrack.com'
@@ -7,9 +7,11 @@ __description__ = 'This plugin automatically uploades handshakes to https://onli
import os
import logging
import requests
from pwnagotchi.utils import StatusFile
READY = False
ALREADY_UPLOADED = None
REPORT = StatusFile('/root/.ohc_uploads', data_format='json')
SKIP = list()
OPTIONS = dict()
@@ -18,20 +20,11 @@ def on_loaded():
Gets called when the plugin gets loaded
"""
global READY
global EMAIL
global ALREADY_UPLOADED
if not 'email' in OPTIONS or ('email' in OPTIONS and OPTIONS['email'] is None):
if 'email' not in OPTIONS or ('email' in OPTIONS and OPTIONS['email'] is None):
logging.error("OHC: Email isn't set. Can't upload to onlinehashcrack.com")
return
try:
with open('/root/.ohc_uploads', 'r') as f:
ALREADY_UPLOADED = f.read().splitlines()
except OSError:
logging.warning('OHC: No upload-file found.')
ALREADY_UPLOADED = []
READY = True
@@ -59,14 +52,17 @@ def on_internet_available(agent):
"""
Called in manual mode when there's internet connectivity
"""
global REPORT
global SKIP
if READY:
display = agent.view()
config = agent.config()
reported = REPORT.data_field_or('reported', default=list())
handshake_dir = config['bettercap']['handshakes']
handshake_filenames = os.listdir(handshake_dir)
handshake_paths = [os.path.join(handshake_dir, filename) for filename in handshake_filenames if filename.endswith('.pcap')]
handshake_new = set(handshake_paths) - set(ALREADY_UPLOADED)
handshake_new = set(handshake_paths) - set(reported) - set(SKIP)
if handshake_new:
logging.info("OHC: Internet connectivity detected. Uploading new handshakes to onelinehashcrack.com")
@@ -76,12 +72,15 @@ def on_internet_available(agent):
display.update(force=True)
try:
_upload_to_ohc(handshake)
ALREADY_UPLOADED.append(handshake)
with open('/root/.ohc_uploads', 'a') as f:
f.write(handshake + "\n")
reported.append(handshake)
REPORT.update(data={'reported': reported})
logging.info(f"OHC: Successfuly uploaded {handshake}")
except requests.exceptions.RequestException:
pass
except requests.exceptions.RequestException as req_e:
SKIP.append(handshake)
logging.error("OHC: %s", req_e)
continue
except OSError as os_e:
logging.error(f"OHC: Got the following error: {os_e}")
SKIP.append(handshake)
logging.error("OHC: %s", os_e)
continue

View File

@@ -18,7 +18,7 @@ def on_ui_update(ui):
global update_count
update_count += 1
if update_count == OPTIONS['refresh_interval']:
ui._init_display()
ui.init_display()
ui.set('status', "Screen cleaned")
logging.info("Screen refreshing")
update_count = 0

View File

@@ -0,0 +1,22 @@
__author__ = 'diemelcw@gmail.com'
__version__ = '1.0.0'
__name__ = 'unfiltered_example'
__license__ = 'GPL3'
__description__ = 'An example plugin for pwnagotchi that implements on_unfiltered_ap_list(agent,aps)'
import logging
# Will be set with the options in config.yml config['main']['plugins'][__name__]
OPTIONS = dict()
# called when the plugin is loaded
def on_loaded():
logging.warning("%s plugin loaded" % __name__)
# called when AP list is ready, before whitelist filtering has occured
def on_unfiltered_ap_list(agent,aps):
logging.info("Unfiltered AP list to follow")
for ap in aps:
logging.info(ap['hostname'])
## Additional logic here ##

View File

@@ -1,5 +1,5 @@
__author__ = '33197631+dadav@users.noreply.github.com'
__version__ = '1.0.0'
__version__ = '2.0.0'
__name__ = 'wigle'
__license__ = 'GPL3'
__description__ = 'This plugin automatically uploades collected wifis to wigle.net'
@@ -11,111 +11,24 @@ from io import StringIO
import csv
from datetime import datetime
import requests
from pwnagotchi.mesh.wifi import freq_to_channel
from pwnagotchi.utils import WifiInfo, FieldNotFoundError, extract_from_pcap
from pwnagotchi.utils import WifiInfo, FieldNotFoundError, extract_from_pcap, StatusFile
READY = False
ALREADY_UPLOADED = None
SKIP = None
REPORT = StatusFile('/root/.wigle_uploads', data_format='json')
SKIP = list()
OPTIONS = dict()
AKMSUITE_TYPES = {
0x00: "Reserved",
0x01: "802.1X",
0x02: "PSK",
}
def _handle_packet(packet, result):
from scapy.all import RadioTap, Dot11Elt, Dot11Beacon, rdpcap, Scapy_Exception, Dot11, Dot11ProbeResp, Dot11AssoReq, \
Dot11ReassoReq, Dot11EltRSN, Dot11EltVendorSpecific, Dot11EltMicrosoftWPA
"""
Analyze each packet and extract the data from Dot11 layers
"""
if hasattr(packet, 'cap') and 'privacy' in packet.cap:
# packet is encrypted
if 'encryption' not in result:
result['encryption'] = set()
if packet.haslayer(Dot11Beacon):
if packet.haslayer(Dot11Beacon)\
or packet.haslayer(Dot11ProbeResp)\
or packet.haslayer(Dot11AssoReq)\
or packet.haslayer(Dot11ReassoReq):
if 'bssid' not in result and hasattr(packet[Dot11], 'addr3'):
result['bssid'] = packet[Dot11].addr3
if 'essid' not in result and hasattr(packet[Dot11Elt], 'info'):
result['essid'] = packet[Dot11Elt].info
if 'channel' not in result and hasattr(packet[Dot11Elt:3], 'info'):
result['channel'] = int(ord(packet[Dot11Elt:3].info))
if packet.haslayer(RadioTap):
if 'rssi' not in result and hasattr(packet[RadioTap], 'dBm_AntSignal'):
result['rssi'] = packet[RadioTap].dBm_AntSignal
if 'channel' not in result and hasattr(packet[RadioTap], 'ChannelFrequency'):
result['channel'] = freq_to_channel(packet[RadioTap].ChannelFrequency)
# see: https://fossies.org/linux/scapy/scapy/layers/dot11.py
if packet.haslayer(Dot11EltRSN):
if hasattr(packet[Dot11EltRSN], 'akm_suites'):
auth = AKMSUITE_TYPES.get(packet[Dot11EltRSN].akm_suites[0].suite)
result['encryption'].add(f"WPA2/{auth}")
else:
result['encryption'].add("WPA2")
if packet.haslayer(Dot11EltVendorSpecific)\
and (packet.haslayer(Dot11EltMicrosoftWPA)
or packet.info.startswith(b'\x00P\xf2\x01\x01\x00')):
if hasattr(packet, 'akm_suites'):
auth = AKMSUITE_TYPES.get(packet.akm_suites[0].suite)
result['encryption'].add(f"WPA2/{auth}")
else:
result['encryption'].add("WPA2")
# end see
return result
def _analyze_pcap(pcap):
from scapy.all import RadioTap, Dot11Elt, Dot11Beacon, rdpcap, Scapy_Exception, Dot11, Dot11ProbeResp, Dot11AssoReq, \
Dot11ReassoReq, Dot11EltRSN, Dot11EltVendorSpecific, Dot11EltMicrosoftWPA
"""
Iterate over the packets and extract data
"""
result = dict()
try:
packets = rdpcap(pcap)
for packet in packets:
result = _handle_packet(packet, result)
except Scapy_Exception as sc_e:
raise sc_e
return result
def on_loaded():
"""
Gets called when the plugin gets loaded
"""
global READY
global ALREADY_UPLOADED
global SKIP
SKIP = list()
if 'api_key' not in OPTIONS or ('api_key' in OPTIONS and OPTIONS['api_key'] is None):
logging.error("WIGLE: api_key isn't set. Can't upload to wigle.net")
return
try:
with open('/root/.wigle_uploads', 'r') as f:
ALREADY_UPLOADED = f.read().splitlines()
except OSError:
logging.warning('WIGLE: No upload-file found.')
ALREADY_UPLOADED = []
READY = True
@@ -197,24 +110,24 @@ def _send_to_wigle(lines, api_key, timeout=30):
def on_internet_available(agent):
from scapy.all import RadioTap, Dot11Elt, Dot11Beacon, rdpcap, Scapy_Exception, Dot11, Dot11ProbeResp, Dot11AssoReq, \
Dot11ReassoReq, Dot11EltRSN, Dot11EltVendorSpecific, Dot11EltMicrosoftWPA
from scapy.all import Scapy_Exception
"""
Called in manual mode when there's internet connectivity
"""
global ALREADY_UPLOADED
global REPORT
global SKIP
if READY:
config = agent.config()
display = agent.view()
reported = REPORT.data_field_or('reported', default=list())
handshake_dir = config['bettercap']['handshakes']
all_files = os.listdir(handshake_dir)
all_gps_files = [os.path.join(handshake_dir, filename)
for filename in all_files
if filename.endswith('.gps.json')]
new_gps_files = set(all_gps_files) - set(ALREADY_UPLOADED) - set(SKIP)
new_gps_files = set(all_gps_files) - set(reported) - set(SKIP)
if new_gps_files:
logging.info("WIGLE: Internet connectivity detected. Uploading new handshakes to wigle.net")
@@ -271,10 +184,8 @@ def on_internet_available(agent):
display.update(force=True)
try:
_send_to_wigle(csv_entries, OPTIONS['api_key'])
ALREADY_UPLOADED += no_err_entries
with open('/root/.wigle_uploads', 'a') as up_file:
for gps in no_err_entries:
up_file.write(gps + "\n")
reported += no_err_entries
REPORT.update(data={'reported': reported})
logging.info("WIGLE: Successfuly uploaded %d files", len(no_err_entries))
except requests.exceptions.RequestException as re_e:
SKIP += no_err_entries

View File

@@ -1,5 +1,5 @@
__author__ = '33197631+dadav@users.noreply.github.com'
__version__ = '1.0.0'
__version__ = '2.0.1'
__name__ = 'wpa-sec'
__license__ = 'GPL3'
__description__ = 'This plugin automatically uploades handshakes to https://wpa-sec.stanev.org'
@@ -7,9 +7,12 @@ __description__ = 'This plugin automatically uploades handshakes to https://wpa-
import os
import logging
import requests
from pwnagotchi.utils import StatusFile
READY = False
ALREADY_UPLOADED = None
REPORT = StatusFile('/root/.wpa_sec_uploads', data_format='json')
OPTIONS = dict()
SKIP = list()
def on_loaded():
@@ -17,20 +20,11 @@ def on_loaded():
Gets called when the plugin gets loaded
"""
global READY
global API_KEY
global ALREADY_UPLOADED
if not 'api_key' in OPTIONS or ('api_key' in OPTIONS and OPTIONS['api_key'] is None):
if 'api_key' not in OPTIONS or ('api_key' in OPTIONS and OPTIONS['api_key'] is None):
logging.error("WPA_SEC: API-KEY isn't set. Can't upload to wpa-sec.stanev.org")
return
try:
with open('/root/.wpa_sec_uploads', 'r') as f:
ALREADY_UPLOADED = f.read().splitlines()
except OSError:
logging.warning('WPA_SEC: No upload-file found.')
ALREADY_UPLOADED = []
READY = True
@@ -39,48 +33,51 @@ def _upload_to_wpasec(path, timeout=30):
Uploads the file to wpa-sec.stanev.org
"""
with open(path, 'rb') as file_to_upload:
headers = {'key': OPTIONS['api_key']}
cookie = {'key': OPTIONS['api_key']}
payload = {'file': file_to_upload}
try:
result = requests.post('https://wpa-sec.stanev.org/?submit',
headers=headers,
result = requests.post('https://wpa-sec.stanev.org',
cookies=cookie,
files=payload,
timeout=timeout)
if ' already submitted' in result.text:
logging.warning(f"{path} was already submitted.")
except requests.exceptions.RequestException as e:
logging.error(f"WPA_SEC: Got an exception while uploading {path} -> {e}")
raise e
logging.warning("%s was already submitted.", path)
except requests.exceptions.RequestException as req_e:
raise req_e
def on_internet_available(agent):
"""
Called in manual mode when there's internet connectivity
"""
global REPORT
global SKIP
if READY:
config = agent.config()
display = agent.view()
reported = REPORT.data_field_or('reported', default=list())
handshake_dir = config['bettercap']['handshakes']
handshake_filenames = os.listdir(handshake_dir)
handshake_paths = [os.path.join(handshake_dir, filename) for filename in handshake_filenames if filename.endswith('.pcap')]
handshake_new = set(handshake_paths) - set(ALREADY_UPLOADED)
handshake_new = set(handshake_paths) - set(reported) - set(SKIP)
if handshake_new:
logging.info("WPA_SEC: Internet connectivity detected.\
Uploading new handshakes to wpa-sec.stanev.org")
logging.info("WPA_SEC: Internet connectivity detected. Uploading new handshakes to wpa-sec.stanev.org")
for idx, handshake in enumerate(handshake_new):
display.set('status', f"Uploading handshake to wpa-sec.stanev.org ({idx + 1}/{len(handshake_new)})")
display.update(force=True)
try:
_upload_to_wpasec(handshake)
ALREADY_UPLOADED.append(handshake)
with open('/root/.wpa_sec_uploads', 'a') as f:
f.write(handshake + "\n")
logging.info(f"WPA_SEC: Successfuly uploaded {handshake}")
except requests.exceptions.RequestException:
pass
reported.append(handshake)
REPORT.update(data={'reported': reported})
logging.info("WPA_SEC: Successfuly uploaded %s", handshake)
except requests.exceptions.RequestException as req_e:
SKIP.append(handshake)
logging.error("WPA_SEC: %s", req_e)
continue
except OSError as os_e:
logging.error(f"WPA_SEC: Got the following error: {os_e}")
logging.error("WPA_SEC: %s", os_e)
continue

View File

@@ -1,13 +1,12 @@
import _thread
from threading import Lock
from PIL import Image
import shutil
import logging
import os
import pwnagotchi, pwnagotchi.plugins as plugins
from pwnagotchi.ui.view import WHITE, View
import pwnagotchi.ui.hw as hw
from pwnagotchi.ui.view import View
from http.server import BaseHTTPRequestHandler, HTTPServer
@@ -88,24 +87,15 @@ class VideoHandler(BaseHTTPRequestHandler):
class Display(View):
def __init__(self, config, state={}):
super(Display, self).__init__(config, state)
super(Display, self).__init__(config, hw.display_for(config), state)
self._enabled = config['ui']['display']['enabled']
self._rotation = config['ui']['display']['rotation']
self._video_enabled = config['ui']['display']['video']['enabled']
self._video_port = config['ui']['display']['video']['port']
self._video_address = config['ui']['display']['video']['address']
self._display_type = config['ui']['display']['type']
self._display_color = config['ui']['display']['color']
self._render_cb = None
self._display = None
self._httpd = None
if self._enabled:
self._init_display()
else:
self.on_render(self._on_view_rendered)
logging.warning("display module is disabled")
self.init_display()
if self._video_enabled:
_thread.start_new_thread(self._http_serve, ())
@@ -119,133 +109,37 @@ class Display(View):
logging.info("could not get ip of usb0, video server not starting")
def is_inky(self):
return self._display_type in ('inkyphat', 'inky')
return self._implementation.name == 'inky'
def is_papirus(self):
return self._display_type in ('papirus', 'papi')
return self._implementation.name == 'papirus'
def is_waveshare_v1(self):
return self._display_type in ('waveshare_1', 'ws_1', 'waveshare1', 'ws1')
return self._implementation.name == 'waveshare_1'
def is_waveshare_v2(self):
return self._display_type in ('waveshare_2', 'ws_2', 'waveshare2', 'ws2')
return self._implementation.name == 'waveshare_2'
def is_oledhat(self):
return self._implementation.name == 'oledhat'
def is_lcdhat(self):
return self._implementation.name == 'lcdhat'
def is_waveshare_any(self):
return self.is_waveshare_v1() or self.is_waveshare_v2()
def _init_display(self):
if self.is_inky():
logging.info("initializing inky display")
from inky import InkyPHAT
self._display = InkyPHAT(self._display_color)
self._display.set_border(InkyPHAT.BLACK)
self._render_cb = self._inky_render
elif self.is_papirus():
logging.info("initializing papirus display")
from pwnagotchi.ui.papirus.epd import EPD
os.environ['EPD_SIZE'] = '2.0'
self._display = EPD()
self._display.clear()
self._render_cb = self._papirus_render
elif self.is_waveshare_v1():
if self._display_color == 'black':
logging.info("initializing waveshare v1 display in monochromatic mode")
from pwnagotchi.ui.waveshare.v1.epd2in13 import EPD
self._display = EPD()
self._display.init(self._display.lut_full_update)
self._display.Clear(0xFF)
self._display.init(self._display.lut_partial_update)
self._render_cb = self._waveshare_render
def init_display(self):
if self._enabled:
self._implementation.initialize()
plugins.on('display_setup', self._implementation)
else:
logging.info("initializing waveshare v1 display 3-color mode")
from pwnagotchi.ui.waveshare.v1.epd2in13bc import EPD
self._display = EPD()
self._display.init()
self._display.Clear()
self._render_cb = self._waveshare_bc_render
elif self.is_waveshare_v2():
logging.info("initializing waveshare v2 display")
from pwnagotchi.ui.waveshare.v2.waveshare import EPD
self._display = EPD()
self._display.init(self._display.FULL_UPDATE)
self._display.Clear(WHITE)
self._display.init(self._display.PART_UPDATE)
self._render_cb = self._waveshare_render
else:
logging.critical("unknown display type %s" % self._display_type)
plugins.on('display_setup', self._display)
logging.warning("display module is disabled")
self.on_render(self._on_view_rendered)
def clear(self):
if self._display is None:
logging.error("no display object created")
elif self.is_inky():
self._display.Clear()
elif self.is_papirus():
self._display.clear()
elif self.is_waveshare_any():
self._display.Clear(WHITE)
else:
logging.critical("unknown display type %s" % self._display_type)
def _inky_render(self):
if self._display_color != 'mono':
display_colors = 3
else:
display_colors = 2
img_buffer = self._canvas.convert('RGB').convert('P', palette=1, colors=display_colors)
if self._display_color == 'red':
img_buffer.putpalette([
255, 255, 255, # index 0 is white
0, 0, 0, # index 1 is black
255, 0, 0 # index 2 is red
])
elif self._display_color == 'yellow':
img_buffer.putpalette([
255, 255, 255, # index 0 is white
0, 0, 0, # index 1 is black
255, 255, 0 # index 2 is yellow
])
else:
img_buffer.putpalette([
255, 255, 255, # index 0 is white
0, 0, 0 # index 1 is black
])
self._display.set_image(img_buffer)
try:
self._display.show()
except:
logging.exception("error while rendering on inky")
def _papirus_render(self):
self._display.display(self._canvas)
self._display.partial_update()
def _waveshare_render(self):
buf = self._display.getbuffer(self._canvas)
if self.is_waveshare_v1():
self._display.display(buf)
elif self.is_waveshare_v2():
self._display.displayPartial(buf)
def _waveshare_bc_render(self):
buf_black = self._display.getbuffer(self._canvas)
# emptyImage = Image.new('1', (self._display.height, self._display.width), 255)
# buf_color = self._display.getbuffer(emptyImage)
# self._display.display(buf_black,buf_color)
# Custom display function that only handles black
# Was included in epd2in13bc.py
self._display.displayBlack(buf_black)
self._implementation.clear()
def image(self):
img = None
@@ -255,8 +149,7 @@ class Display(View):
def _on_view_rendered(self, img):
VideoHandler.render(img)
if self._enabled:
self._canvas = (img if self._rotation == 0 else img.rotate(self._rotation))
if self._render_cb is not None:
self._render_cb()
if self._implementation is not None:
self._implementation.render(self._canvas)

View File

@@ -1,11 +1,11 @@
LOOK_R = '(⌐■_■)'
LOOK_L = '(■_■¬)'
LOOK_R = '( ⚆_⚆)'
LOOK_L = '(☉_☉ )'
SLEEP = '(⇀‿‿↼)'
SLEEP2 = '(≖‿‿≖)'
AWAKE = '(◕‿‿◕)'
BORED = '(-__-)'
INTENSE = '(°▃▃°)'
COOL = '(⊙☁◉┐)'
COOL = '(⌐■_■)'
HAPPY = '(•‿‿•)'
EXCITED = '(ᵔ◡◡ᵔ)'
MOTIVATED = '(☼‿‿☼)'

View File

@@ -0,0 +1,28 @@
from pwnagotchi.ui.hw.inky import Inky
from pwnagotchi.ui.hw.papirus import Papirus
from pwnagotchi.ui.hw.oledhat import OledHat
from pwnagotchi.ui.hw.lcdhat import LcdHat
from pwnagotchi.ui.hw.waveshare1 import WaveshareV1
from pwnagotchi.ui.hw.waveshare2 import WaveshareV2
def display_for(config):
# config has been normalized already in utils.load_config
if config['ui']['display']['type'] == 'inky':
return Inky(config)
elif config['ui']['display']['type'] == 'papirus':
return Papirus(config)
if config['ui']['display']['type'] == 'oledhat':
return OledHat(config)
if config['ui']['display']['type'] == 'lcdhat':
return LcdHat(config)
elif config['ui']['display']['type'] == 'waveshare_1':
return WaveshareV1(config)
elif config['ui']['display']['type'] == 'waveshare_2':
return WaveshareV2(config)

40
pwnagotchi/ui/hw/base.py Normal file
View File

@@ -0,0 +1,40 @@
import pwnagotchi.ui.fonts as fonts
class DisplayImpl(object):
def __init__(self, config, name):
self.name = name
self.config = config['ui']['display']
self._layout = {
'width': 0,
'height': 0,
'face': (0, 0),
'name': (0, 0),
'channel': (0, 0),
'aps': (0, 0),
'uptime': (0, 0),
'line1': (0, 0),
'line2': (0, 0),
'friend_face': (0, 0),
'friend_name': (0, 0),
'shakes': (0, 0),
'mode': (0, 0),
# status is special :D
'status': {
'pos': (0, 0),
'font': fonts.Medium,
'max': 20
}
}
def layout(self):
raise NotImplementedError
def initialize(self):
raise NotImplementedError
def render(self, canvas):
raise NotImplementedError
def clear(self):
raise NotImplementedError

72
pwnagotchi/ui/hw/inky.py Normal file
View File

@@ -0,0 +1,72 @@
import logging
import pwnagotchi.ui.fonts as fonts
from pwnagotchi.ui.hw.base import DisplayImpl
class Inky(DisplayImpl):
def __init__(self, config):
super(Inky, self).__init__(config, 'inky')
self._display = None
def layout(self):
fonts.setup(10, 8, 10, 28)
self._layout['width'] = 212
self._layout['height'] = 104
self._layout['face'] = (0, 37)
self._layout['name'] = (5, 18)
self._layout['channel'] = (0, 0)
self._layout['aps'] = (30, 0)
self._layout['uptime'] = (147, 0)
self._layout['line1'] = [0, 12, 212, 12]
self._layout['line2'] = [0, 92, 212, 92]
self._layout['friend_face'] = (0, 76)
self._layout['friend_name'] = (40, 78)
self._layout['shakes'] = (0, 93)
self._layout['mode'] = (187, 93)
self._layout['status'] = {
'pos': (102, 18),
'font': fonts.Small,
'max': 20
}
return self._layout
def initialize(self):
logging.info("initializing inky display")
from pwnagotchi.ui.hw.libs.inkyphat.inkyphatfast import InkyPHATFast
self._display = InkyPHATFast(self.config['color'])
self._display.set_border(InkyPHATFast.BLACK)
def render(self, canvas):
if self.config['color'] != 'mono':
display_colors = 3
else:
display_colors = 2
img_buffer = canvas.convert('RGB').convert('P', palette=1, colors=display_colors)
if self.config['color'] == 'red':
img_buffer.putpalette([
255, 255, 255, # index 0 is white
0, 0, 0, # index 1 is black
255, 0, 0 # index 2 is red
])
elif self.config['color'] == 'yellow':
img_buffer.putpalette([
255, 255, 255, # index 0 is white
0, 0, 0, # index 1 is black
255, 255, 0 # index 2 is yellow
])
else:
img_buffer.putpalette([
255, 255, 255, # index 0 is white
0, 0, 0 # index 1 is black
])
self._display.set_image(img_buffer)
try:
self._display.show()
except:
logging.exception("error while rendering on inky")
def clear(self):
self._display.Clear()

View File

@@ -0,0 +1,46 @@
import logging
import pwnagotchi.ui.fonts as fonts
from pwnagotchi.ui.hw.base import DisplayImpl
class LcdHat(DisplayImpl):
def __init__(self, config):
super(LcdHat, self).__init__(config, 'lcdhat')
self._display = None
def layout(self):
fonts.setup(10, 9, 10, 35)
self._layout['width'] = 240
self._layout['height'] = 240
self._layout['face'] = (0, 40)
self._layout['name'] = (5, 20)
self._layout['channel'] = (0, 0)
self._layout['aps'] = (28, 0)
self._layout['uptime'] = (175, 0)
self._layout['line1'] = [0, 14, 240, 14]
self._layout['line2'] = [0, 108, 240, 108]
self._layout['friend_face'] = (0, 92)
self._layout['friend_name'] = (40, 94)
self._layout['shakes'] = (0, 109)
self._layout['mode'] = (215, 109)
self._layout['status'] = {
'pos': (125, 20),
'font': fonts.Medium,
'max': 20
}
return self._layout
def initialize(self):
logging.info("initializing lcdhat display")
from pwnagotchi.ui.hw.libs.waveshare.lcdhat.epd import EPD
self._display = EPD()
self._display.init()
self._display.Clear()
def render(self, canvas):
self._display.display(canvas)
def clear(self):
self._display.clear()

View File

@@ -0,0 +1,24 @@
from inky.inky import Inky, CS0_PIN, DC_PIN, RESET_PIN, BUSY_PIN
class InkyFast(Inky):
def __init__(self, resolution=(400, 300), colour='black', cs_pin=CS0_PIN, dc_pin=DC_PIN, reset_pin=RESET_PIN,
busy_pin=BUSY_PIN, h_flip=False, v_flip=False):
super(InkyFast, self).__init__(resolution, colour, cs_pin, dc_pin, reset_pin, busy_pin, h_flip, v_flip)
self._luts['black'] = [
0b01001000, 0b10100000, 0b00010000, 0b00010000, 0b00010011, 0b00000000, 0b00000000,
0b01001000, 0b10100000, 0b10000000, 0b00000000, 0b00000011, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b01001000, 0b10100101, 0b00000000, 0b10111011, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
# The following timings have been reduced to avoid the fade to black
0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x04, 0x04, 0x04, 0x04,
0x04, 0x08, 0x08, 0x10, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
]

View File

@@ -0,0 +1,27 @@
"""Inky pHAT e-Ink Display Driver."""
from . import inkyfast
class InkyPHATFast(inkyfast.InkyFast):
"""Inky wHAT e-Ink Display Driver."""
WIDTH = 212
HEIGHT = 104
WHITE = 0
BLACK = 1
RED = 2
YELLOW = 2
def __init__(self, colour):
"""Initialise an Inky pHAT Display.
:param colour: one of red, black or yellow, default: black
"""
inkyfast.InkyFast.__init__(
self,
resolution=(self.WIDTH, self.HEIGHT),
colour=colour,
h_flip=False,
v_flip=False)

View File

@@ -15,7 +15,7 @@
from PIL import Image
from PIL import ImageOps
from pwnagotchi.ui.papirus.lm75b import LM75B
from pwnagotchi.ui.hw.libs.papirus.lm75b import LM75B
import re
import os
import sys

View File

@@ -0,0 +1,165 @@
import spidev
import RPi.GPIO as GPIO
import time
import numpy as np
class ST7789(object):
"""class for ST7789 240*240 1.3inch OLED displays."""
def __init__(self,spi,rst = 27,dc = 25,bl = 24):
self.width = 240
self.height = 240
#Initialize DC RST pin
self._dc = dc
self._rst = rst
self._bl = bl
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(self._dc,GPIO.OUT)
GPIO.setup(self._rst,GPIO.OUT)
GPIO.setup(self._bl,GPIO.OUT)
GPIO.output(self._bl, GPIO.HIGH)
#Initialize SPI
self._spi = spi
self._spi.max_speed_hz = 40000000
""" Write register address and data """
def command(self, cmd):
GPIO.output(self._dc, GPIO.LOW)
self._spi.writebytes([cmd])
def data(self, val):
GPIO.output(self._dc, GPIO.HIGH)
self._spi.writebytes([val])
def Init(self):
"""Initialize dispaly"""
self.reset()
self.command(0x36)
self.data(0x70) #self.data(0x00)
self.command(0x3A)
self.data(0x05)
self.command(0xB2)
self.data(0x0C)
self.data(0x0C)
self.data(0x00)
self.data(0x33)
self.data(0x33)
self.command(0xB7)
self.data(0x35)
self.command(0xBB)
self.data(0x19)
self.command(0xC0)
self.data(0x2C)
self.command(0xC2)
self.data(0x01)
self.command(0xC3)
self.data(0x12)
self.command(0xC4)
self.data(0x20)
self.command(0xC6)
self.data(0x0F)
self.command(0xD0)
self.data(0xA4)
self.data(0xA1)
self.command(0xE0)
self.data(0xD0)
self.data(0x04)
self.data(0x0D)
self.data(0x11)
self.data(0x13)
self.data(0x2B)
self.data(0x3F)
self.data(0x54)
self.data(0x4C)
self.data(0x18)
self.data(0x0D)
self.data(0x0B)
self.data(0x1F)
self.data(0x23)
self.command(0xE1)
self.data(0xD0)
self.data(0x04)
self.data(0x0C)
self.data(0x11)
self.data(0x13)
self.data(0x2C)
self.data(0x3F)
self.data(0x44)
self.data(0x51)
self.data(0x2F)
self.data(0x1F)
self.data(0x1F)
self.data(0x20)
self.data(0x23)
self.command(0x21)
self.command(0x11)
self.command(0x29)
def reset(self):
"""Reset the display"""
GPIO.output(self._rst,GPIO.HIGH)
time.sleep(0.01)
GPIO.output(self._rst,GPIO.LOW)
time.sleep(0.01)
GPIO.output(self._rst,GPIO.HIGH)
time.sleep(0.01)
def SetWindows(self, Xstart, Ystart, Xend, Yend):
#set the X coordinates
self.command(0x2A)
self.data(0x00) #Set the horizontal starting point to the high octet
self.data(Xstart & 0xff) #Set the horizontal starting point to the low octet
self.data(0x00) #Set the horizontal end to the high octet
self.data((Xend - 1) & 0xff) #Set the horizontal end to the low octet
#set the Y coordinates
self.command(0x2B)
self.data(0x00)
self.data((Ystart & 0xff))
self.data(0x00)
self.data((Yend - 1) & 0xff )
self.command(0x2C)
def ShowImage(self,Image,Xstart,Ystart):
"""Set buffer to value of Python Imaging Library image."""
"""Write display buffer to physical display"""
imwidth, imheight = Image.size
if imwidth != self.width or imheight != self.height:
raise ValueError('Image must be same dimensions as display \
({0}x{1}).' .format(self.width, self.height))
img = np.asarray(Image)
pix = np.zeros((self.width,self.height,2), dtype = np.uint8)
pix[...,[0]] = np.add(np.bitwise_and(img[...,[0]],0xF8),np.right_shift(img[...,[1]],5))
pix[...,[1]] = np.add(np.bitwise_and(np.left_shift(img[...,[1]],3),0xE0),np.right_shift(img[...,[2]],3))
pix = pix.flatten().tolist()
self.SetWindows ( 0, 0, self.width, self.height)
GPIO.output(self._dc,GPIO.HIGH)
for i in range(0,len(pix),4096):
self._spi.writebytes(pix[i:i+4096])
def clear(self):
"""Clear contents of image buffer"""
_buffer = [0xff]*(self.width * self.height * 2)
self.SetWindows ( 0, 0, self.width, self.height)
GPIO.output(self._dc,GPIO.HIGH)
for i in range(0,len(_buffer),4096):
self._spi.writebytes(_buffer[i:i+4096])

Binary file not shown.

View File

@@ -0,0 +1,76 @@
# /*****************************************************************************
# * | File : config.py
# * | Author : Guillaume Giraudon
# * | Info :
# *----------------
# * | This version: V1.0
# * | Date : 2019-10-18
# * | Info :
# ******************************************************************************/
import RPi.GPIO as GPIO
import time
from smbus import SMBus
import spidev
import ctypes
# import spidev
# Pin definition
RST_PIN = 27
DC_PIN = 25
BL_PIN = 24
Device_SPI = 1
Device_I2C = 0
Device = Device_SPI
spi = spidev.SpiDev(0, 0)
def digital_write(pin, value):
GPIO.output(pin, value)
def digital_read(pin):
return GPIO.input(BUSY_PIN)
def delay_ms(delaytime):
time.sleep(delaytime / 1000.0)
def spi_writebyte(data):
# SPI.writebytes(data)
spi.writebytes([data[0]])
def i2c_writebyte(reg, value):
bus.write_byte_data(address, reg, value)
# time.sleep(0.01)
def module_init():
# print("module_init")
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(RST_PIN, GPIO.OUT)
GPIO.setup(DC_PIN, GPIO.OUT)
# SPI.max_speed_hz = 2000000
# SPI.mode = 0b00
# i2c_writebyte(0xff,0xff)
# spi.SYSFS_software_spi_begin()
# spi.SYSFS_software_spi_setDataMode(0);
# spi.SYSFS_software_spi_setClockDivider(1);
#spi.max_speed_hz = 2000000
#spi.mode = 0b00
GPIO.output(BL_PIN, 1)
GPIO.output(DC_PIN, 0)
return 0
def module_exit():
spi.SYSFS_software_spi_end()
GPIO.output(RST_PIN, 0)
GPIO.output(DC_PIN, 0)
### END OF FILE ###

View File

@@ -0,0 +1,28 @@
from . import ST7789
from . import config
# Display resolution
EPD_WIDTH = 240
EPD_HEIGHT = 240
disp = ST7789.ST7789(config.spi,config.RST_PIN, config.DC_PIN, config.BL_PIN)
class EPD(object):
def __init__(self):
self.reset_pin = config.RST_PIN
self.dc_pin = config.DC_PIN
#self.busy_pin = config.BUSY_PIN
#self.cs_pin = config.CS_PIN
self.width = EPD_WIDTH
self.height = EPD_HEIGHT
def init(self):
disp.Init()
def Clear(self):
disp.clear()
def display(self, image):
rgb_im = image.convert('RGB')
disp.ShowImage(rgb_im,0,0)

View File

@@ -0,0 +1,135 @@
from . import config
import RPi.GPIO as GPIO
import time
Device_SPI = config.Device_SPI
Device_I2C = config.Device_I2C
LCD_WIDTH = 128 #LCD width
LCD_HEIGHT = 64 #LCD height
class SH1106(object):
def __init__(self):
self.width = LCD_WIDTH
self.height = LCD_HEIGHT
#Initialize DC RST pin
self._dc = config.DC_PIN
self._rst = config.RST_PIN
self._bl = config.BL_PIN
self.Device = config.Device
""" Write register address and data """
def command(self, cmd):
if(self.Device == Device_SPI):
GPIO.output(self._dc, GPIO.LOW)
config.spi_writebyte([cmd])
else:
config.i2c_writebyte(0x00, cmd)
# def data(self, val):
# GPIO.output(self._dc, GPIO.HIGH)
# config.spi_writebyte([val])
def Init(self):
if (config.module_init() != 0):
return -1
"""Initialize dispaly"""
self.reset()
self.command(0xAE);#--turn off oled panel
self.command(0x02);#---set low column address
self.command(0x10);#---set high column address
self.command(0x40);#--set start line address Set Mapping RAM Display Start Line (0x00~0x3F)
self.command(0x81);#--set contrast control register
self.command(0xA0);#--Set SEG/Column Mapping
self.command(0xC0);#Set COM/Row Scan Direction
self.command(0xA6);#--set normal display
self.command(0xA8);#--set multiplex ratio(1 to 64)
self.command(0x3F);#--1/64 duty
self.command(0xD3);#-set display offset Shift Mapping RAM Counter (0x00~0x3F)
self.command(0x00);#-not offset
self.command(0xd5);#--set display clock divide ratio/oscillator frequency
self.command(0x80);#--set divide ratio, Set Clock as 100 Frames/Sec
self.command(0xD9);#--set pre-charge period
self.command(0xF1);#Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
self.command(0xDA);#--set com pins hardware configuration
self.command(0x12);
self.command(0xDB);#--set vcomh
self.command(0x40);#Set VCOM Deselect Level
self.command(0x20);#-Set Page Addressing Mode (0x00/0x01/0x02)
self.command(0x02);#
self.command(0xA4);# Disable Entire Display On (0xa4/0xa5)
self.command(0xA6);# Disable Inverse Display On (0xa6/a7)
time.sleep(0.1)
self.command(0xAF);#--turn on oled panel
def reset(self):
"""Reset the display"""
GPIO.output(self._rst,GPIO.HIGH)
time.sleep(0.1)
GPIO.output(self._rst,GPIO.LOW)
time.sleep(0.1)
GPIO.output(self._rst,GPIO.HIGH)
time.sleep(0.1)
def getbuffer(self, image):
# print "bufsiz = ",(self.width/8) * self.height
buf = [0xFF] * ((self.width//8) * self.height)
image_monocolor = image.convert('1')
imwidth, imheight = image_monocolor.size
pixels = image_monocolor.load()
# print "imwidth = %d, imheight = %d",imwidth,imheight
if(imwidth == self.width and imheight == self.height):
#print ("Vertical")
for y in range(imheight):
for x in range(imwidth):
# Set the bits for the column of pixels at the current position.
if pixels[x, y] == 0:
buf[x + (y // 8) * self.width] &= ~(1 << (y % 8))
# print x,y,x + (y * self.width)/8,buf[(x + y * self.width) / 8]
elif(imwidth == self.height and imheight == self.width):
#print ("Vertical")
for y in range(imheight):
for x in range(imwidth):
newx = y
newy = self.height - x - 1
if pixels[x, y] == 0:
buf[(newx + (newy // 8 )*self.width) ] &= ~(1 << (y % 8))
return buf
# def ShowImage(self,Image):
# self.SetWindows()
# GPIO.output(self._dc, GPIO.HIGH);
# for i in range(0,self.width * self.height/8):
# config.spi_writebyte([~Image[i]])
def ShowImage(self, pBuf):
for page in range(0,8):
# set page address #
self.command(0xB0 + page);
# set low column address #
self.command(0x02);
# set high column address #
self.command(0x10);
# write data #
time.sleep(0.01)
if(self.Device == Device_SPI):
GPIO.output(self._dc, GPIO.HIGH);
for i in range(0,self.width):#for(int i=0;i<self.width; i++)
if(self.Device == Device_SPI):
config.spi_writebyte([~pBuf[i + self.width * page]]);
else :
config.i2c_writebyte(0x40, ~pBuf[i + self.width * page])
def clear(self):
"""Clear contents of image buffer"""
_buffer = [0xff]*(self.width * self.height//8)
self.ShowImage(_buffer)
#print "%d",_buffer[i:i+4096]

View File

@@ -0,0 +1,111 @@
# /*****************************************************************************
# * | File : config.py
# * | Author : Waveshare team
# * | Function : Hardware underlying interface,for Jetson nano
# * | Info :
# *----------------
# * | This version: V1.0
# * | Date : 2019-06-06
# * | Info :
# ******************************************************************************/
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
import RPi.GPIO as GPIO
import time
from smbus import SMBus
import spidev
import ctypes
# import spidev
# Pin definition
RST_PIN = 25
DC_PIN = 24
CS_PIN = 8
BL_PIN = 18
BUSY_PIN = 18
Device_SPI = 1
Device_I2C = 0
if(Device_SPI == 1):
Device = Device_SPI
spi = spidev.SpiDev(0, 0)
else :
Device = Device_I2C
address = 0x3C
bus = SMBus(1)
def digital_write(pin, value):
GPIO.output(pin, value)
def digital_read(pin):
return GPIO.input(BUSY_PIN)
def delay_ms(delaytime):
time.sleep(delaytime / 1000.0)
def spi_writebyte(data):
# SPI.writebytes(data)
spi.writebytes([data[0]])
def i2c_writebyte(reg, value):
bus.write_byte_data(address, reg, value)
# time.sleep(0.01)
def module_init():
# print("module_init")
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(RST_PIN, GPIO.OUT)
GPIO.setup(DC_PIN, GPIO.OUT)
GPIO.setup(CS_PIN, GPIO.OUT)
GPIO.setup(BL_PIN, GPIO.OUT)
# SPI.max_speed_hz = 2000000
# SPI.mode = 0b00
# i2c_writebyte(0xff,0xff)
if(Device == Device_SPI):
# spi.SYSFS_software_spi_begin()
# spi.SYSFS_software_spi_setDataMode(0);
# spi.SYSFS_software_spi_setClockDivider(1);
spi.max_speed_hz = 2000000
spi.mode = 0b00
GPIO.output(CS_PIN, 0)
GPIO.output(BL_PIN, 1)
GPIO.output(DC_PIN, 0)
return 0
def module_exit():
if(Device == Device_SPI):
spi.SYSFS_software_spi_end()
else :
bus.close()
GPIO.output(RST_PIN, 0)
GPIO.output(DC_PIN, 0)
### END OF FILE ###

View File

@@ -0,0 +1,27 @@
from . import SH1106
from . import config
# Display resolution
EPD_WIDTH = 64
EPD_HEIGHT = 128
disp = SH1106.SH1106()
class EPD(object):
def __init__(self):
self.reset_pin = config.RST_PIN
self.dc_pin = config.DC_PIN
self.busy_pin = config.BUSY_PIN
self.cs_pin = config.CS_PIN
self.width = EPD_WIDTH
self.height = EPD_HEIGHT
def init(self):
disp.Init()
def Clear(self):
disp.clear()
def display(self, image):
disp.ShowImage(disp.getbuffer(image))

View File

@@ -30,7 +30,6 @@
import logging
from . import epdconfig
import numpy as np
# Display resolution
EPD_WIDTH = 122

View File

@@ -27,9 +27,7 @@
# THE SOFTWARE.
#
import logging
from . import epdconfig
from PIL import Image
import RPi.GPIO as GPIO
# import numpy as np

View File

@@ -0,0 +1,45 @@
import logging
import pwnagotchi.ui.fonts as fonts
from pwnagotchi.ui.hw.base import DisplayImpl
class OledHat(DisplayImpl):
def __init__(self, config):
super(OledHat, self).__init__(config, 'oledhat')
self._display = None
def layout(self):
fonts.setup(8, 8, 8, 8)
self._layout['width'] = 128
self._layout['height'] = 64
self._layout['face'] = (0, 32)
self._layout['name'] = (0, 10)
self._layout['channel'] = (0, 0)
self._layout['aps'] = (25, 0)
self._layout['uptime'] = (65, 0)
self._layout['line1'] = [0, 9, 128, 9]
self._layout['line2'] = [0, 53, 128, 53]
self._layout['friend_face'] = (0, 41)
self._layout['friend_name'] = (40, 43)
self._layout['shakes'] = (0, 53)
self._layout['mode'] = (103, 10)
self._layout['status'] = {
'pos': (30, 18),
'font': fonts.Small,
'max': 18
}
return self._layout
def initialize(self):
logging.info("initializing oledhat display")
from pwnagotchi.ui.hw.libs.waveshare.oledhat.epd import EPD
self._display = EPD()
self._display.init()
self._display.Clear()
def render(self, canvas):
self._display.display(canvas)
def clear(self):
self._display.clear()

View File

@@ -0,0 +1,47 @@
import logging
import os
import pwnagotchi.ui.fonts as fonts
from pwnagotchi.ui.hw.base import DisplayImpl
class Papirus(DisplayImpl):
def __init__(self, config):
super(Papirus, self).__init__(config, 'papirus')
self._display = None
def layout(self):
fonts.setup(10, 8, 10, 23)
self._layout['width'] = 200
self._layout['height'] = 96
self._layout['face'] = (0, 24)
self._layout['name'] = (5, 14)
self._layout['channel'] = (0, 0)
self._layout['aps'] = (25, 0)
self._layout['uptime'] = (135, 0)
self._layout['line1'] = [0, 11, 200, 11]
self._layout['line2'] = [0, 85, 200, 85]
self._layout['friend_face'] = (0, 69)
self._layout['friend_name'] = (40, 71)
self._layout['shakes'] = (0, 86)
self._layout['mode'] = (175, 86)
self._layout['status'] = {
'pos': (85, 14),
'font': fonts.Medium,
'max': 16
}
return self._layout
def initialize(self):
logging.info("initializing papirus display")
from pwnagotchi.ui.hw.libs.papirus.epd import EPD
os.environ['EPD_SIZE'] = '2.0'
self._display = EPD()
self._display.clear()
def render(self, canvas):
self._display.display(canvas)
self._display.partial_update()
def clear(self):
self._display.clear()

View File

@@ -0,0 +1,85 @@
import logging
import pwnagotchi.ui.fonts as fonts
from pwnagotchi.ui.hw.base import DisplayImpl
class WaveshareV1(DisplayImpl):
def __init__(self, config):
super(WaveshareV1, self).__init__(config, 'waveshare_1')
self._display = None
def layout(self):
if self.config['color'] == 'black':
fonts.setup(10, 9, 10, 35)
self._layout['width'] = 250
self._layout['height'] = 122
self._layout['face'] = (0, 40)
self._layout['name'] = (5, 20)
self._layout['channel'] = (0, 0)
self._layout['aps'] = (28, 0)
self._layout['uptime'] = (185, 0)
self._layout['line1'] = [0, 14, 250, 14]
self._layout['line2'] = [0, 108, 250, 108]
self._layout['friend_face'] = (0, 92)
self._layout['friend_name'] = (40, 94)
self._layout['shakes'] = (0, 109)
self._layout['mode'] = (225, 109)
self._layout['status'] = {
'pos': (125, 20),
'font': fonts.Medium,
'max': 20
}
else:
fonts.setup(10, 8, 10, 25)
self._layout['width'] = 212
self._layout['height'] = 104
self._layout['face'] = (0, 26)
self._layout['name'] = (5, 15)
self._layout['channel'] = (0, 0)
self._layout['aps'] = (28, 0)
self._layout['uptime'] = (147, 0)
self._layout['line1'] = [0, 12, 212, 12]
self._layout['line2'] = [0, 92, 212, 92]
self._layout['friend_face'] = (0, 76)
self._layout['friend_name'] = (40, 78)
self._layout['shakes'] = (0, 93)
self._layout['mode'] = (187, 93)
self._layout['status'] = {
'pos': (91, 15),
'font': fonts.Medium,
'max': 20
}
return self._layout
def initialize(self):
if self.config['color'] == 'black':
logging.info("initializing waveshare v1 display in monochromatic mode")
from pwnagotchi.ui.hw.libs.waveshare.v1.epd2in13 import EPD
self._display = EPD()
self._display.init(self._display.lut_full_update)
self._display.Clear(0xFF)
self._display.init(self._display.lut_partial_update)
else:
logging.info("initializing waveshare v1 display 3-color mode")
from pwnagotchi.ui.hw.libs.waveshare.v1.epd2in13bc import EPD
self._display = EPD()
self._display.init()
self._display.Clear()
def render(self, canvas):
if self.config['color'] == 'black':
buf = self._display.getbuffer(canvas)
self._display.display(buf)
else:
buf_black = self._display.getbuffer(canvas)
# emptyImage = Image.new('1', (self._display.height, self._display.width), 255)
# buf_color = self._display.getbuffer(emptyImage)
# self._display.display(buf_black,buf_color)
# Custom display function that only handles black
# Was included in epd2in13bc.py
self._display.displayBlack(buf_black)
def clear(self):
self._display.Clear(0xff)

View File

@@ -0,0 +1,69 @@
import logging
import pwnagotchi.ui.fonts as fonts
from pwnagotchi.ui.hw.base import DisplayImpl
class WaveshareV2(DisplayImpl):
def __init__(self, config):
super(WaveshareV2, self).__init__(config, 'waveshare_2')
self._display = None
def layout(self):
if self.config['color'] == 'black':
fonts.setup(10, 9, 10, 35)
self._layout['width'] = 250
self._layout['height'] = 122
self._layout['face'] = (0, 40)
self._layout['name'] = (5, 20)
self._layout['channel'] = (0, 0)
self._layout['aps'] = (28, 0)
self._layout['uptime'] = (185, 0)
self._layout['line1'] = [0, 14, 250, 14]
self._layout['line2'] = [0, 108, 250, 108]
self._layout['friend_face'] = (0, 92)
self._layout['friend_name'] = (40, 94)
self._layout['shakes'] = (0, 109)
self._layout['mode'] = (225, 109)
self._layout['status'] = {
'pos': (125, 20),
'font': fonts.Medium,
'max': 20
}
else:
fonts.setup(10, 8, 10, 25)
self._layout['width'] = 212
self._layout['height'] = 104
self._layout['face'] = (0, 26)
self._layout['name'] = (5, 15)
self._layout['channel'] = (0, 0)
self._layout['aps'] = (28, 0)
self._layout['status'] = (91, 15)
self._layout['uptime'] = (147, 0)
self._layout['line1'] = [0, 12, 212, 12]
self._layout['line2'] = [0, 92, 212, 92]
self._layout['friend_face'] = (0, 76)
self._layout['friend_name'] = (40, 78)
self._layout['shakes'] = (0, 93)
self._layout['mode'] = (187, 93)
self._layout['status'] = {
'pos': (125, 20),
'font': fonts.Medium,
'max': 14
}
return self._layout
def initialize(self):
logging.info("initializing waveshare v2 display")
from pwnagotchi.ui.hw.libs.waveshare.v2.waveshare import EPD
self._display = EPD()
self._display.init(self._display.FULL_UPDATE)
self._display.Clear(0xff)
self._display.init(self._display.PART_UPDATE)
def render(self, canvas):
buf = self._display.getbuffer(canvas)
self._display.displayPartial(buf)
def clear(self):
self._display.Clear(0xff)

View File

@@ -18,64 +18,8 @@ BLACK = 0x00
ROOT = None
def setup_display_specifics(config):
width = 0
height = 0
face_pos = (0, 0)
name_pos = (0, 0)
status_pos = (0, 0)
status_font = fonts.Medium
status_max_length = None
if config['ui']['display']['type'] in ('inky', 'inkyphat'):
fonts.setup(10, 8, 10, 28)
width = 212
height = 104
face_pos = (0, 37)
name_pos = (5, 18)
status_pos = (102, 18)
status_font = fonts.Small
status_max_length = 20
elif config['ui']['display']['type'] in ('papirus', 'papi'):
fonts.setup(10, 8, 10, 23)
width = 200
height = 96
face_pos = (0, int(height / 4))
name_pos = (5, int(height * .15))
status_pos = (int(width / 2) - 15, int(height * .15))
status_font = fonts.Medium
status_max_length = (width - status_pos[0]) // 6
elif config['ui']['display']['type'] in ('ws_1', 'ws1', 'waveshare_1', 'waveshare1',
'ws_2', 'ws2', 'waveshare_2', 'waveshare2'):
if config['ui']['display']['color'] == 'black':
fonts.setup(10, 9, 10, 35)
width = 250
height = 122
face_pos = (0, 40)
name_pos = (5, 20)
status_pos = (125, 20)
status_font = fonts.Medium
else:
fonts.setup(10, 8, 10, 25)
width = 212
height = 104
face_pos = (0, int(height / 4))
name_pos = (5, int(height * .15))
status_pos = (int(width / 2) - 15, int(height * .15))
status_font = fonts.Medium
status_max_length = (width - status_pos[0]) // 6
return width, height, face_pos, name_pos, status_pos, status_font, status_max_length
class View(object):
def __init__(self, config, state={}):
def __init__(self, config, impl, state=None):
global ROOT
self._render_cbs = []
@@ -84,51 +28,49 @@ class View(object):
self._frozen = False
self._lock = Lock()
self._voice = Voice(lang=config['main']['lang'])
self._width, self._height, \
face_pos, name_pos, status_pos, status_font, status_max_length = setup_display_specifics(config)
self._implementation = impl
self._layout = impl.layout()
self._width = self._layout['width']
self._height = self._layout['height']
self._state = State(state={
'channel': LabeledValue(color=BLACK, label='CH', value='00', position=(0, 0), label_font=fonts.Bold,
'channel': LabeledValue(color=BLACK, label='CH', value='00', position=self._layout['channel'],
label_font=fonts.Bold,
text_font=fonts.Medium),
'aps': LabeledValue(color=BLACK, label='APS', value='0 (00)', position=(30, 0), label_font=fonts.Bold,
text_font=fonts.Medium),
# 'epoch': LabeledValue(color=BLACK, label='E', value='0000', position=(145, 0), label_font=fonts.Bold,
# text_font=fonts.Medium),
'uptime': LabeledValue(color=BLACK, label='UP', value='00:00:00', position=(self._width - 65, 0),
'aps': LabeledValue(color=BLACK, label='APS', value='0 (00)', position=self._layout['aps'],
label_font=fonts.Bold,
text_font=fonts.Medium),
'line1': Line([0, int(self._height * .12), self._width, int(self._height * .12)], color=BLACK),
'line2': Line(
[0, self._height - int(self._height * .12), self._width, self._height - int(self._height * .12)],
'uptime': LabeledValue(color=BLACK, label='UP', value='00:00:00', position=self._layout['uptime'],
label_font=fonts.Bold,
text_font=fonts.Medium),
'line1': Line(self._layout['line1'], color=BLACK),
'line2': Line(self._layout['line2'], color=BLACK),
'face': Text(value=faces.SLEEP, position=self._layout['face'], color=BLACK, font=fonts.Huge),
'friend_face': Text(value=None, position=self._layout['friend_face'], font=fonts.Bold, color=BLACK),
'friend_name': Text(value=None, position=self._layout['friend_name'], font=fonts.BoldSmall,
color=BLACK),
'face': Text(value=faces.SLEEP, position=face_pos, color=BLACK, font=fonts.Huge),
'friend_face': Text(value=None, position=(0, (self._height * 0.88) - 15), font=fonts.Bold, color=BLACK),
'friend_name': Text(value=None, position=(40, (self._height * 0.88) - 13), font=fonts.BoldSmall,
color=BLACK),
'name': Text(value='%s>' % 'pwnagotchi', position=name_pos, color=BLACK, font=fonts.Bold),
'name': Text(value='%s>' % 'pwnagotchi', position=self._layout['name'], color=BLACK, font=fonts.Bold),
'status': Text(value=self._voice.default(),
position=status_pos,
position=self._layout['status']['pos'],
color=BLACK,
font=status_font,
font=self._layout['status']['font'],
wrap=True,
# the current maximum number of characters per line, assuming each character is 6 pixels wide
max_length=status_max_length),
max_length=self._layout['status']['max']),
'shakes': LabeledValue(label='PWND ', value='0 (00)', color=BLACK,
position=(0, self._height - int(self._height * .12) + 1), label_font=fonts.Bold,
position=self._layout['shakes'], label_font=fonts.Bold,
text_font=fonts.Medium),
'mode': Text(value='AUTO', position=(self._width - 25, self._height - int(self._height * .12) + 1),
'mode': Text(value='AUTO', position=self._layout['mode'],
font=fonts.Bold, color=BLACK),
})
if state:
for key, value in state.items():
self._state.set(key, value)

View File

@@ -31,11 +31,19 @@ def load_config(args):
ref_defaults_file = os.path.join(os.path.dirname(pwnagotchi.__file__), 'defaults.yml')
ref_defaults_data = None
if not os.path.exists(args.config):
# check for a config.yml file on /boot/
if os.path.exists("/boot/config.yml"):
# logging not configured here yet
print("installing /boot/config.yml to %s ...", args.user_config)
# https://stackoverflow.com/questions/42392600/oserror-errno-18-invalid-cross-device-link
shutil.move("/boot/config.yml", args.user_config)
# if not config is found, copy the defaults
if not os.path.exists(args.config):
print("copying %s to %s ..." % (ref_defaults_file, args.config))
shutil.copy(ref_defaults_file, args.config)
else:
# check if the user messed with the defaults
with open(ref_defaults_file) as fp:
ref_defaults_data = fp.read()
@@ -46,9 +54,11 @@ def load_config(args):
print("!!! file in %s is different than release defaults, overwriting !!!" % args.config)
shutil.copy(ref_defaults_file, args.config)
# load the defaults
with open(args.config) as fp:
config = yaml.safe_load(fp)
# load the user config
if os.path.exists(args.user_config):
with open(args.user_config) as fp:
user_config = yaml.safe_load(fp)
@@ -56,6 +66,28 @@ def load_config(args):
if user_config:
config = merge_config(user_config, config)
# the very first step is to normalize the display name so we don't need dozens of if/elif around
if config['ui']['display']['type'] in ('inky', 'inkyphat'):
config['ui']['display']['type'] = 'inky'
elif config['ui']['display']['type'] in ('papirus', 'papi'):
config['ui']['display']['type'] = 'papirus'
elif config['ui']['display']['type'] in ('oledhat'):
config['ui']['display']['type'] = 'oledhat'
elif config['ui']['display']['type'] in ('ws_1', 'ws1', 'waveshare_1', 'waveshare1'):
config['ui']['display']['type'] = 'waveshare_1'
elif config['ui']['display']['type'] in ('ws_2', 'ws2', 'waveshare_2', 'waveshare2'):
config['ui']['display']['type'] = 'waveshare_2'
else:
print("unsupported display type %s" % config['ui']['display']['type'])
exit(1)
print("Effective Configuration:")
print(yaml.dump(config, default_flow_style=False))
return config
@@ -109,6 +141,7 @@ def blink(times=1, delay=0.3):
time.sleep(delay)
led(True)
class WifiInfo(Enum):
"""
Fields you can extract from a pcap file
@@ -119,6 +152,7 @@ class WifiInfo(Enum):
CHANNEL = 3
RSSI = 4
class FieldNotFoundError(Exception):
pass

View File

@@ -14,6 +14,9 @@ class Voice:
translation.install()
self._ = translation.gettext
def custom(self, s):
return s
def default(self):
return self._('ZzzzZZzzzzZzzz')
@@ -68,8 +71,8 @@ class Voice:
def on_new_peer(self, peer):
return random.choice([
self._('Hello {name}! Nice to meet you. {name}').format(name=peer.name()),
self._('Unit {name} is nearby! {name}').format(name=peer.name())])
self._('Hello {name}! Nice to meet you.').format(name=peer.name()),
self._('Unit {name} is nearby!').format(name=peer.name())])
def on_lost_peer(self, peer):
return random.choice([

View File

@@ -13,3 +13,4 @@ inky==0.0.5
smbus2==0.3.0
Pillow==5.4.1
spidev==3.4
gast==0.2.2

View File

@@ -1,351 +0,0 @@
#!/usr/bin/env bash
# based on: https://wiki.debian.org/RaspberryPi/qemu-user-static
## and https://z4ziggy.wordpress.com/2015/05/04/from-bochs-to-chroot/
set -eu
REQUIREMENTS=( wget gunzip git dd e2fsck resize2fs parted losetup qemu-system-x86_64 )
DEBREQUIREMENTS=( wget gzip git parted qemu-system-x86 qemu-user-static )
REPO_DIR="$(dirname "$(dirname "$(realpath "$0")")")"
TMP_DIR="${REPO_DIR}/tmp"
MNT_DIR="${TMP_DIR}/mnt"
THIS_DIR=$(pwd)
PWNI_NAME="pwnagotchi"
PWNI_OUTPUT="pwnagotchi.img"
PWNI_SIZE="8"
OPT_SPARSE=0
OPT_PROVISION_ONLY=0
OPT_CHECK_DEPS_ONLY=0
OPT_IMAGE_PROVIDED=0
OPT_RASPBIAN_VERSION='latest'
OPT_APTPROXY=""
SUPPORTED_RASPBIAN_VERSIONS=( 'latest' 'buster' 'stretch' )
if [[ "$EUID" -ne 0 ]]; then
echo "Run this script as root!"
exit 1
fi
function check_dependencies() {
if [ -f /etc/debian_version ];
then
echo "[+] Checking Debian dependencies"
for REQ in "${DEBREQUIREMENTS[@]}"; do
if ! dpkg -s "$REQ" >/dev/null 2>&1; then
echo "Dependency check failed for ${REQ}; use 'apt-get install ${REQ}' to install"
exit 1
fi
done
fi
echo "[+] Checking dependencies"
for REQ in "${REQUIREMENTS[@]}"; do
if ! type "$REQ" >/dev/null 2>&1; then
echo "Dependency check failed for ${REQ}"
exit 1
fi
done
if ! test -e /usr/bin/qemu-arm-static; then
echo "[-] You need the package \"qemu-user-static\" for this to work."
exit 1
fi
if ! systemctl is-active systemd-binfmt.service >/dev/null 2>&1; then
mkdir -p "/lib/binfmt.d"
echo ':qemu-arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:F' > /lib/binfmt.d/qemu-arm-static.conf
systemctl restart systemd-binfmt.service
fi
}
function get_raspbian() {
VERSION="$1"
case "$VERSION" in
latest)
URL="https://downloads.raspberrypi.org/raspbian_lite_latest"
;;
buster)
URL="https://downloads.raspberrypi.org/raspbian/images/raspbian-2019-07-12/2019-07-10-raspbian-buster.zip"
;;
stretch)
URL="https://downloads.raspberrypi.org/raspbian/images/raspbian-2019-04-09/2019-04-08-raspbian-stretch.zip"
;;
esac
echo "[+] Downloading raspbian.zip"
mkdir -p "${TMP_DIR}"
wget --show-progress -qcO "${TMP_DIR}/raspbian.zip" "$URL"
echo "[+] Unpacking raspbian.zip to raspbian.img"
gunzip -c "${TMP_DIR}/raspbian.zip" > "${TMP_DIR}/raspbian.img"
}
function provide_raspbian() {
echo "[+] Providing path of raspbian file"
mkdir -p "${TMP_DIR}"
echo "[+] Unpacking raspbian.zip to raspbian.img"
gunzip -c "${PWNI_INPUT}" > "${TMP_DIR}/raspbian.img"
}
function setup_raspbian(){
# Detect the ability to create sparse files
if [ "${OPT_SPARSE}" -eq 0 ]; then
if ! type "bmaptool" >/dev/null 2>&1; then
echo "[!] bmaptool not available, not creating a sparse image"
else
echo "[+] Defaulting to sparse image generation as bmaptool is available"
OPT_SPARSE=1
fi
fi
# Note that we 'extend' the raspbian.img
if [ "${OPT_SPARSE}" -eq 1 ];
then
# Resize sparse (so that we can use bmaptool later)
echo "[+] Resizing sparse image of ${PWNI_SIZE}GB (1000s)"
truncate -s ${PWNI_SIZE}GB "${TMP_DIR}/raspbian.img"
else
echo "[+] Resizing full image to ${PWNI_SIZE}G"
# Full disk-space using image (appends to raspbian image)
dd if=/dev/zero bs=1G count="${PWNI_SIZE}" >> "${TMP_DIR}/raspbian.img"
fi
echo "[+] Setup loop device"
mkdir -p "${MNT_DIR}"
LOOP_PATH="$(losetup --find --partscan --show "${TMP_DIR}/raspbian.img")"
PART2_START="$(parted -s "$LOOP_PATH" -- print | awk '$1==2{ print $2 }')"
parted -s "$LOOP_PATH" rm 2
parted -s "$LOOP_PATH" mkpart primary "$PART2_START" 100%
echo "[+] Check FS"
e2fsck -y -f "${LOOP_PATH}p2"
echo "[+] Resize FS"
resize2fs "${LOOP_PATH}p2"
echo "[+] Device is ${LOOP_PATH}"
echo "[+] Unmount if already mounted with other img"
mountpoint -q "${MNT_DIR}" && umount -R "${MNT_DIR}"
echo "[+] Mount /"
mount -o rw "${LOOP_PATH}p2" "${MNT_DIR}"
echo "[+] Mount /boot"
mount -o rw "${LOOP_PATH}p1" "${MNT_DIR}/boot"
mount --bind /dev "${MNT_DIR}/dev/"
mount --bind /sys "${MNT_DIR}/sys/"
mount --bind /proc "${MNT_DIR}/proc/"
mount --bind /dev/pts "${MNT_DIR}/dev/pts"
cp /usr/bin/qemu-arm-static "${MNT_DIR}/usr/bin"
cp /etc/resolv.conf "${MNT_DIR}/etc/resolv.conf"
}
function provision_raspbian() {
cd "${MNT_DIR}"
sed -i'' 's/^\([^#]\)/#\1/g' etc/ld.so.preload # add comments
echo "[+] Run chroot commands"
LANG=C LC_ALL=C LC_CTYPE=C chroot . bin/bash -x <<EOF
set -eu
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
if [ ! -z "${OPT_APTPROXY}" ];
then
echo "[+] Using Proxy ${OPT_APTPROXY}"
echo "Acquire::http { Proxy \"${OPT_APTPROXY}\"; }" >/etc/apt/apt.conf.d/99pwnagotchi_proxy
fi
uname -a
apt-get -y update
apt-get -y upgrade
apt-get -y install git vim screen build-essential golang python3-pip gawk
apt-get -y install libpcap-dev libusb-1.0-0-dev libnetfilter-queue-dev
apt-get -y install dphys-swapfile libopenmpi-dev libatlas-base-dev
apt-get -y install libjasper-dev libqtgui4 libqt4-test libopenjp2-7
apt-get -y install tcpdump libilmbase23 libopenexr23 libgstreamer1.0-0
apt-get -y install libavcodec58 libavformat58 libswscale5
# setup dphys-swapfile
echo "CONF_SWAPSIZE=1024" >/etc/dphys-swapfile
systemctl enable dphys-swapfile.service
# install pwnagotchi
cd /tmp
git clone https://github.com/evilsocket/pwnagotchi.git
rsync -aP pwnagotchi/sdcard/boot/* /boot/
rsync -aP pwnagotchi/sdcard/rootfs/* /
rm -rf /tmp/pwnagotchi
# configure pwnagotchi
echo -e "$PWNI_NAME" > /etc/hostname
sed -i "s@^127\.0\.0\.1 .*@127.0.0.1 localhost "$PWNI_NAME" "$PWNI_NAME".local@g" /etc/hosts
sed -i "s@alpha@$PWNI_NAME@g" /etc/motd
chmod +x /etc/rc.local
# need armv6l version of tensorflow and opencv-python, not armv7l
# PIP_OPTS="--upgrade --only-binary :all: --abi cp37m --platform linux_armv6l --target /usr/lib/python3.7/site-packages/"
# pip3 install \$PIP_OPTS opencv-python
# Should work for tensorflow too, but BUG: Hash mismatch; therefore:
wget -P /root/ -c https://www.piwheels.org/simple/tensorflow/tensorflow-1.13.1-cp37-none-linux_armv6l.whl
wget -P /root/ -c https://www.piwheels.org/simple/opencv-python/opencv_python-3.4.3.18-cp37-cp37m-linux_armv6l.whl
# we need to install these on first raspberry start...
sed -i '/startup\.sh/i pip3 install --no-deps --force-reinstall --upgrade /root/tensorflow-1.13.1-cp37-none-linux_armv6l.whl /root/opencv_python-3.4.3.18-cp37-cp37m-linux_armv6l.whl && rm /root/tensorflow-1.13.1-cp37-none-linux_armv6l.whl /root/opencv_python-3.4.3.18-cp37-cp37m-linux_armv6l.whl && sed -i "/tensorflow/d" /etc/rc.local' /etc/rc.local
# newer version is broken
pip3 install gast==0.2.2
</root/pwnagotchi/scripts/requirements.txt xargs -I{} --max-args=1 --max-procs="$(nproc)"\
pip3 install --progress-bar off {}
# waveshare
pip3 install spidev RPi.GPIO
# install bettercap
export GOPATH=/root/go
taskset -c 1 go get -u github.com/bettercap/bettercap
mv "\$GOPATH/bin/bettercap" /usr/bin/bettercap
# install bettercap caplets (cant run bettercap in chroot)
cd /tmp
git clone https://github.com/bettercap/caplets.git
cd caplets
make install
rm -rf /tmp/caplets
cd /root # fixes getcwd error that was bugging me
# Re4son-Kernel
echo "deb http://http.re4son-kernel.com/re4son/ kali-pi main" > /etc/apt/sources.list.d/re4son.list
wget -O - https://re4son-kernel.com/keys/http/archive-key.asc | apt-key add -
apt update
apt install -y kalipi-kernel kalipi-bootloader kalipi-re4son-firmware kalipi-kernel-headers libraspberrypi0 libraspberrypi-dev libraspberrypi-doc libraspberrypi-bin
# Fix PARTUUID
PUUID_ROOT="\$(blkid "\$(df / --output=source | tail -1)" | grep -Po 'PARTUUID="\K[^"]+')"
PUUID_BOOT="\$(blkid "\$(df /boot --output=source | tail -1)" | grep -Po 'PARTUUID="\K[^"]+')"
# sed regex info: search for line containing / followed by whitespace or /boot (second sed)
# in this line, search for PARTUUID= followed by letters, numbers or "-"
# replace that match with the new PARTUUID
sed -i "/\/[ ]\+/s/PARTUUID=[A-Za-z0-9-]\+/PARTUUID=\$PUUID_ROOT/g" /etc/fstab
sed -i "/\/boot/s/PARTUUID=[A-Za-z0-9-]\+/PARTUUID=\$PUUID_BOOT/g" /etc/fstab
sed -i "s/root=[^ ]\+/root=PARTUUID=\${PUUID_ROOT}/g" /boot/cmdline.txt
# delete keys
find /etc/ssh/ -name "ssh_host_*key*" -delete
# slows down boot
systemctl disable apt-daily.timer apt-daily.service apt-daily-upgrade.timer apt-daily-upgrade.service
# unecessary services
systemctl disable triggerhappy bluetooth wpa_supplicant
EOF
sed -i'' 's/^#//g' etc/ld.so.preload
cd "${REPO_DIR}"
umount -R "${MNT_DIR}"
losetup -D "$(losetup -l | awk '/raspbian\.img/{print $1}')"
mv "${TMP_DIR}/raspbian.img" "${PWNI_OUTPUT}"
if [ "${OPT_SPARSE}" -eq 1 ];
then
bmaptool create -o "${PWNI_OUTPUT}.bmap" "${PWNI_OUTPUT}"
fi
}
function usage() {
cat <<EOF
usage: $0 [OPTIONS]
Options:
-n <name> # Name of the pwnagotchi (default: pwnagotchi)
-i <file> # Provide the path of an already downloaded raspbian image
-o <file> # Name of the img-file (default: pwnagotchi.img)
-s <size> # Size which should be added to second partition (in Gigabyte) (default: 4)
-v <version> # Version of raspbian (Supported: ${SUPPORTED_RASPBIAN_VERSIONS[*]}; default: latest)
-p # Only run provisioning (assumes the image is already mounted)
-d # Only run dependencies checks
-h # Show this help
EOF
exit 0
}
while getopts "A:n:i:o:s:v:dph" o; do
case "${o}" in
A)
OPT_APTPROXY="${OPTARG}"
;;
n)
PWNI_NAME="${OPTARG}"
;;
i)
PWNI_INPUT="${OPTARG}"
OPT_IMAGE_PROVIDED=1
;;
o)
PWNI_OUTPUT="${OPTARG}"
;;
s)
PWNI_SIZE="${OPTARG}"
;;
p)
OPT_PROVISION_ONLY=1
;;
d)
OPT_CHECK_DEPS_ONLY=1
;;
v)
if [[ "${SUPPORTED_RASPBIAN_VERSIONS[*]}" =~ ${OPTARG} ]]; then
OPT_RASPBIAN_VERSION="${OPTARG}"
else
usage
fi
;;
h)
usage
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [[ "$OPT_PROVISION_ONLY" -eq 1 ]]; then
provision_raspbian
exit 0
elif [[ "$OPT_CHECK_DEPS_ONLY" -eq 1 ]]; then
check_dependencies
exit 0
fi
check_dependencies
if [[ "$OPT_IMAGE_PROVIDED" -eq 1 ]]; then
provide_raspbian
else
get_raspbian "$OPT_RASPBIAN_VERSION"
fi
setup_raspbian
provision_raspbian
#Make a baby with a random gender, maybe do something fun with this later!
gender[0]="boy"
gender[1]="girl"
rand=$[ $RANDOM % 2 ]
echo -e "[+] Congratz, it's a ${gender[$rand]} (⌐■_■)!"
echo -e "[+] One more step: dd if=../${PWNI_OUTPUT} of=<PATH_TO_SDCARD> bs=4M status=progress"
if [ "${OPT_SPARSE}" -eq 1 ];
then
echo -e "[t] To transfer use: rsync -vaS --progress $(whoami)@$(hostname -f):${THIS_DIR}/../${PWNI_OUTPUT} <DEST>"
echo -e "[t] To burn with bmaptool: bmaptool copy ~/${PWNI_OUTPUT} /dev/<DEVICE>"
fi
# Helpful OSX reminder
echo -e "[t] Mac: use 'diskutil list' to figure out which device to burn to; 'diskutil unmountDisk' to unmount that disk'; then use /dev/rdiskX (note the 'r') for faster transfer"