Files
Martin Gallo cd4fe47cfc Arrange tagline, copyright and license notes across all source files
This was a pending change to:
- Use the same tagline, copyright and license notice across files.
- Remove authors' contacts that are no longer valid (due to affiliation changes).
- Update repository location.
- Update license file with missing licenses (althought those were already in source files).

This doesn't include any change on the source code, nor any change on current copyright or licenses. Just formatting and phrasing to make our and distro's maintainers life easier.
2021-07-20 10:04:27 -03:00

57 lines
2.5 KiB
Python

#!/usr/bin/env python
# Impacket - Collection of Python classes for working with network protocols.
#
# SECUREAUTH LABS. Copyright (C) 2021 SecureAuth Corporation. All rights reserved.
#
# This software is provided under a slightly modified version
# of the Apache Software License. See the accompanying LICENSE file
# for more information.
#
# Description:
# Utility and helper functions for the example scripts
#
import unittest
from impacket.examples.utils import parse_target, parse_credentials
class UtilsTests(unittest.TestCase):
def test_parse_target(self):
# Parse target returns a tuple with: domain, username, password, remote_name/address
targets = {
"": ("", "", "", ""),
"HostName": ("", "", "", "HostName"),
"UserName@HostName": ("", "UserName", "", "HostName"),
"UserName:Password@HostName": ("", "UserName", "Password", "HostName"),
"UserName:Pa$$word1234@HostName": ("", "UserName", "Pa$$word1234", "HostName"),
"UserName:Password!#$@HostName": ("", "UserName", "Password!#$", "HostName"),
"UserName:Passw@rd!#$@HostName": ("", "UserName", "Passw@rd!#$", "HostName"),
"UserName:P@ssw@rd@!#$@HostName": ("", "UserName", "P@ssw@rd@!#$", "HostName"),
"DOMAIN/UserName@HostName": ("DOMAIN", "UserName", "", "HostName"),
"DOMAIN/:Password@HostName": ("DOMAIN", "", "Password", "HostName"),
"DOMAIN/UserName:Password@HostName": ("DOMAIN", "UserName", "Password", "HostName"),
"DOMAIN/UserName:Password/123@HostName": ("DOMAIN", "UserName", "Password/123", "HostName"),
}
for target, result in targets.items():
self.assertTupleEqual(parse_target(target), result)
def test_parse_credentials(self):
# Parse credentials returns a tuple with: domain, username, password
creds = {
"": ("", "", ""),
"UserName": ("", "UserName", ""),
"UserName:Password": ("", "UserName", "Password"),
"UserName:Password:123": ("", "UserName", "Password:123"),
"DOMAIN/UserName": ("DOMAIN", "UserName", ""),
"DOMAIN/UserName:Password": ("DOMAIN", "UserName", "Password"),
"DOMAIN/UserName:Password/123": ("DOMAIN", "UserName", "Password/123"),
}
for cred, result in creds.items():
self.assertTupleEqual(parse_credentials(cred), result)
if __name__ == "__main__":
unittest.main(verbosity=1)