-
Notifications
You must be signed in to change notification settings - Fork 95
/
batch_antidebug.py
64 lines (52 loc) · 1.42 KB
/
batch_antidebug.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/python
import os
import sys
import time
import hashlib
from pyew_core import CPyew
def printData(pyew, path, msg):
buf = pyew.getBuffer()
print "File :", path
print "MD5 :", hashlib.md5(buf).hexdigest()
print "SHA1 :", hashlib.sha1(buf).hexdigest()
print "SHA256:", hashlib.sha256(buf).hexdigest()
print "Found :", msg
def checkAntidebug(path):
t = time.time()
pyew = CPyew(batch=True)
pyew.codeanalysis = True
try:
pyew.loadFile(path)
except KeyboardInterrupt:
print "Abort"
sys.exit(0)
except:
print "ERROR loading file %s" % path
return
if pyew.format not in ["PE", "ELF"]:
return
if len(pyew.antidebug) > 0:
print
printData(pyew, path, pyew.antidebug)
print "Time to analyze %f" % (time.time() - t)
print
def doChecks(path):
checkAntidebug(path)
def main(path):
buf = ""
for root, dirs, files in os.walk(path):
for x in files:
filepath = os.path.join(root, x)
sys.stdout.write("\b"*len(buf) + " "*len(buf) + "\b"*len(buf))
buf = "Analyzing file %s ..." % filepath
sys.stdout.write(buf)
sys.stdout.flush()
doChecks(filepath)
print
def usage():
print "Usage:", sys.argv[0], "<path>"
if __name__ == "__main__":
if len(sys.argv) == 1:
usage()
else:
main(sys.argv[1])