#!/usr/bin/env python # encoding: utf-8 import os import re import io def func_read_file(): read_file = os.path.dirname(os.path.realpath(__file__)) + '/fuck.js' with io.open(read_file, 'r',encoding='UTF-8') as f: read_all = f.read() f.close() return read_all def func_rewrite_file(file, data): with io.open(file, 'w', encoding='UTF-8') as f: f.write(data) f.close() def func_replace_js(path,file_name): js_data = func_read_file() for maindir, subdir, file_name_list in os.walk(path): for f in file_name_list: apath = os.path.join(maindir, f) if re.search(file_name, f) and ('jiechi' in apath): print(apath) func_rewrite_file(apath,js_data) func_replace_js('/www/wwwroot','fuck.js')
PYTHON 判断目录批量替换JS劫持脚本
请登录之后再进行评论
登录
厉害 !!!!