From a808fd33c7d71bf8bac3a827fd66e8775735cd91 Mon Sep 17 00:00:00 2001
From: dadav <33197631+dadav@users.noreply.github.com>
Date: Tue, 14 Apr 2020 21:53:17 +0200
Subject: [PATCH 1/9] another toml fix in paradise
---
builder/pwnagotchi.yml | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/builder/pwnagotchi.yml b/builder/pwnagotchi.yml
index 86924de..a0c08e7 100644
--- a/builder/pwnagotchi.yml
+++ b/builder/pwnagotchi.yml
@@ -311,21 +311,17 @@
- name: check if user configuration exists
stat:
- path: /etc/pwnagotchi/config.yml
+ path: /etc/pwnagotchi/config.toml
register: user_config
- - name: create /etc/pwnagotchi/config.yml
+ - name: create /etc/pwnagotchi/config.toml
copy:
- dest: /etc/pwnagotchi/config.yml
+ dest: /etc/pwnagotchi/config.toml
content: |
- # Add your configuration overrides on this file any configuration changes done to default.yml will be lost!
+ # Add your configuration overrides on this file any configuration changes done to default.toml will be lost!
# Example:
- #
- # ui:
- # display:
- # type: 'inkyphat'
- # color: 'black'
- #
+ # ui.display.enabled = true
+ # ui.display.type = "waveshare_2"
when: not user_config.stat.exists
- name: enable ssh on boot
@@ -372,9 +368,9 @@
Hi! I'm a pwnagotchi, please take good care of me!
Here are some basic things you need to know to raise me properly!
- If you want to change my configuration, use /etc/pwnagotchi/config.yml
+ If you want to change my configuration, use /etc/pwnagotchi/config.toml
- All the configuration options can be found on /etc/pwnagotchi/default.yml,
+ All the configuration options can be found on /etc/pwnagotchi/default.toml,
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.
From 8a07e822e69a7ad1297bb98f593604872200afde Mon Sep 17 00:00:00 2001
From: dadav <33197631+dadav@users.noreply.github.com>
Date: Tue, 14 Apr 2020 22:20:42 +0200
Subject: [PATCH 2/9] breaks if never used
---
pwnagotchi/plugins/__init__.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/pwnagotchi/plugins/__init__.py b/pwnagotchi/plugins/__init__.py
index 2ffd21c..08d0b76 100644
--- a/pwnagotchi/plugins/__init__.py
+++ b/pwnagotchi/plugins/__init__.py
@@ -44,6 +44,8 @@ def toggle_plugin(name, enable=True):
global loaded, database
if pwnagotchi.config:
+ if not name in pwnagotchi.config['main']['plugins']:
+ pwnagotchi.config['main']['plugins'][name] = dict()
pwnagotchi.config['main']['plugins'][name]['enabled'] = enable
save_config(pwnagotchi.config, '/etc/pwnagotchi/config.toml')
From 6805df858efb279b4a2031f79a88f1afa136ab9f Mon Sep 17 00:00:00 2001
From: dadav <33197631+dadav@users.noreply.github.com>
Date: Wed, 15 Apr 2020 08:20:47 +0200
Subject: [PATCH 3/9] basename should be dirname
---
pwnagotchi/ui/web/__init__.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pwnagotchi/ui/web/__init__.py b/pwnagotchi/ui/web/__init__.py
index 7d5f4a0..533f2f7 100644
--- a/pwnagotchi/ui/web/__init__.py
+++ b/pwnagotchi/ui/web/__init__.py
@@ -9,7 +9,7 @@ frame_lock = Lock()
def update_frame(img):
global frame_lock, frame_path, frame_format
- if not os.path.exists(os.path.basename(frame_path)):
- os.makedirs(os.path.basename(frame_path))
+ if not os.path.exists(os.path.dirname(frame_path)):
+ os.makedirs(os.path.dirname(frame_path))
with frame_lock:
img.save(frame_path, format=frame_format)
From e53bdc46a4b63a60fea67d79bdfd3d3b00e76c0b Mon Sep 17 00:00:00 2001
From: dadav <33197631+dadav@users.noreply.github.com>
Date: Wed, 15 Apr 2020 13:19:01 +0200
Subject: [PATCH 4/9] there is no logging to journald anymore
---
builder/pwnagotchi.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builder/pwnagotchi.yml b/builder/pwnagotchi.yml
index a0c08e7..a294153 100644
--- a/builder/pwnagotchi.yml
+++ b/builder/pwnagotchi.yml
@@ -376,7 +376,7 @@
I'm managed by systemd. Here are some basic commands.
If you want to know what I'm doing, you can check my logs with the command
- journalctl -fu pwnagotchi
+ tail -f /var/log/pwnagotchi.log
If you want to know if I'm running, you can use
systemctl status pwnagotchi
From 585b208e9ef691857e8703800cc3d2b5ed22164a Mon Sep 17 00:00:00 2001
From: dadav <33197631+dadav@users.noreply.github.com>
Date: Wed, 15 Apr 2020 16:05:56 +0200
Subject: [PATCH 5/9] support multiple passwords
---
builder/data/usr/bin/decryption-webserver | 90 ++++++++++++++++++-----
builder/data/usr/bin/pwnlib | 11 +--
2 files changed, 79 insertions(+), 22 deletions(-)
diff --git a/builder/data/usr/bin/decryption-webserver b/builder/data/usr/bin/decryption-webserver
index 72e4016..96e7ba6 100755
--- a/builder/data/usr/bin/decryption-webserver
+++ b/builder/data/usr/bin/decryption-webserver
@@ -1,35 +1,36 @@
#!/usr/bin/env python3
from http.server import HTTPServer, BaseHTTPRequestHandler
+from urllib.parse import parse_qsl
-HTML_FORM = """
+_HTML_FORM_TEMPLATE = """
Decryption
@@ -39,7 +40,7 @@ HTML_FORM = """
Please provide the decryption password.
@@ -48,6 +49,55 @@ HTML_FORM = """
"""
+POST_RESPONSE = """
+
+
+
+
+
+
+
+
+
+
+
+
+"""
+
+HTML_FORM = None
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
@@ -59,13 +109,19 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
content_length = int(self.headers['Content-Length'])
body = self.rfile.read(content_length)
+ for mapping, password in parse_qsl(body.decode('UTF-8')):
+ with open('/tmp/.pwnagotchi-secret-{}'.format(mapping), 'wt') as pwfile:
+ pwfile.write(password)
self.send_response(200)
self.end_headers()
- password = body.decode('UTF-8').split('=')[1]
+ self.wfile.write(POST_RESPONSE.encode())
- with open('/tmp/.pwnagotchi-secret', 'wt') as pwfile:
- pwfile.write(password)
+with open('/root/.pwnagotchi-crypted') as crypted_file:
+ mappings = [line.split()[0] for line in crypted_file.readlines()]
+ fields = ''.join(['\n '.format(m=m)
+ for m in mappings])
+ HTML_FORM = _HTML_FORM_TEMPLATE.format(password_fields=fields)
httpd = HTTPServer(('0.0.0.0', 80), SimpleHTTPRequestHandler)
httpd.serve_forever()
diff --git a/builder/data/usr/bin/pwnlib b/builder/data/usr/bin/pwnlib
index 2b7a820..cbf358c 100755
--- a/builder/data/usr/bin/pwnlib
+++ b/builder/data/usr/bin/pwnlib
@@ -103,12 +103,11 @@ is_decrypted() {
# fail if not mounted
if ! mountpoint -q "$mount" >/dev/null 2>&1; then
- if [ -f /tmp/.pwnagotchi-secret ]; then
- /dev/null 2>&1; then
echo "Container decrypted!"
-
fi
fi
@@ -151,8 +150,10 @@ EOF
fi
done /tmp/.pwnagotchi-secret python3 -c 'print("A"*4096)'
+ # overwrite passwords
+ python3 -c 'print("A"*4096)' | tee /tmp/.pwnagotchi-secret-* >/dev/null
+ # delete
+ rm /tmp/.pwnagotchi-secret-*
sync # flush
pkill wpa_supplicant
From 3965bdb55452f12e734a811594ff188af898f39c Mon Sep 17 00:00:00 2001
From: dadav <33197631+dadav@users.noreply.github.com>
Date: Wed, 15 Apr 2020 17:02:50 +0200
Subject: [PATCH 6/9] performs better without it
---
pwnagotchi/plugins/default/logtail.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/pwnagotchi/plugins/default/logtail.py b/pwnagotchi/plugins/default/logtail.py
index b19500e..c3c8fed 100644
--- a/pwnagotchi/plugins/default/logtail.py
+++ b/pwnagotchi/plugins/default/logtail.py
@@ -273,7 +273,6 @@ class Logtail(plugins.Plugin):
if path == 'stream':
def generate():
with open(self.config['main']['log']['path']) as f:
- yield f.read()
while True:
yield f.readline()
From 568c5b020dac804f10b8297cfdb07ca0d096913a Mon Sep 17 00:00:00 2001
From: dadav <33197631+dadav@users.noreply.github.com>
Date: Wed, 15 Apr 2020 17:19:41 +0200
Subject: [PATCH 7/9] aaaannnd even better
---
pwnagotchi/plugins/default/logtail.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/pwnagotchi/plugins/default/logtail.py b/pwnagotchi/plugins/default/logtail.py
index c3c8fed..086bf73 100644
--- a/pwnagotchi/plugins/default/logtail.py
+++ b/pwnagotchi/plugins/default/logtail.py
@@ -1,6 +1,7 @@
import os
import logging
import threading
+from itertools import islice
from time import sleep
from datetime import datetime,timedelta
from pwnagotchi import plugins
@@ -273,6 +274,10 @@ class Logtail(plugins.Plugin):
if path == 'stream':
def generate():
with open(self.config['main']['log']['path']) as f:
+ # https://stackoverflow.com/questions/39549426/read-multiple-lines-from-a-file-batch-by-batch/39549901#39549901
+ n = 1024
+ for n_lines in iter(lambda: ''.join(islice(f, n)), ''):
+ yield n_lines
while True:
yield f.readline()
From 7ec20caf23fb8159f271bb849cead8dda114cf84 Mon Sep 17 00:00:00 2001
From: dadav <33197631+dadav@users.noreply.github.com>
Date: Wed, 15 Apr 2020 17:49:57 +0200
Subject: [PATCH 8/9] fix filter bug
---
pwnagotchi/plugins/default/logtail.py | 32 +++++++++------------------
1 file changed, 11 insertions(+), 21 deletions(-)
diff --git a/pwnagotchi/plugins/default/logtail.py b/pwnagotchi/plugins/default/logtail.py
index 086bf73..3f633e1 100644
--- a/pwnagotchi/plugins/default/logtail.py
+++ b/pwnagotchi/plugins/default/logtail.py
@@ -91,7 +91,7 @@ TEMPLATE = """
{% endblock %}
{% block script %}
- var content = document.getElementById('content');
+ var table = document.getElementById('table');
var filter = document.getElementById('filter');
var filterVal = filter.value.toUpperCase();
@@ -155,10 +155,10 @@ TEMPLATE = """
tr.className = colorClass;
if (filterVal.length > 0 && value.toUpperCase().indexOf(filterVal) == -1) {
- tr.style.visibility = "collapse";
+ tr.style.display = "none";
}
- content.appendChild(tr);
+ table.appendChild(tr);
});
position = messages.length - 1;
}
@@ -194,25 +194,15 @@ TEMPLATE = """
function doneTyping() {
document.body.style.cursor = 'progress';
- var table, tr, tds, td, i, txtValue;
+ var tr, tds, td, i, txtValue;
filterVal = filter.value.toUpperCase();
- table = document.getElementById("content");
tr = table.getElementsByTagName("tr");
- for (i = 0; i < tr.length; i++) {
- tds = tr[i].getElementsByTagName("td");
- if (tds) {
- for (l = 0; l < tds.length; l++) {
- td = tds[l];
- if (td) {
- txtValue = td.textContent || td.innerText;
- if (txtValue.toUpperCase().indexOf(filterVal) > -1) {
- tr[i].style.visibility = "visible";
- break;
- } else {
- tr[i].style.visibility = "collapse";
- }
- }
- }
+ for (i = 1; i < tr.length; i++) {
+ txtValue = tr[i].textContent || tr[i].innerText;
+ if (txtValue.toUpperCase().indexOf(filterVal) > -1) {
+ tr[i].style.display = "table-row";
+ } else {
+ tr[i].style.display = "none";
}
}
document.body.style.cursor = 'default';
@@ -226,7 +216,7 @@ TEMPLATE = """
-