-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathutils.py
43 lines (37 loc) · 1.07 KB
/
utils.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
# coding:utf-8
# author: WenR0
import os
import re
import subprocess
def load_php_opcode(phpfilename):
"""
获取php opcode 信息
:param phpfilename:
:return:
"""
try:
output = subprocess.check_output(['php.exe', '-dvld.active=1', '-dvld.execute=0', phpfilename], stderr=subprocess.STDOUT)
tokens = re.findall(r'\s(\b[A-Z_]+\b)\s', output)
t = " ".join(tokens)
return t
except:
return " "
def recursion_load_php_file_opcode(dir):
"""
递归获取 php opcde
:param dir: 目录文件
:return:
"""
files_list = []
for root, dirs, files in os.walk(dir):
for filename in files:
if filename.endswith('.php'):
try:
full_path = os.path.join(root, filename)
file_content = load_php_opcode(full_path)
print "[Gen success] {}".format(full_path)
print '--' * 20
files_list.append(file_content)
except:
continue
return files_list