| skipped 551 lines |
552 | 552 | | self.logging.debug(ex) |
553 | 553 | | self.logging.debug(f"Export Done!") |
554 | 554 | | |
| 555 | + | def export_sam(self): |
| 556 | + | user_credz=self.get_credz(distinct_sam=True) |
| 557 | + | filename = os.path.join(self.options.output_directory, 'raw_sam') |
| 558 | + | self.logging.info(f"Exporting {len(user_credz)} NTLM credz to {self.options.output_directory}") |
| 559 | + | if os.path.exists(filename): |
| 560 | + | os.remove(filename) |
| 561 | + | for index, cred in enumerate(user_credz): |
| 562 | + | username, password = cred |
| 563 | + | try: |
| 564 | + | f=open(filename,'ab') |
| 565 | + | f.write(f"{username}:{password}\n".encode('utf-8')) |
| 566 | + | f.close() |
| 567 | + | except Exception as ex: |
| 568 | + | self.logging.error(f"Exception in export raw sam to {filename}") |
| 569 | + | self.logging.debug(ex) |
| 570 | + | self.logging.debug(f"Export Done!") |
| 571 | + | |
555 | 572 | | def export_cookies(self): |
556 | 573 | | user_credz=self.get_cookies() |
557 | 574 | | filename = os.path.join(self.options.output_directory, 'raw_cookies') |
| skipped 18 lines |
576 | 593 | | results = cur.fetchall() |
577 | 594 | | return results |
578 | 595 | | |
579 | | - | def get_credz(self, filterTerm=None, credz_type=None,distinct=False): |
| 596 | + | def get_credz(self, filterTerm=None, credz_type=None,distinct=False,distinct_sam=False): |
580 | 597 | | """ |
581 | 598 | | Return credentials from the database. |
582 | 599 | | """ |
| skipped 11 lines |
594 | 611 | | with self.conn: |
595 | 612 | | cur = self.conn.cursor() |
596 | 613 | | cur.execute("SELECT DISTINCT username,password FROM credz WHERE LOWER(type) NOT IN ('sam','lsa','dcc2') AND password NOT IN ('')") |
| 614 | + | elif distinct_sam : |
| 615 | + | with self.conn: |
| 616 | + | cur = self.conn.cursor() |
| 617 | + | cur.execute("SELECT DISTINCT username,password FROM credz WHERE LOWER(type) IN ('sam') AND password NOT IN ('')") |
597 | 618 | | # otherwise return all credentials |
598 | 619 | | else: |
599 | 620 | | with self.conn: |
| skipped 1109 lines |