def NameToNumForOneFile(path): if Smali.isSmali(path): path = Smali.getDataFilePath( path) #change smali path to data file path if DataFile.isDataFile(path) and os.path.exists(path): fDir = os.path.dirname(path) if cmp(fDir, "") == 0: fDir = "." name = DataFile.getDataFileName(path) else: return java = Java(fDir, name) #java.printJava() if java.getListLen() == 0: print "Can not find data file: " + os.path.join(java.path, java.name) + ".data" return if False: print "NameToNum: " + os.path.join(java.path, java.name) + ".data" toNum = NameToNum(java.name, java.path, java.smaliList) #toNum.printAccessSmaliSet() toNum.doNameToNum() os.remove(path)
def NameToNumForOneFile(path): if Smali.isSmali(path): path = Smali.getDataFilePath(path) #change smali path to data file path if DataFile.isDataFile(path) and os.path.exists(path): fDir = os.path.dirname(path) if cmp(fDir, "") == 0: fDir = "." name = DataFile.getDataFileName(path) else: return java = Java(fDir, name) #java.printJava() if java.getListLen() == 0: print "Can not find data file: "+os.path.join(java.path, java.name)+".data" return if False: print "NameToNum: "+os.path.join(java.path, java.name)+".data" toNum = NameToNum(java.name, java.path, java.smaliList) #toNum.printAccessSmaliSet() toNum.doNameToNum() os.remove(path)
toNum.doNameToNum() os.remove(path) def Usage(): print "Usage: name2num.py aa/bb/A.data" print " name2num.py aa/bb/A.smali" print " name2num.py aa/bb" if __name__ == '__main__': argLen = len(sys.argv) if argLen == 2: path = sys.argv[1] if os.path.isfile(path) and (DataFile.isDataFile(path) or Smali.isSmali(path)): NameToNumForOneFile(path) elif os.path.isdir(path): for root, dirs, files in os.walk(path): for sfile in files: fPath = os.path.join(root, sfile) if DataFile.isDataFile(fPath): NameToNumForOneFile(fPath) else: Usage() else: Usage()
toNum = NameToNum(java.name, java.path, java.smaliList) #toNum.printAccessSmaliSet() toNum.doNameToNum() os.remove(path) def Usage(): print "Usage: name2num.py aa/bb/A.data" print " name2num.py aa/bb/A.smali" print " name2num.py aa/bb" if __name__ == '__main__': argLen = len(sys.argv) if argLen == 2: path = sys.argv[1] if os.path.isfile(path) and (DataFile.isDataFile(path) or Smali.isSmali(path)): NameToNumForOneFile(path) elif os.path.isdir(path): for root, dirs, files in os.walk(path): for sfile in files: fPath = os.path.join(root, sfile) if DataFile.isDataFile(fPath): NameToNumForOneFile(fPath) else: Usage() else: Usage()