栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Python 混淆源代码

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Python 混淆源代码

发现好多python混淆库要么不能用要么操作复杂,所以写了这个简易轻量的源码,支持替换多线程,可自行扩展~

#!/usr/bin/python3
# -*- coding: UTF-8 -*-
"""
@Author: Cliang
"""
import re

openfile = input('文件名:')
text = open(openfile, encoding='utf-8').read()

wd_df = re.findall('ndef (w*)(', text)   # 查找定义的方法名称
wd_df = list(set(wd_df))
for i in wd_df:     # 剔除特殊的方法
    if i[0:2] == "__":
        wd_df.remove(i)
    if i == 'super':
        wd_df.remove(i)
idlist = []
for i in wd_df:
    idlist.append('O' + str(hash(i))[-7:])      # 用字母O+哈希后七位重新命名方法

cs = len(wd_df)
if cs == len(set(idlist)):
    while cs > 0:
        cs -= 1
        # 替换方法名
        text = text.replace(wd_df[cs] + '(', idlist[cs] + '(')
        # 替换多线程
        text = text.replace('target=' + wd_df[cs],'target=' + idlist[cs])
        text = text.replace('global ' + wd_df[cs], 'global ' + idlist[cs])
        text = text.replace(', ' + wd_df[cs], ', ' + idlist[cs])
    print('成功替换的方法有:', wd_df, 'n', idlist)
else:
    print('哈希存在重复')

save_name = str(id(openfile)) + '.py'
file_save = open(save_name, 'w', encoding='utf-8')
file_save.write(text)
file_save.close()

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/300168.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号