From 0f8f77c2be707c9c91a7cf25aa248a4b9fe867e1 Mon Sep 17 00:00:00 2001 From: Simone Margaritelli Date: Sat, 12 Oct 2019 20:00:50 +0200 Subject: [PATCH] new: new text while generating keys ... --- bin/pwnagotchi | 2 +- pwnagotchi/identity.py | 5 ++++- pwnagotchi/ui/view.py | 5 +++++ pwnagotchi/voice.py | 4 ++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bin/pwnagotchi b/bin/pwnagotchi index 855e714..297bce6 100755 --- a/bin/pwnagotchi +++ b/bin/pwnagotchi @@ -33,8 +33,8 @@ if __name__ == '__main__': plugins.load(config) - keypair = KeyPair() display = Display(config=config, state={'name': '%s>' % pwnagotchi.name()}) + 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)) diff --git a/pwnagotchi/identity.py b/pwnagotchi/identity.py index 97a0630..7ea7652 100644 --- a/pwnagotchi/identity.py +++ b/pwnagotchi/identity.py @@ -10,12 +10,13 @@ DefaultPath = "/etc/pwnagotchi/" class KeyPair(object): - def __init__(self, path=DefaultPath): + def __init__(self, path=DefaultPath, view=None): self.path = path self.priv_path = os.path.join(path, "id_rsa") self.priv_key = None self.pub_path = "%s.pub" % self.priv_path self.pub_key = None + self._view = view if not os.path.exists(self.path): os.makedirs(self.path) @@ -23,6 +24,7 @@ class KeyPair(object): while True: # first time, generate new keys if not os.path.exists(self.priv_path) or not os.path.exists(self.pub_path): + self._view.on_keys_generation() logging.info("generating %s ..." % self.priv_path) os.system("/usr/bin/ssh-keygen -t rsa -m PEM -b 4096 -N '' -f '%s'" % self.priv_path) @@ -45,6 +47,7 @@ class KeyPair(object): self.fingerprint = hashlib.sha256(pem_ascii).hexdigest() # no exception, keys loaded correctly. + self._view.on_normal() return except Exception as e: diff --git a/pwnagotchi/ui/view.py b/pwnagotchi/ui/view.py index 92dc0ab..03ea0f3 100644 --- a/pwnagotchi/ui/view.py +++ b/pwnagotchi/ui/view.py @@ -213,6 +213,11 @@ class View(object): faces.SAD, faces.LONELY) + def on_keys_generation(self): + self.set('face', faces.AWAKE) + self.set('status', self._voice.on_keys_generation()) + self.update() + def on_normal(self): self.set('face', faces.AWAKE) self.set('status', self._voice.on_normal()) diff --git a/pwnagotchi/voice.py b/pwnagotchi/voice.py index a5305f6..22281cc 100644 --- a/pwnagotchi/voice.py +++ b/pwnagotchi/voice.py @@ -28,6 +28,10 @@ class Voice: self._('AI ready.'), self._('The neural network is ready.')]) + def on_keys_generation(self): + return random.choice([ + self._('Generating keys, do not turn off ...')]) + def on_normal(self): return random.choice([ '',