This is a Python script that implements a simple encryption and decryption algorithm. The script uses four different encryption methods: base64 encoding with 16, 32, 64, and 85 bits. The encryption method used is selected randomly. The script also includes a simple anti-debugging technique and a self-modifying code feature.
The script consists of several functions:
random_char
: generates a random character from the ASCII letters.encrypt
: takes a list of lines as input, encrypts each line using one of the four encryption methods, and returns the encrypted lines and the encryption method used.write_lines
: writes the encrypted lines to a file.decrypt
: takes the encrypted lines and the encryption method used, decrypts the lines, and executes the decrypted code.main
: the main function that reads the script, encrypts the lines, writes the encrypted lines to a file, and decrypts the lines.
- The script starts by importing the necessary libraries:
os
,base64
,random
,string
,hashlib
,struct
,socket
. - The
random_char
function generates a random character from the ASCII letters. - The
encrypt
function takes a list of lines as input, encrypts each line using one of the four encryption methods, and returns the encrypted lines and the encryption method used. - The
write_lines
function writes the encrypted lines to a file. - The
decrypt
function takes the encrypted lines and the encryption method used, decrypts the lines, and executes the decrypted code. - The
main
function reads the script, encrypts the lines, writes the encrypted lines to a file, and decrypts the lines.
To use the script, simply run it using the Python interpreter. The script will encrypt the lines and write them to a file. To decrypt the lines, run the script again with the encryption method used as an argument.
The script uses four different encryption methods: base64 encoding with 16, 32, 64, and 85 bits. The encryption method used is selected randomly.
This script is licensed under the MIT License.