def main( ):
import confuse_audio
confuse_audio.run(work_directory)
import confuse_picture
confuse_picture.run(work_directory)
import confuse_meta
confuse_meta.run(work_directory)
import confuse_anim
confuse_anim.run(work_directory)
import confuse_video
confuse_video.run(work_directory)
import confuse_text
confuse_text.run(work_directory)
import confuse_bytes
confuse_bytes.run(work_directory)
# 植入垃圾代码 稀释马甲代码
# domain
if __name__ == "__main__":
work_directory = input('input work directory:\n')
work_directory = work_directory.replace('\\','/')
import unittestutls
howlong_benrunning = unittestutls.get_func_time(func=main,log=False)
input(f'appliction complete: running time {
round(howlong_benrunning,2)} seconds')
以二进制的方式读入后覆盖源文件
from os.path import isfile
class confuse_base( ):
def __init__(self, filepath:str) -> None:
if not isfile(filepath):
raise ValueError(f"not a file type: {
filepath}")
self.filepath = filepath
def confuse( self ):
with open( self.filepath,'rb+') as fp:
content = fp.read()
fp.seek(0)
fp.write(content)
使用PIL修改像素矩阵 确保图片像素变动的同时 表现上无明显差异
from findutils import find_img_files
def run(pro_dir:str):
pro_dir = pro_dir.replace('\\','/')
img_urls = find_img_files( pro_dir )
num_imgs = len(img_urls)
if num_imgs == 0:
print(f'not found image in directory: {
pro_dir}')
return
from imgfileutils import auto_modify_img_pixels
import time
s = time.time()
executor = None
# 使用进程池
if num_imgs >= 1e+5:
import concurrent.futures
executor = concurrent.futures.ProcessPoolExecutor()
# 使用线程池
elif num_imgs >= 1e+3:
import concurrent.futures
executor = concurrent.futures.ThreadPoolExecutor()
if executor != None:
# 提交图像处理任务
futures = [executor.submit(auto_modify_img_pixels, arg) for arg in img_urls]
# 等待所有任务完成
concurrent.futures.wait(futures)
else:
#使用协程池
import gevent
from gevent import monkey; monkey.patch_all()
tasks = [gevent.spawn(auto_modify_img_pixels, arg) for arg in img_urls]
gevent.joinall(tasks)
e = time.time()
print(