Coverage for /root/GitHubProjects/impacket/impacket/examples/ntlmrelayx/servers/socksplugins/__init__.py: 89%

# Coverage for /root/GitHubProjects/impacket/impacket/examples/ntlmrelayx/servers/socksplugins/__init__.py : 89%

## 15 statements

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1# Impacket - Collection of Python classes for working with network protocols.

2#

3# SECUREAUTH LABS. Copyright (C) 2018 SecureAuth Corporation. All rights reserved.

4#

5# This software is provided under a slightly modified version

6# of the Apache Software License. See the accompanying LICENSE file

7# for more information.

8#

9 import os

10 import sys

11 import pkg_resources

12

13 SOCKS_RELAYS = set()

14

15 for file in pkg_resources.resource_listdir('impacket.examples.ntlmrelayx.servers', 'socksplugins'):

16 if file.find('__') >= 0 or file.endswith('.py') is False:

17 continue

18 # This seems to be None in some case (py3 only)

19 # __spec__ is py3 only though, but I haven't seen this being None on py2

20 # so it should cover all cases.

21 try:

22 package = __spec__.name # Python 3

23 except NameError:

24 package = __package__ # Python 2

25 __import__(package + '.' + os.path.splitext(file)[0])

26 module = sys.modules[package + '.' + os.path.splitext(file)[0]]

27 pluginClass = getattr(module, getattr(module, 'PLUGIN_CLASS'))

28 SOCKS_RELAYS.add(pluginClass)