def cycTraPropertyListMap(file_dir, propertyPrefix): fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if tmp_path.endswith('.h'): if not igFil.isIgnoreFiles(tmp_path): pass if '+' not in tmp_path: if 'AppDelegate.' not in tmp_path: getPropertyNameAtHFile(tmp_path, propertyPrefix) conLog.info('[ReadProH OK] ' + tmp_path) if tmp_path.endswith('.swift'): if not igFil.isIgnoreFiles(tmp_path): if '+' not in tmp_path: if 'AppDelegate.' not in tmp_path: getPropertyNameAtSwiftAndMiss( tmp_path, propertyPrefix) conLog.info('[ReadProH OK] ' + tmp_path) except Exception as e: try: conLog.error('[ReadProH Fail] ' + str(e)) finally: e = None del e else: cycTraPropertyListMap(tmp_path, propertyPrefix)
def cycTra_for_methodListMap(file_dir, funNamePrefix): fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if tmp_path.endswith('.h'): pass if not igFil.isIgnoreFiles(tmp_path): if '+' not in tmp_path: confusionAt_H_Obj(tmp_path, funNamePrefix) conLog.info('[ConFunH OK] ' + tmp_path) if tmp_path.endswith('.swift'): if not igFil.isIgnoreFiles(tmp_path): if '+' not in tmp_path: if 'Tests.swift' not in tmp_path: confusionAt_Swift_Obj(tmp_path, funNamePrefix) conLog.info('[ConFunH OK] ' + tmp_path) except Exception as e: try: conLog.error('[ConFunH Fail] ' + str(e)) finally: e = None del e else: cycTra_for_methodListMap(tmp_path, funNamePrefix)
def findProjectPbxproj(file_dir): if _projectNameTup == None: return fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if tmp_path.endswith('project.pbxproj'): if not igFil.isIgnoreFiles(tmp_path): modifyProjectPbxproj(tmp_path) if '/Pods/' in tmp_path or tmp_path.endswith('contents.xcworkspacedata'): modifyProjectPbxproj(tmp_path) else: if '/Pods/' not in tmp_path: if tmp_path.endswith('Podfile'): modifyProjectPbxproj(tmp_path) conLog.info('[MissProName OK] ' + tmp_path) except Exception as e: try: conLog.error('[MissProName Fail] ' + str(e)) finally: e = None del e else: findProjectPbxproj(tmp_path)
def modifyFolderName(file_dir): if _projectNameTup == None: return fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) tmp_pathList = '/.git/' not in tmp_path and tmp_path.split('/') FolderName = tmp_pathList[-1] if _projectNameTup[0] in FolderName: FolderName = FolderName.replace(_projectNameTup[0], _projectNameTup[1]) tmp_pathList[-1] = FolderName new_path = '/'.join(tmp_pathList) try: os.rename(tmp_path, new_path) conLog.info('[MissProName OK] ' + new_path) tmp_path = new_path except Exception as e: try: conLog.error('[MissProName Fail] ' + str(e)) finally: e = None del e if not os.path.isdir(tmp_path): pass else: modifyFolderName(tmp_path)
def realizeRubbishFunCode(file_dir, amount, rubPrefix): global allObjRubCodeMap personinfo = ZFJPersoninfo() rubbishFileMap = personinfo.rubbishFileMap fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): object_name = tmp_path.split('/')[-1].split('.')[0] if object_name not in rubbishFileMap.keys(): rubCodeTuple = None if object_name not in allObjRubCodeMap.keys(): rubCodeTuple = addRandomCode.addRandomClass( amount, rubPrefix) allObjRubCodeMap[object_name] = rubCodeTuple else: rubCodeTuple = allObjRubCodeMap[object_name] if tmp_path.endswith('.h'): if not notUpdateFile(tmp_path): addCodeAtHFile(tmp_path, rubCodeTuple) conLog.info('[AddCode OK] ' + tmp_path) if tmp_path.endswith('.m') or tmp_path.endswith('.mm'): if not notUpdateFile(tmp_path): addCodeAtMFile(tmp_path, rubCodeTuple) conLog.info('[AddCode OK] ' + tmp_path) continue realizeRubbishFunCode(tmp_path, amount, rubPrefix)
def cycTraMissPropertyAtMFile(file_dir): fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if tmp_path.endswith('.m') or tmp_path.endswith( '.mm') or tmp_path.endswith( '.xib') or tmp_path.endswith('.storyboard'): if '/Pods/' not in tmp_path: missPropertyAtMFile(tmp_path) conLog.info('[ConFunM OK] ' + tmp_path) if tmp_path.endswith('.swift'): if '/Pods/' not in tmp_path: missPublicProAtSwiftFile(tmp_path) conLog.info('[ConFunM OK] ' + tmp_path) except Exception as e: try: conLog.error('[ConFunM Fail] ' + str(e)) finally: e = None del e else: cycTraMissPropertyAtMFile(tmp_path)
def startCleanRubRes(file_dir, ignoreList=[]): global _isCleaing if _isCleaing == True: return _isCleaing = True initData() conLog.info('------------------------------------------------------------') searchAllResName(file_dir) conLog.info_delRes('----------------------------------------') conLog.info_delRes(_resNameMap) for item in ignoreList: if item in list(_resNameMap.keys()): del _resNameMap[item] conLog.info_delRes('----------------------------------------') conLog.info_delRes(ignoreList) searchProjectCode(file_dir) conLog.info_delRes('----------------------------------------') conLog.info_delRes(_resNameMap) delAllRubRes() conLog.info_delRes('----------------------------------------') conLog.info_delRes(_hadDelMap) conLog.info_delRes('----------------------------------------') conLog.info_delRes(_resNameMap) _isCleaing = False
def reviseFilesName(file_dir): fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if not igFil.isIgnoreFiles(tmp_path): if tmp_path.endswith('.h') or tmp_path.endswith( '.m') or tmp_path.endswith( '.xib') or tmp_path.endswith('.swift'): for object_name in objectNamesMap.keys(): replace_name = objectNamesMap[object_name] new_path = tmp_path.replace( object_name + '.', replace_name + '.') if tmp_path != new_path: os.rename(tmp_path, new_path) conLog.info('[ReFilNa Scu] ' + tmp_path) except Exception as e: try: conLog.error('[ReFilNa Fail] ' + str(e)) finally: e = None del e else: reviseFilesName(tmp_path)
def startAddRubFileClass(file_dir, fileCount=5, amount=5, rubPrefix=''): resetData() searchXcodeprojPath(file_dir) createRubbishOCFile(fileCount, amount, rubPrefix) conLog.info(':') conLog.info(_createFileMap) setCreateFolderChildrenCode() addCodeInProjectPbxproj()
def startObfuscatedObjName(path, prefix=''): initData() conLog.info('----------------------------------------') getObjectNames(path, prefix) personinfo = ZFJPersoninfo() personinfo.objectNamesMap = objectNamesMap conLog.info(objectNamesMap) replaceFilesObjNames(path) reviseFilesName(path)
def startMissFolder(file_dir, folderPreFix): global _folderPreFix initData() _folderPreFix = folderPreFix conLog.info('----------------------------------------') getProjectPbxprojPath(file_dir) personinfo = ZFJPersoninfo() personinfo.method_list_map = PBXGroupMap conLog.info(PBXGroupMap) getPathChildMap(file_dir) setPathForPBXGroupMap() findFolderAndMiss(file_dir) getNewProjectPbxprojPath(file_dir)
def startConfusionFun(file_dir, funNamePrefix): initData() conLog.info('----------------------------------------') cycTra_for_methodListMap(file_dir, funNamePrefix) personinfo = ZFJPersoninfo() personinfo.method_list_map = method_list_map conLog.info(method_list_map) conLog.info('----------------------------------------') cycTra_for_propertyList(file_dir) conLog.info('----------------------------------------') cycTra_for_ConMFile(file_dir)
def startConfusionPro(file_dir, propertyPrefix): initData() conLog.info('----------------------------------------') cycTraPropertyListMap(file_dir, propertyPrefix) personinfo = ZFJPersoninfo() personinfo.propertyMisMap = propertyMisMap conLog.info(propertyMisMap) conLog.info('----------------------------------------') cycTraMyPropertyList(file_dir) conLog.info('----------------------------------------') cycTraMissPropertyAtMFile(file_dir)
def startSourceName(file_dir, imgPreFix): initData() conLog.info('----------------------------------------') searchXcassets(file_dir, imgPreFix) personinfo = ZFJPersoninfo() personinfo.sourceMap = sourceMap personinfo.xcassetsMap = xcassetsMap conLog.info(sourceMap) conLog.info(xcassetsMap) conLog.info('----------------------------------------') upDateContentsJson() startReplaceSouName(file_dir)
def getNewProjectPbxprojPath(file_dir): fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if tmp_path.endswith('project.pbxproj'): if '/Pods/' not in tmp_path: missProjectPbxproj(tmp_path) conLog.info('[MissFolder OK] ' + tmp_path) except Exception as e: try: conLog.error('[MissFolder Fail] ' + str(e)) finally: e = None del e else: getNewProjectPbxprojPath(tmp_path)
def startReplaceSouName(file_dir): fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if not igFil.isIgnoreFiles(tmp_path): if '/Contents.json' not in tmp_path: replaceAtFile(tmp_path) conLog.info('[RepSouNa OK] ' + tmp_path) except Exception as e: try: conLog.error('[RepSouNa Fail] ' + str(e)) finally: e = None del e else: startReplaceSouName(tmp_path)
def propertyListAtMFile(file_dir): fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if tmp_path.endswith('.m') or tmp_path.endswith('.mm'): if not notUpdateFile(tmp_path): getPropertyList(tmp_path) conLog.info('[CallFun OK] ' + tmp_path) except Exception as e: try: conLog.error('[CallFun Fail] ' + str(e)) finally: e = None del e else: propertyListAtMFile(tmp_path)
def searchMissCode(file_dir): fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if not igFil.isIgnoreFiles(tmp_path): pass if tmp_path.endswith('.m'): missCodeAtFile(tmp_path) conLog.info('[SearchStr OK] ' + tmp_path) except Exception as e: try: conLog.error('[SearchStr Fail] ' + str(e)) finally: e = None del e else: searchMissCode(tmp_path)
def replaceFilesObjNames(file_dir): fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if '/Pods/' not in tmp_path: if not tmp_path.endswith('.json'): if '/.git/' not in tmp_path: reviseObjectNames(tmp_path) conLog.info('[ReObjNa OK] ' + tmp_path) except Exception as e: try: conLog.error('[ReObjNa Fail] ' + str(e)) finally: e = None del e else: replaceFilesObjNames(tmp_path)
def encryptString(file_dir): fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if not igFil.isIgnoreFiles(tmp_path): pass if not tmp_path.endswith('.pch'): obfuscate(tmp_path) conLog.info('[EncrStr OK] ' + tmp_path) except Exception as e: try: conLog.error('[EncrStr Fail] ' + str(e)) finally: e = None del e else: encryptString(tmp_path)
def searchPchFile(file_dir): fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if tmp_path.endswith('.pch'): pass if '/Pods/' not in tmp_path: addCodeAtPch(tmp_path) conLog.info('[SearPCH OK] ' + tmp_path) except Exception as e: try: conLog.error('[SearPCH Fail] ' + str(e)) finally: e = None del e else: searchPchFile(tmp_path)
def getProjectPbxprojPath(file_dir): global pbxprojPath fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if tmp_path.endswith('project.pbxproj'): if '/Pods/' not in tmp_path: pbxprojPath = tmp_path getPBXGroupMap(tmp_path) conLog.info('[GetPbxPath OK] ' + tmp_path) except Exception as e: try: conLog.error('[GetPbxPath Fail] ' + str(e)) finally: e = None del e else: getProjectPbxprojPath(tmp_path)
def addWordBtnClick(self): personinfo = ZFJPersoninfo() fail_list = [] scu_list = [] addText = self.addTextEdit.toPlainText() addText = ''.join(addText.split()) addText.replace(',', ',') new_lexicon_list = addText.split(',') for word in new_lexicon_list: if len(word) > 0: if word not in personinfo.lexicon_list: personinfo.lexicon_list.append(word) scu_list.append(word) else: fail_list.append(word) else: conLog.info('AddLexicon Fail ') if len(fail_list) > 0: self.megBoxInfor('添加成功:' + ','.join(fail_list)) conLog.info('AddLexicon Fail ' + ','.join(fail_list)) if len(scu_list) > 0: file_data = ','.join(personinfo.lexicon_list) Wopen = open('lexicon.txt', 'w') Wopen.write(file_data) Wopen.close() conLog.info('AddLexicon OK ' + ','.join(scu_list)) self.lexiconEdit.setPlainText(','.join(personinfo.lexicon_list))
def startEncryptStr(file_dir): conLog.info('--------------------开始查找PCH--------------------') searchPchFile(file_dir) conLog.info('--------------------开始查找字符串--------------------') searchMissCode(file_dir) conLog.info('--------------------开始加密字符串--------------------') encryptString(file_dir)
def startDeleteNotes(file_dir): fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if not igFil.isIgnoreFiles(tmp_path): if tmp_path.endswith('.h') or tmp_path.endswith( '.m') or tmp_path.endswith( '.mm') or tmp_path.endswith( '.swift') or tmp_path.endswith('.pch'): readFileEveryLine(tmp_path) conLog.info('[DelNote OK] ' + tmp_path) except Exception as e: try: conLog.error('[DelNote Fail] ' + str(e)) finally: e = None del e else: startDeleteNotes(tmp_path)
def startModifyProjectName(file_dir): initData() conLog.info('----------------------------------------') getMyProjectName(file_dir) conLog.info(_projectNameTup) conLog.info('----------------------------------------') modifyFolderName(file_dir) findProjectPbxproj(file_dir)
def findFolderAndMiss(file_dir): global _pchPath global _plistPath fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): if tmp_path.endswith('.pch'): if '/Pods/' not in tmp_path: _pchPath = tmp_path if tmp_path.endswith('/Info.plist'): if 'Tests/' not in tmp_path: if '/Pods/' not in tmp_path: _plistPath = tmp_path else: missName = os.path.isdir(tmp_path) and getThisPathMissName( tmp_path) if missName != None: pathList = tmp_path.split('/') del pathList[-1] pathList.append(missName) temp = '/'.join(pathList) oldname = os.path.join(file_dir, tmp_path) newname = os.path.join(file_dir, temp) try: os.rename(oldname, newname) findFolderAndMiss(newname) conLog.info('[MissFolder OK] ' + newname) except Exception as e: try: conLog.error('[MissFolder Fail] ' + str(e)) findFolderAndMiss(tmp_path) finally: e = None del e else: findFolderAndMiss(tmp_path)
def cycTra_for_ConMFile(file_dir): fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if tmp_path.endswith('.m'): if '/Pods/' not in tmp_path: confusionAt_M_Obj(tmp_path) conLog.info('[ConFunM OK] ' + tmp_path) if tmp_path.endswith('.swift'): if '/Pods/' not in tmp_path: confusionSwiftObjFun(tmp_path) conLog.info('[ConFunM OK] ' + tmp_path) except Exception as e: try: conLog.error('[ConFunM Fail] ' + str(e)) finally: e = None del e else: cycTra_for_ConMFile(tmp_path)
def cycTraMyPropertyList(file_dir): fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if tmp_path.endswith('.m') or tmp_path.endswith('.mm'): if '/Pods/' not in tmp_path: getMyPropertyList(tmp_path) conLog.info('[GetGroL OK] ' + tmp_path) if tmp_path.endswith('.swift'): if '/Pods/' not in tmp_path: getMyPropertyListForSwift(tmp_path) conLog.info('[GetGroL OK] ' + tmp_path) except Exception as e: try: conLog.error('[GetGroL Fail] ' + str(e)) finally: e = None del e else: cycTraMyPropertyList(tmp_path)
def startUpdateSourceHash(file_dir): fs = os.listdir(file_dir) for dir in fs: tmp_path = os.path.join(file_dir, dir) if not os.path.isdir(tmp_path): try: if not igFil.isIgnoreFiles(tmp_path): if isImage(tmp_path): old_hash = getFileHash(tmp_path) updateImgHash(tmp_path) new_hash = getFileHash(tmp_path) conLog.info('[UPdHash OK] ' + tmp_path) conLog.tips('[UPdHash Meg] Old:' + old_hash + '<->New:' + new_hash) except Exception as e: try: conLog.error('[UPdHash Fail] ' + str(e)) finally: e = None del e else: startUpdateSourceHash(tmp_path)