Skip to content

Commit 14d8f8a

Browse files
authored
Merge pull request #81 from Hackndo/3.1.8
3.1.8
2 parents 4e4b4e5 + abe9211 commit 14d8f8a

File tree

9 files changed

+29
-31
lines changed

9 files changed

+29
-31
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# lsassy
2-
[![PyPI version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=py&type=6&v=v3.1.7&x2=0)](https://pypi.org/project/lsassy)
2+
[![PyPI version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=py&type=6&v=v3.1.8&x2=0)](https://pypi.org/project/lsassy)
33
[![PyPI Statistics](https://img.shields.io/pypi/dm/lsassy.svg)](https://pypistats.org/packages/lsassy)
44
[![Tests](https://github.com/hackndo/lsassy/workflows/Tests/badge.svg)](https://github.com/hackndo/lsassy/actions?workflow=Tests)
55
[![Twitter](https://img.shields.io/twitter/follow/hackanddo?label=HackAndDo&style=social)](https://twitter.com/intent/follow?screen_name=hackanddo)

lsassy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '3.1.7'
1+
__version__ = '3.1.8'

lsassy/console.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from lsassy import __version__
55
from lsassy.core import ThreadPool
66
from lsassy.dumper import Dumper
7-
from lsassy.logger import lsassy_logger
7+
from lsassy.logger import lsassy_logger, LsassyLogger
88
import logging
99

1010

@@ -84,6 +84,9 @@ def main():
8484

8585
args = parser.parse_args()
8686

87+
# Handle no_color parameter with logger
88+
lsassy_logger.set_no_color(no_color=args.no_color)
89+
8790
if args.v == 1:
8891
lsassy_logger.setLevel(logging.INFO)
8992
elif args.v >= 2:

lsassy/logger.py

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33

44

55
class LsassyLogger(logging.LoggerAdapter):
6-
def __init__(self):
7-
super().__init__(self)
6+
def __init__(self, no_color=False):
7+
super().__init__(self, extra=None)
88
self.logger = logging.getLogger("lsassy")
99
self.logger.propagate = False
10-
self.no_color = None
10+
self.no_color = no_color
1111

12-
formatter = LsassyFormatter()
13-
handler = logging.StreamHandler(sys.stdout)
14-
handler.setFormatter(formatter)
15-
self.logger.addHandler(handler)
12+
formatter = LsassyFormatter(no_color=no_color)
13+
self.handler = logging.StreamHandler(sys.stdout)
14+
self.handler.setFormatter(formatter)
15+
self.logger.addHandler(self.handler)
1616

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

27+
def set_no_color(self, no_color=False):
28+
self.logger.removeHandler(self.handler)
29+
self.handler = logging.StreamHandler(sys.stdout)
30+
self.handler.setFormatter(LsassyFormatter(no_color=no_color))
31+
self.logger.addHandler(self.handler)
32+
2733

2834
class LsassyFormatter(logging.Formatter):
2935
"""
3036
Custom formatting. Inspired by impacket "Logger" class
3137
"""
3238
def __init__(self, no_color=False):
3339
self.formatter = logging.Formatter.__init__(self, '%(bullet)s %(threadName)s %(message)s', None)
34-
self._no_color = no_color
35-
if not self._no_color:
40+
self.no_color = no_color
41+
self.BLUE, self.WHITE, self.YELLOW, self.RED, self.GREEN, self.NC = '', '', '', '', '', ''
42+
if not self.no_color:
3643
self.BLUE = '\033[1;34m'
3744
self.WHITE = '\033[1;37m'
3845
self.YELLOW = '\033[1;33m'
3946
self.RED = '\033[1;31m'
4047
self.GREEN = '\033[1;32m'
4148
self.NC = '\033[0m'
4249

43-
@property
44-
def no_color(self):
45-
try:
46-
return self._no_color
47-
except AttributeError:
48-
return False
49-
50-
@no_color.setter
51-
def no_color(self, no_color):
52-
if no_color:
53-
self.BLUE, self.WHITE, self.YELLOW, self.RED, self.GREEN, self.NC = '', '', '', '', '', ''
54-
self._no_color = no_color
55-
5650
def format(self, record):
5751
"""
5852
Custom bullet formatting with colors

lsassy/output/table_output.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,8 @@ def get_output(self):
4040
cred["sha1"] if cred["sha1"] is not None else "",
4141
"{} - {}".format(cred["ticket"]["domain"], cred["ticket"]["endtime"].strftime("%Y-%m-%d %H:%M")) if cred["ticket"] is not None else "",
4242
"{}".format(cred["masterkey"]) if cred["masterkey"] is not None else "")
43-
return table
43+
console = Console()
44+
with console.capture() as capture:
45+
console.print(table)
46+
return capture.get()
4447

lsassy/writer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ def write(self, file_format, out_format="pretty", output_file=None, quiet=False,
4545
output = self.get_output(out_format, users_only, tickets, masterkeys)
4646

4747
if file_format is None:
48-
file_format = out_format
4948
file_content = output
50-
5149
else:
5250
file_content = self.get_output(file_format, users_only, tickets, masterkeys)
5351

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "lsassy"
3-
version = "3.1.7"
3+
version = "3.1.8"
44
description = "Tool to remotely extract credentials"
55
readme = "README.md"
66
homepage = "https://github.com/hackndo/lsassy"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
setup(
1515
name="lsassy",
16-
version="3.1.7",
16+
version="3.1.8",
1717
author="Pixis",
1818
author_email="hackndo@gmail.com",
1919
description="Python library to extract credentials from lsass remotely",

tests/test_lsassy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33

44
def test_version():
5-
assert __version__ == '3.1.7'
5+
assert __version__ == '3.1.8'

0 commit comments

Comments
 (0)