| 6 | MODULES_DIR = bashfuscator_modules.__path__[0] |
| 7 | |
| 8 | def import_mutators(): |
| 9 | modules = [] |
| 10 | for root, dirs, files in os.walk(MODULES_DIR): |
| 11 | _, package, root = root.rpartition("bashfuscator/modules/".replace("/", os.sep)) |
| 12 | root = root.replace(os.sep, ".") |
| 13 | files = filter(lambda x: not x.startswith("_") and x.endswith(".py"), files) |
| 14 | modules.extend(map(lambda x: ".".join((root, os.path.splitext(x)[0])), files)) |
| 15 | |
| 16 | commandObfuscators = [] |
| 17 | stringObfuscators = [] |
| 18 | tokenObfuscators = [] |
| 19 | encoders = [] |
| 20 | compressors = [] |
| 21 | |
| 22 | |
| 23 | for moduleName in modules: |
| 24 | module = importlib.import_module("bashfuscator.modules." + moduleName) |
| 25 | className = moduleName.split(".")[-1] |
| 26 | className = "".join(s.title() for s in className.split("_")) |
| 27 | currModule = getattr(module, className)() |
| 28 | |
| 29 | if currModule.mutatorType == "command": |
| 30 | commandObfuscators.append(currModule) |
| 31 | elif currModule.mutatorType == "string": |
| 32 | stringObfuscators.append(currModule) |
| 33 | elif currModule.mutatorType == "token": |
| 34 | tokenObfuscators.append(currModule) |
| 35 | elif currModule.mutatorType == "encode": |
| 36 | encoders.append(currModule) |
| 37 | elif currModule.mutatorType == "compress": |
| 38 | compressors.append(currModule) |
| 39 | |
| 40 | return commandObfuscators, stringObfuscators, tokenObfuscators, encoders, compressors |