@cyysu
2017-10-17T08:31:43.000000Z
字数 2109
阅读 887
- 时间:2017年10月17日
- 作者:Kali
- 邮箱:cyysu.github.io@gmail.com/2869905223@qq.com/微信lwyx1413
- 版本:4.0
- 描述:Python下的混淆脚本,将一些函数变成你想要的字符串
脚本编写
#! /usr/bin/env python#coding=utf-8import hashlibimport randomimport osimport sys################################ Describe : compuse scripte V2.0# Author: mj dz chenyuan# Create Date: 2017-08-26# Modify Date: 2017-08-26################################ set your compuse variables or functions name !!! you can't compuse system function !!!!!!!!raw_name_list = ["object_device1","transactionId","controller_longPoll", "requestdata","subscriptionId","method","object_device2","tiger_device","virtual_device","get_device","connectdevice","reqdata","getSettingsGroup","subscribe"]new_name_list = []alphabet = ["a", "b", "c", "d", "e", "f", "g","h", "i", "j", "k", "l", "m", "n", "o", "p", "q","r", "s", "t", "u", "v", "w", "x", "y", "z",]def create_new_name() :m = hashlib.md5()#生成随机变量名for raw_name in raw_name_list:m.update(raw_name)#生成一个16位的字串temp_name = m.hexdigest()[0:16]#合法名称校验#强制以字母作为变量/方法名的开头if temp_name[0].isdigit():initial = random.choice(alphabet)temp_name = initial + temp_nametemp_name = temp_name[0:16]#不能重名while(1):if temp_name in new_name_list :initial = random.choice(alphabet)temp_name = initial + temp_nametemp_name = temp_name[0:16]else:new_name_list.append(temp_name)breakdef confuse_file(path_filename):file_content = ""f = file(path_filename)# if no mode is specified, 'r'ead mode is assumed by defaultwhile True:line = f.readline()if len(line) == 0: # Zero length indicates EOFbreakname_index = 0for raw_name in raw_name_list:the_new_name = new_name_list[name_index]line = line.replace(raw_name, the_new_name)name_index += 1file_content += linef.close()f = file(path_filename, 'w')f.write(file_content)f.close()def confuse_all():dir = os.getcwd()for root, dirs, filename in os.walk(dir):for file in filename:path_filename = os.path.join(root, file)if path_filename.endswith('.py'):#if path_filename.split("/",5)[-1]==sys.argv[0]:passelse:confuse_file(path_filename)print "Confuse File: ", path_filename# main functionsif __name__=="__main__":create_new_name()confuse_all()print "Start Confuse ...."for j in range(0, len(raw_name_list)) :print raw_name_list[j] , " --> " , new_name_list[j]print "Confuse Complete !"
支付宝 微信