new: new text while generating keys ...
This commit is contained in:
parent
a9123922c0
commit
0f8f77c2be
@ -33,8 +33,8 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
plugins.load(config)
|
plugins.load(config)
|
||||||
|
|
||||||
keypair = KeyPair()
|
|
||||||
display = Display(config=config, state={'name': '%s>' % pwnagotchi.name()})
|
display = Display(config=config, state={'name': '%s>' % pwnagotchi.name()})
|
||||||
|
keypair = KeyPair(view=display)
|
||||||
agent = Agent(view=display, config=config, keypair=keypair)
|
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._keypair.fingerprint, pwnagotchi.version))
|
||||||
|
@ -10,12 +10,13 @@ DefaultPath = "/etc/pwnagotchi/"
|
|||||||
|
|
||||||
|
|
||||||
class KeyPair(object):
|
class KeyPair(object):
|
||||||
def __init__(self, path=DefaultPath):
|
def __init__(self, path=DefaultPath, view=None):
|
||||||
self.path = path
|
self.path = path
|
||||||
self.priv_path = os.path.join(path, "id_rsa")
|
self.priv_path = os.path.join(path, "id_rsa")
|
||||||
self.priv_key = None
|
self.priv_key = None
|
||||||
self.pub_path = "%s.pub" % self.priv_path
|
self.pub_path = "%s.pub" % self.priv_path
|
||||||
self.pub_key = None
|
self.pub_key = None
|
||||||
|
self._view = view
|
||||||
|
|
||||||
if not os.path.exists(self.path):
|
if not os.path.exists(self.path):
|
||||||
os.makedirs(self.path)
|
os.makedirs(self.path)
|
||||||
@ -23,6 +24,7 @@ class KeyPair(object):
|
|||||||
while True:
|
while True:
|
||||||
# first time, generate new keys
|
# first time, generate new keys
|
||||||
if not os.path.exists(self.priv_path) or not os.path.exists(self.pub_path):
|
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)
|
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)
|
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()
|
self.fingerprint = hashlib.sha256(pem_ascii).hexdigest()
|
||||||
|
|
||||||
# no exception, keys loaded correctly.
|
# no exception, keys loaded correctly.
|
||||||
|
self._view.on_normal()
|
||||||
return
|
return
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -213,6 +213,11 @@ class View(object):
|
|||||||
faces.SAD,
|
faces.SAD,
|
||||||
faces.LONELY)
|
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):
|
def on_normal(self):
|
||||||
self.set('face', faces.AWAKE)
|
self.set('face', faces.AWAKE)
|
||||||
self.set('status', self._voice.on_normal())
|
self.set('status', self._voice.on_normal())
|
||||||
|
@ -28,6 +28,10 @@ class Voice:
|
|||||||
self._('AI ready.'),
|
self._('AI ready.'),
|
||||||
self._('The neural network is 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):
|
def on_normal(self):
|
||||||
return random.choice([
|
return random.choice([
|
||||||
'',
|
'',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user