Skip to content

Commit

Permalink
Merge pull request #81 from Hackndo/3.1.8
Browse files Browse the repository at this point in the history
3.1.8
  • Loading branch information
Hackndo authored Apr 8, 2023
2 parents 4e4b4e5 + abe9211 commit 14d8f8a
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# lsassy
[![PyPI version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=py&type=6&v=v3.1.7&x2=0)](https://pypi.org/project/lsassy)
[![PyPI version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=py&type=6&v=v3.1.8&x2=0)](https://pypi.org/project/lsassy)
[![PyPI Statistics](https://img.shields.io/pypi/dm/lsassy.svg)](https://pypistats.org/packages/lsassy)
[![Tests](https://github.com/hackndo/lsassy/workflows/Tests/badge.svg)](https://github.com/hackndo/lsassy/actions?workflow=Tests)
[![Twitter](https://img.shields.io/twitter/follow/hackanddo?label=HackAndDo&style=social)](https://twitter.com/intent/follow?screen_name=hackanddo)
Expand Down
2 changes: 1 addition & 1 deletion lsassy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.1.7'
__version__ = '3.1.8'
5 changes: 4 additions & 1 deletion lsassy/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from lsassy import __version__
from lsassy.core import ThreadPool
from lsassy.dumper import Dumper
from lsassy.logger import lsassy_logger
from lsassy.logger import lsassy_logger, LsassyLogger
import logging


Expand Down Expand Up @@ -84,6 +84,9 @@ def main():

args = parser.parse_args()

# Handle no_color parameter with logger
lsassy_logger.set_no_color(no_color=args.no_color)

if args.v == 1:
lsassy_logger.setLevel(logging.INFO)
elif args.v >= 2:
Expand Down
38 changes: 16 additions & 22 deletions lsassy/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@


class LsassyLogger(logging.LoggerAdapter):
def __init__(self):
super().__init__(self)
def __init__(self, no_color=False):
super().__init__(self, extra=None)
self.logger = logging.getLogger("lsassy")
self.logger.propagate = False
self.no_color = None
self.no_color = no_color

formatter = LsassyFormatter()
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(formatter)
self.logger.addHandler(handler)
formatter = LsassyFormatter(no_color=no_color)
self.handler = logging.StreamHandler(sys.stdout)
self.handler.setFormatter(formatter)
self.logger.addHandler(self.handler)

def lsassy_highlight(self, msg):
"""
Expand All @@ -24,35 +24,29 @@ def lsassy_highlight(self, msg):
return msg
return "\033[1;33m{}\033[0m".format(msg)

def set_no_color(self, no_color=False):
self.logger.removeHandler(self.handler)
self.handler = logging.StreamHandler(sys.stdout)
self.handler.setFormatter(LsassyFormatter(no_color=no_color))
self.logger.addHandler(self.handler)


class LsassyFormatter(logging.Formatter):
"""
Custom formatting. Inspired by impacket "Logger" class
"""
def __init__(self, no_color=False):
self.formatter = logging.Formatter.__init__(self, '%(bullet)s %(threadName)s %(message)s', None)
self._no_color = no_color
if not self._no_color:
self.no_color = no_color
self.BLUE, self.WHITE, self.YELLOW, self.RED, self.GREEN, self.NC = '', '', '', '', '', ''
if not self.no_color:
self.BLUE = '\033[1;34m'
self.WHITE = '\033[1;37m'
self.YELLOW = '\033[1;33m'
self.RED = '\033[1;31m'
self.GREEN = '\033[1;32m'
self.NC = '\033[0m'

@property
def no_color(self):
try:
return self._no_color
except AttributeError:
return False

@no_color.setter
def no_color(self, no_color):
if no_color:
self.BLUE, self.WHITE, self.YELLOW, self.RED, self.GREEN, self.NC = '', '', '', '', '', ''
self._no_color = no_color

def format(self, record):
"""
Custom bullet formatting with colors
Expand Down
5 changes: 4 additions & 1 deletion lsassy/output/table_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@ def get_output(self):
cred["sha1"] if cred["sha1"] is not None else "",
"{} - {}".format(cred["ticket"]["domain"], cred["ticket"]["endtime"].strftime("%Y-%m-%d %H:%M")) if cred["ticket"] is not None else "",
"{}".format(cred["masterkey"]) if cred["masterkey"] is not None else "")
return table
console = Console()
with console.capture() as capture:
console.print(table)
return capture.get()

2 changes: 0 additions & 2 deletions lsassy/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def write(self, file_format, out_format="pretty", output_file=None, quiet=False,
output = self.get_output(out_format, users_only, tickets, masterkeys)

if file_format is None:
file_format = out_format
file_content = output

else:
file_content = self.get_output(file_format, users_only, tickets, masterkeys)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "lsassy"
version = "3.1.7"
version = "3.1.8"
description = "Tool to remotely extract credentials"
readme = "README.md"
homepage = "https://github.com/hackndo/lsassy"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setup(
name="lsassy",
version="3.1.7",
version="3.1.8",
author="Pixis",
author_email="[email protected]",
description="Python library to extract credentials from lsass remotely",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lsassy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


def test_version():
assert __version__ == '3.1.7'
assert __version__ == '3.1.8'

0 comments on commit 14d8f8a

Please sign in to comment.