xm解析器错误python

时间:2017-06-23 09:53:44

标签: python xml parsing

import sys
import os
import subprocess
from xml.dom import minidom

user_input = raw_input("Enter the path of your file: ")
#f = open(user_input,'r+')
#str(f)
apktool = "/usr/share/apktool/apktool.jar"
os.system(apktool + " d " +  user_input)
base = os.path.basename(user_input)
a = os.path.splitext(base)[0]
#b = os.path.dirname(user_input)
d = os.path.abspath(os.path.splitext(base)[0])
#print d
#print a
for root,dirs,files in os.walk(os.path.abspath(os.path.splitext(base)[0])):
    for filename in files:
        if filename.startswith('AndroidManifest'):
            pth = os.path.realpath(os.path.join(root,filename))
            #print pth
dom1 = minidom.parse(pth)
activity = dom1.getElementsByTagName("intent-filter")
for b in activity:
    activity= b.parentNode.getAttribute("android:name")
    export= b.parentNode.getAttribute("android:exported")
    if (export=='false'):
        print activity , "Exported but not exploitable"
    else:
        print activity , "Not Protected"

这会出现以下错误:

Traceback (most recent call last):
  File "C:\archie\Androidtestsuite\apktool\decompile.py", line 22, in <module>
    dom1 = minidom.parse(pth)
NameError: name 'pth' is not defined

使用python 2.7。这段代码在Ubuntu中运行正常,但它在windows中出错。是xml解析器问题还是我遗漏了什么。

0 个答案:

没有答案