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 import os

2 import sys

3 import pkg_resources

4

5 SOCKS_RELAYS = set()

6

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

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

9 continue

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

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

12 # so it should cover all cases.

13 try:

14 package = __spec__.name # Python 3

15 except NameError:

16 package = __package__ # Python 2

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

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

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

20 SOCKS_RELAYS.add(pluginClass)