forked from Th4nat0s/Chall_Tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
machouillemacro.py
executable file
·49 lines (42 loc) · 1.16 KB
/
machouillemacro.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
# coding=utf-8
import re, sys, random, string
#Dim vaLFVutQ As Integer^M
#vaLFVutQ = 3^M
#Do While vaLFVutQ < 32^M
#DoEvents: vaLFVutQ = vaLFVutQ + 1^M
#Loop^M
# Functions
def getparam(count):
if len(sys.argv) != count+1:
print 'Machouille Macro'
print 'Obfuscate VBA macro .. To Use: '+ sys.argv[0]+ ' filename'
sys.exit(1)
else:
return sys.argv[1]
# Main Code #####
def decoy():
N = random.randrange(16)
param = getparam(1)
NAME = random.choice(string.letters) + ''.join(random.choice(string.letters + string.digits) for _ in range(N))
NUM = random.randrange(16)
body = ("\nDim %s As Integer\n" % NAME)
body += ("%s = %d\n" % (NAME, NUM))
body += ("Do While %s < %d\n" % (NAME, NUM + 1 + random.randrange(15)))
body += ("DoEvents: %s = %s + 1\n" % (NAME,NAME))
body += ("Loop\n\n")
return body
def main():
PENDOWN = False
mfile = getparam(1)
f = open(mfile, 'rb')
for line in f.readlines():
print line
if line.upper().startswith("SUB"):
PENDOWN = True
if line.upper().startswith("END SUB"):
PENDOWN = False
if PENDOWN:
print decoy()
if __name__ == '__main__':
main()