exporting raw credz and cookies2

This commit is contained in:
Pierre-Alexandre Vandewoestyne 2022-01-30 16:59:14 +01:00
parent cbe5fe6317
commit 6fbcc9c60b
2 changed files with 23 additions and 1 deletions

View File

@ -186,6 +186,7 @@ def main():
my_report = reporting(sqlite3.connect(options.db_path), logging, options, targets) my_report = reporting(sqlite3.connect(options.db_path), logging, options, targets)
my_report.generate_report() my_report.generate_report()
my_report.export_credz() my_report.export_credz()
my_report.export_sam()
my_report.export_cookies() my_report.export_cookies()
if options.GetHashes: if options.GetHashes:
my_report.export_MKF_hashes() my_report.export_MKF_hashes()

View File

@ -552,6 +552,23 @@ class reporting:
self.logging.debug(ex) self.logging.debug(ex)
self.logging.debug(f"Export Done!") self.logging.debug(f"Export Done!")
def export_sam(self):
user_credz=self.get_credz(distinct_sam=True)
filename = os.path.join(self.options.output_directory, 'raw_sam')
self.logging.info(f"Exporting {len(user_credz)} NTLM credz to {self.options.output_directory}")
if os.path.exists(filename):
os.remove(filename)
for index, cred in enumerate(user_credz):
username, password = cred
try:
f=open(filename,'ab')
f.write(f"{username}:{password}\n".encode('utf-8'))
f.close()
except Exception as ex:
self.logging.error(f"Exception in export raw sam to {filename}")
self.logging.debug(ex)
self.logging.debug(f"Export Done!")
def export_cookies(self): def export_cookies(self):
user_credz=self.get_cookies() user_credz=self.get_cookies()
filename = os.path.join(self.options.output_directory, 'raw_cookies') filename = os.path.join(self.options.output_directory, 'raw_cookies')
@ -576,7 +593,7 @@ class reporting:
results = cur.fetchall() results = cur.fetchall()
return results return results
def get_credz(self, filterTerm=None, credz_type=None,distinct=False): def get_credz(self, filterTerm=None, credz_type=None,distinct=False,distinct_sam=False):
""" """
Return credentials from the database. Return credentials from the database.
""" """
@ -594,6 +611,10 @@ class reporting:
with self.conn: with self.conn:
cur = self.conn.cursor() cur = self.conn.cursor()
cur.execute("SELECT DISTINCT username,password FROM credz WHERE LOWER(type) NOT IN ('sam','lsa','dcc2') AND password NOT IN ('')") cur.execute("SELECT DISTINCT username,password FROM credz WHERE LOWER(type) NOT IN ('sam','lsa','dcc2') AND password NOT IN ('')")
elif distinct_sam :
with self.conn:
cur = self.conn.cursor()
cur.execute("SELECT DISTINCT username,password FROM credz WHERE LOWER(type) IN ('sam') AND password NOT IN ('')")
# otherwise return all credentials # otherwise return all credentials
else: else:
with self.conn: with self.conn: