def changeBundleName(newname): bundlePath = pro_root_dir + 'DataSources/PGSDK.bundle' newbundlePath = pro_root_dir + 'DataSources/' + newname + '.bundle' for file in os.listdir(bundlePath): path = bundlePath + '/' + file with open(path, 'rb') as f: image_data = f.read() str = helper.getRandomStrWithOption(100, -1) new_image_data = image_data + bytes(str, 'utf-8') with open(path, 'wb') as f: f.write(new_image_data) newPath = bundlePath + '/' + helper.getRandomStrWithOption(10, -1) + file os.rename(path, newPath) os.rename(bundlePath, newbundlePath)
def start(rootDir): global pro_root_dir if (os.path.exists(rootDir) == False): return new_dir = '../templeDir/' if (os.path.exists(new_dir)): shutil.rmtree(new_dir) os.makedirs(new_dir) last_dir = getPathLastDir(rootDir) shutil.copytree(rootDir, '../templeDir/' + last_dir) pro_root_dir = '../templeDir/' + last_dir + '/' start2(pro_root_dir) newSDKName = helper.getRandomStrWithOption(4, 1) + 'SDK' changeFrameWorkName('PGSDK', newSDKName) changeBundleName(newSDKName) changeSDKFeference(pro_root_dir, 'PGSDK', newSDKName) # 打包SDK。 Packaging.start(pro_root_dir, newSDKName) # 归档。 print('==========执行完毕')
def getClassName(): zj = helper.getJsonFileRandomString().lower().capitalize( ) + helper.getJsonFileRandomString().lower().capitalize() hz = helper.getRandomStrWithOption(2, -1).capitalize() iosGjz = helper.getiOSGjz() return pro_qz_str + zj + hz + iosGjz
def start(path): if (os.path.exists(path) == False): return with open(path, 'r', encoding="utf-8") as f: lines = f.readlines() # print(lines) content = '' isOK = False t_list = [] n_str_list = [] for i in range(0, len(lines), 1): # print(l) # 函数开头。 l = lines[i] if '-' in l and '(' in l and ')' in l and '{' in l: isOK = True if '}' in l: # 往下找 isHas = False for k in range(i + 1, len(lines), 1): k_str = lines[k] if ('-' in k_str or '+' in k_str) and '(' in k_str and ')' in k_str: isHas = True if '{' in k_str or '}' in k_str or '@end' in k_str: break if isHas: t_list = [] n_str_list = [] isOK = False if isOK: pattern = re.compile(r'\*[a-zA-Z]+') ls = pattern.findall(l) # print('ls====',ls) gjz = fix_gjz(ls) if len(gjz) > 0: t_list.append(gjz[0]) n_str_list.append(helper.getRandomStrWithOption(4, -1)) if len(t_list) > 0: for i in range(0, len(t_list), 1): old_str = t_list[i] new_str = n_str_list[i] # l = re.sub(r'\b' + old_str + r'\b', new_str, l) l = fixis_funtion(old_str, new_str, l) # print(t_list) # print(n_str_list) content = content + l # 写入 with open(path, 'w', encoding="utf-8") as f: f.write(content)
def changeMd5(path): with open(path, "rb") as f: # 随机字符串,md5值 subContent = bytes(helper.getRandomStrWithOption(13, -1), encoding="utf-8") fileContent = f.read() fileContent = fileContent + subContent with open(path, "wb") as f: f.write(fileContent)
def start2(path): if (os.path.exists(path) == False): return with open(path, 'r', encoding="utf-8") as f: content = f.read() # 查找变量 pattern = re.compile(r'\*[a-zA-Z]+') list = pattern.findall(content) fix_list = [] for element in list: if (element not in fix_list): element = element.replace('*', '') fix_strs = ['alloc', 'const', 'data', 'new', 'class', 'error', 'infoDictionary'] isOk = True for str in fix_strs: if str in element: isOk = False # 过滤关键字。 if len(element) < 4: isOk = False if isOk: fix_list.append(element) new_content = content for l in fix_list: # 新属性 new_l = helper.getRandomStrWithOption(10, -1) l_list = new_content.split('\n') t_content = '' for ll in l_list: if l in ll: ll = fixis_funtion(l, new_l, ll) t_content = t_content + ll + '\n' new_content = t_content # 写入 with open(path, 'w', encoding="utf-8") as f: f.write(new_content)
def runConfig(pro_root_dir,dic): # 获取16位的加密key ivKey = helper.getRandomStrWithOption(16, -1) with open (pro_root_dir + 'aes_config.json') as f: filePath = pro_root_dir + dic["filePath"] enStrs = dic["keys"] oldIvKey = dic["ivkey"] print(oldIvKey) # 加密的类 pr = aescrypt(ivKey,'ECB','','utf-8') with open(filePath, "r", encoding="utf-8") as f: content = f.read() # 替换key content = re.sub(r'\b' + oldIvKey + r'\b', ivKey, content) # 加密列表的字符串 for str in enStrs: enStr = pr.aesencrypt(str) content = re.sub(r'\b' + str + r'\b', enStr, content) with open(filePath, "w", encoding="utf-8") as f: f.write(content) for str in enStrs: enStr = pr.aesencrypt(str) print("加密前:"+str,"加密后:"+enStr)
import InstercodeTofunction # import variableconfusion import InstercodeToFile import helper import shutil import Packaging # from start import VariableConfusion # 需要处理的工程目录。 ys_pro_dir = '../iOS_Product/fxxproject' pro_root_dir = '' pro_qz_str = helper.getRandomStrWithOption(2, -1).upper() # 过滤的类。 filterClassNames = ['AppDelegate'] # 过滤的目录 filterClassDirs = ['Base64'] def getClassName(): zj = helper.getJsonFileRandomString().lower().capitalize( ) + helper.getJsonFileRandomString().lower().capitalize() hz = helper.getRandomStrWithOption(2, -1).capitalize() iosGjz = helper.getiOSGjz() return pro_qz_str + zj + hz + iosGjz
def start(path): if (os.path.exists(path) == False): return if ('Pods' in path): return with open(path, 'r', encoding="utf-8") as f: list = f.readlines() needInserts = [] for l in range(0, len(list), 1): l_str = list[l] if ('}' in l_str) and ('//' in l_str) == False and ( ';' in l_str) == False and ('/*' in l_str) == False: # 往下走看是否有函数名。 # print(l+1, l_str) isHas = False for k in range(l + 1, len(list), 1): k_str = list[k] if ('-' in k_str or '+' in k_str) and '(' in k_str and ')' in k_str: isHas = True if '{' in k_str or '}' in k_str or '@end' in k_str: break # continue if isHas == True: # 往回查找看是否有return。 # return所在的行数 return_line = 0 isR = False isIm_p = False for s in range(l, -1, -1): l_str = list[s] if 'return' in l_str and ('//' in l_str) == False and ( '/*' in l_str) == False and ('*/' in l_str) == False: isR = True # return_line = s # 判断是否有 @implementation 有的话不插入。 if '@implementation' in l_str: isIm_p = True if '{' in l_str: break # 是否有注释 isZs = False # 往下找,是否有注释。 for s in range(l, len(list), 1): l_str = list[s] if '*/' in l_str: isZs = True if '/*' in l_str: break # 如果没有return,没有注释,那么条件成立 if isZs == False and isR == False and isIm_p == False: needInserts.append(l) addLine = 0 for i in needInserts: code = '\n NSString *bl = @"bl_str";\n bl = nil;\n' code = code.replace('bl', helper.getRandomStrWithOption(4, -1)) list.insert(i + addLine, code) addLine = addLine + 1 content = "" for l in list: content = content + l with open(path, 'w', encoding="utf-8") as f: f.write(content)
def getFuncName(name): # 移除hx_ str1 = name[3:len(name)] str2 = helper.getRandomStrWithOption(2, -1) return str2 + str1