misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
Simone Margaritelli 2019-10-20 20:57:15 +02:00
parent 399e78e675
commit 74a75f03b8
No known key found for this signature in database
GPG Key ID: 82E42E7F3B34C97E

View File

@ -79,7 +79,6 @@ def install(display, update):
os.system('wget -q "%s" -O "%s"' % (update['url'], target_path)) os.system('wget -q "%s" -O "%s"' % (update['url'], target_path))
logging.info("[update] extracting %s to %s ..." % (target_path, path)) logging.info("[update] extracting %s to %s ..." % (target_path, path))
display.update(force=True, new_data={'status': 'Extracting %s ...' % name}) display.update(force=True, new_data={'status': 'Extracting %s ...' % name})
os.system('unzip "%s" -d "%s"' % (target_path, path)) os.system('unzip "%s" -d "%s"' % (target_path, path))
@ -92,11 +91,10 @@ def install(display, update):
return False return False
else: else:
display.update(force=True, new_data={'status': 'Verifying %s ...' % name})
checksum = checksums[0] checksum = checksums[0]
logging.info("[update] verifying %s for %s ..." % (checksum, source_path)) logging.info("[update] verifying %s for %s ..." % (checksum, source_path))
display.update(force=True, new_data={'status': 'Verifying %s ...' % name})
with open(checksum, 'rt') as fp: with open(checksum, 'rt') as fp:
expected = fp.read().split('=')[1].strip().lower() expected = fp.read().split('=')[1].strip().lower()
@ -107,6 +105,7 @@ def install(display, update):
logging.warning("[update] checksum mismatch for %s: expected=%s got=%s" % (source_path, expected, real)) logging.warning("[update] checksum mismatch for %s: expected=%s got=%s" % (source_path, expected, real))
return False return False
logging.info("[update] installing %s ..." % name)
display.update(force=True, new_data={'status': 'Installing %s ...' % name}) display.update(force=True, new_data={'status': 'Installing %s ...' % name})
if update['native']: if update['native']:
@ -125,6 +124,7 @@ def install(display, update):
os.system("service %s stop" % update['service']) os.system("service %s stop" % update['service'])
os.system("cd %s && pip3 install ." % source_path) os.system("cd %s && pip3 install ." % source_path)
logging.info("[update] restarting %s ..." % update['service'])
os.system("service %s start" % update['service']) os.system("service %s start" % update['service'])
return True return True
@ -153,7 +153,7 @@ def on_internet_available(agent):
( (
'bettercap/bettercap', subprocess.getoutput('bettercap -version').split(' ')[1].replace('v', ''), 'bettercap/bettercap', subprocess.getoutput('bettercap -version').split(' ')[1].replace('v', ''),
True, 'bettercap'), True, 'bettercap'),
('evilsocket/pwngrid', subprocess.getoutput('pwngrid -version').replace('v', ''), True, 'pwndrid-peer'), ('evilsocket/pwngrid', subprocess.getoutput('pwngrid -version').replace('v', ''), True, 'pwngrid-peer'),
('evilsocket/pwnagotchi', pwnagotchi.version, False, 'pwnagotchi') ('evilsocket/pwnagotchi', pwnagotchi.version, False, 'pwnagotchi')
] ]